0

I am writing a program to compute Groebner bases using the library FGB. While it has a C interface, I am calling the library from C++ code compiled with g++ on Ubuntu.

Compiling with the option -g and using x/i $pc in gdb, the illegal instruction is as follows.

0x421c39 FGb_xmalloc_spec+985: vcvtsi2sd %rbx,%xmm0,%xmm0

The line above has angle brackets around FGB_xmalloc_spec+985. As far as I can tell, my processor does not support this instruction, and I am trying to figure out why the program uses it. It looks to me like the instruction comes from the library code. However, the code I am compiling used to work on the desktop it is now failing on - one day just started throwing the illegal instruction. I assumed I screwed up some libraries or something, so I reinstalled Ubuntu 16.04 but I continue to get the illegal instruction. The same exact code does work on another desktop and a chromebook, running Ubuntu 16.04 and 14.04 respectively.

Technical information:

  • g++: 5.4.0 20160609
  • gdb: 7.11.1
  • Ubuntu: 16.04/14.04 LTS
  • Process: x86info output

    Found 4 identical CPUs Extended Family: 0 Extended Model: 1 Family: 6 Model: 23 Stepping: 10 Type: 0 (Original OEM) CPU Model (x86info's best guess): Core 2 Duo Processor name string (BIOS programmed): Intel(R) Core(TM)2 Quad CPU Q9650 @ 3.00GHz

  • cpu flags

    fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm tpr_shadow vnmi flexpriority dtherm

  • Compile line

    g++ -std=c++11 -g -I src -o bin/main.o -c src/main.cpp

    g++ -std=c++11 -g -I src -o bin/Polynomial.o -c src/Polynomial.cpp

    g++ -std=c++11 -g -I src -o bin/Util.o -c src/Util.cpp

    g++ -std=c++11 -g -I src -o bin/Solve.o -c src/Solve.cpp

    g++ -std=c++11 -g -o bin/StartUp bin/main.o bin/Util.o bin/Polynomial.o bin/Solve.o -Llib -lfgb -lfgbexp -lgb -lgbexp -lminpoly -lminpolyvgf -lgmp -lm -fopenmp

At this point, I am not sure what further things I can try to avoid this illegal instruction and welcome any and all suggestions.

RghtHndSd
  • 117
  • 5
  • [vcvtsi2sd](http://www.felixcloutier.com/x86/CVTSI2SD.html) requires a processor with AVX. Have you tried to rebuild the library on this machine and then recompile your program and link against the library? – Michael Petch Feb 16 '17 at 20:50
  • 2
    I assume "getting the illegal instruction" means it crashes it the console? Just because gdb prints it, it doesn't necessarily mean anything is broken, the code may be using runtime cpu detection. It's only a problem if it actually crashes. Also, you forgot to mention which version of FGB you are using and where you got it from. The site you linked does not have any `libfgb` or `libfgbexp` as far as I could tell. – Jester Feb 16 '17 at 23:16
  • @MichaelPetch: I do not believe the source for the library is publicly available. – RghtHndSd Feb 17 '17 at 12:37
  • @Jester: Yes, the program crashes. It is version 1.68 (build 14539). The library is on the site, here is a [direct link to the tarball](http://www-polsys.lip6.fr/~jcf/FGb/C/@downloads/call_FGb6.maclinux.x64.tar.gz). libfgb.a can be found in call_FGb/nv/maple/C/x64 (for linux). – RghtHndSd Feb 17 '17 at 12:42
  • Does the `make test` in that tarball work for you? – Jester Feb 17 '17 at 12:46
  • The code seems to be littered with avx instructions, looks like it is an avx build. Not sure how it ever worked for your non-avx procesor, I don't see any conditionals or other sign of runtime cpu detection. – Jester Feb 17 '17 at 13:03
  • @Jester: Well, I feel pretty silly. I swore that at one time it worked on my home computer. However checking the two other computers that it works on, both processors support avx. With your comment, I am convinced that avx is required to run the fgb library as it is compiled now, which I should have been able to see from my gdb output (but, foolish me, did not believe). If you could make your comment that the library (as compiled) requires avx, I'd accept it as an answer. Or maybe this whole questions should be deleted... – RghtHndSd Feb 17 '17 at 16:05

0 Answers0