eth-sri / ELINA

ELINA: ETH LIbrary for Numerical Analysis
http://elina.ethz.ch/
Other
129 stars 54 forks source link

Cannot build with vector instructions on macOS #29

Closed Cu3PO42 closed 6 years ago

Cu3PO42 commented 6 years ago

Hi,

I am trying to build ELINA on macOS 10.13.5. When not using any vector instructions, it builds correctly. However when using either SSE or AVX support, I get compile errors saying that v_double_type is an undeclared identifier.

According to sysctl the following instruction sets are supported by my CPU, so I believe that both of those options should work:

FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C

My version of clang is:

Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

The full error log given by make IS_VECTOR=-DVECTOR is

(cd elina_auxiliary; make all)
make[1]: Nothing to be done for `all'.
(cd elina_linearize; make all)
make[1]: Nothing to be done for `all'.
(cd partitions_api; make all)
make[1]: Nothing to be done for `all'.
(cd elina_oct; make all)
cc -c -Wcast-qual -Wswitch -Wall -Wextra -Wundef -Wcast-align -Wno-unused -U__STRICT_ANSI__ -fPIC -O3 -DNDEBUG -Werror-implicit-function-declaration -Wbad-function-cast -Wstrict-prototypes -std=c99 -g  -DNUM_LONGLONGRAT -DNUM_DOUBLE -DTHRESHOLD=0.75 -DTIMING -D_GNU_SOURCE -pthread -fno-tree-vectorize -m64 -march=native   -I../elina_auxiliary -I../elina_linearize -I../partitions_api   -o opt_oct_closure_dense.o opt_oct_closure_dense.c -L../partitions_api -lpartitions -L../elina_auxiliary -lelinaux -L../elina_linearize -lelinalinearize  -lmpfr  -lgmp -lm
clang: warning: -lpartitions: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lelinaux: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lelinalinearize: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lmpfr: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lgmp: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L../partitions_api' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L../elina_auxiliary' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L../elina_linearize' [-Wunused-command-line-argument]
In file included from opt_oct_closure_dense.c:22:
In file included from ./opt_oct_closure_dense.h:29:
In file included from ./opt_oct_hmat.h:31:
In file included from ./opt_oct_internal.h:87:
In file included from ./opt_oct.h:38:
In file included from ../elina_linearize/elina_generic.h:35:
In file included from ../elina_linearize/elina_linearize.h:32:
../elina_linearize/elina_rat.h:66:68: warning: unused parameter 'num' [-Wunused-parameter]
static inline bool elina_rat_set_int(elina_rat_t *a, long long int num){
                                                                   ^
opt_oct_closure_dense.c:51:3: error: use of undeclared identifier 'v_double_type'
                v_double_type t1 = v_set1_double(temp[i^1]);
                ^
opt_oct_closure_dense.c:55:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type t2 = v_load_double(temp + j*v_length);
                        ^
opt_oct_closure_dense.c:56:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type op1 = v_add_double(t1,t2);
                        ^
opt_oct_closure_dense.c:57:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type op2 = v_load_double(p + j*v_length);
                        ^
opt_oct_closure_dense.c:58:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type res = v_min_double(op1, op2);
                        ^
opt_oct_closure_dense.c:60:4: error: implicit declaration of function 'v_store_double' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
                        v_store_double(m + (((i+1)*(i+1))/2) + j*v_length, res);
                        ^
opt_oct_closure_dense.c:60:4: warning: this function declaration is not a prototype [-Wstrict-prototypes]
opt_oct_closure_dense.c:60:55: error: use of undeclared identifier 'res'
                        v_store_double(m + (((i+1)*(i+1))/2) + j*v_length, res);
                                                                           ^
opt_oct_closure_dense.c:100:3: error: use of undeclared identifier 'v_double_type'
                v_double_type t1 = v_set1_double(temp[i^1]);
                ^
opt_oct_closure_dense.c:104:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type t2 = v_load_double(temp + j*v_length);
                        ^
opt_oct_closure_dense.c:105:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type op1 = v_add_double(t1,t2);
                        ^
opt_oct_closure_dense.c:106:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type op2 = v_load_double(p + j*v_length);
                        ^
opt_oct_closure_dense.c:107:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type res = v_min_double(op1, op2);
                        ^
opt_oct_closure_dense.c:109:55: error: use of undeclared identifier 'res'
                        v_store_double(m + (((i+1)*(i+1))/2) + j*v_length, res);
                                                                           ^
opt_oct_closure_dense.c:222:3: error: use of undeclared identifier 'v_double_type'
                v_double_type t1 = v_set1_double(m[ind2]);
                ^
opt_oct_closure_dense.c:223:3: error: use of undeclared identifier 'v_double_type'
                v_double_type t2 = v_set1_double(m[ind1]);
                ^
opt_oct_closure_dense.c:229:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type t3 = v_load_double(p1 + j*v_length);
                        ^
opt_oct_closure_dense.c:230:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type op1 = v_add_double(t1,t3);
                        ^
opt_oct_closure_dense.c:232:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type t4 = v_load_double(p2 + j*v_length);
                        ^
opt_oct_closure_dense.c:233:4: error: use of undeclared identifier 'v_double_type'
                        v_double_type op2 = v_add_double(t2,t4);
                        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 warnings and 20 errors generated.
make[1]: *** [opt_oct_closure_dense.o] Error 1
make: *** [c] Error 2

Please let me know if there's any other information on my system that you need.

GgnDpSngh commented 6 years ago

Hi,

Thanks for trying out ELINA. Can you check if your system has "immintrin.h" and if yes, can you send it to me?

Cheers, Gagan

Cu3PO42 commented 6 years ago

Hi,

Thanks for getting back to me! My system has multiple copies of that file from various compilers, including one in the standard include path that should be picked up by clang when compiling ELINA. I have uploaded it to a gist.

Best regards,
Tobias

GgnDpSngh commented 6 years ago

I think I have seen this bug before, can you try removing ELINA completely from your system and then reinstall again with VECTOR option?

Cheers, Gagan

Cu3PO42 commented 6 years ago

I have not previously run make install, so I just removed my clone of the repository, cloned it again and ran the build commands. I am unfortunately still getting the same error.

GgnDpSngh commented 6 years ago

Hi Tobias,

I managed to reproduce your bug on my machine. I have updated the configure file to fix this. Try running ./configure -use-vector to build the ELINA Octagon library with the AVX vector instructions. Let me know if this works.

Cheers, Gagan

Cu3PO42 commented 6 years ago

Hi Gagendeep,

that did indeed fix the build error I was experiencing! It might be of note that the first time I re-ran make the compilation error was gone, but I did get a linker error saying some symbols weren't found.

Running make a second time fixed that though.

Thank you so much!