Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build with clang fails when NOFORTRAN=0 #1628

Closed
shahrzad opened this issue Jun 19, 2018 · 4 comments
Closed

Build with clang fails when NOFORTRAN=0 #1628

shahrzad opened this issue Jun 19, 2018 · 4 comments

Comments

@shahrzad
Copy link

Hi,
I am trying to build OpenBlas with clang on Fedrora using:

make CC=clang USE_OPENMP=1
gfortran -O2 -Wall -m64 -fopenmp   -o cblat1 cblat1.o ../libopenblas_haswellp-r0.3.1.dev.a -lm -lpthread -lgfortran -lm -lpthread -lgfortran 
gfortran -O2 -Wall -m64 -fopenmp   -o zblat1 zblat1.o ../libopenblas_haswellp-r0.3.1.dev.a -lm -lpthread -lgfortran -lm -lpthread -lgfortran 
../libopenblas_haswellp-r0.3.1.dev.a(blas_server.o): In function `exec_blas':
blas_server_omp.c:(.text+0x26e): undefined reference to `__kmpc_fork_call'
../libopenblas_haswellp-r0.3.1.dev.a(blas_server.o): In function `.omp_outlined.':
blas_server_omp.c:(.text+0x307): undefined reference to `__kmpc_for_static_init_8'
blas_server_omp.c:(.text+0x599): undefined reference to `__kmpc_for_static_fini'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:141: zblat1] Error 1
make[1]: *** Waiting for unfinished jobs....
../libopenblas_haswellp-r0.3.1.dev.a(blas_server.o): In function `exec_blas':
blas_server_omp.c:(.text+0x26e): undefined reference to `__kmpc_fork_call'
../libopenblas_haswellp-r0.3.1.dev.a(blas_server.o): In function `.omp_outlined.':
blas_server_omp.c:(.text+0x307): undefined reference to `__kmpc_for_static_init_8'
blas_server_omp.c:(.text+0x599): undefined reference to `__kmpc_for_static_fini'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:138: cblat1] Error 1

and when I use NOFORTRAN=0:

make CC=clang USE_OPENMP=1 NOFORTRAN=0
clang -c -O2 -DMAX_STACK_ALLOC=2048 -fopenmp -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DNO_AVX512 -DSMP_SERVER -DUSE_OPENMP -DNO_WARMUP -DMAX_CPU_NUMBER=32 -DMAX_PARALLEL_NUMBER=1 -DASMNAME=ztrtri_LU_parallel -DASMFNAME=ztrtri_LU_parallel_ -DNAME=ztrtri_LU_parallel_ -DCNAME=ztrtri_LU_parallel -DCHAR_NAME=\"ztrtri_LU_parallel_\" -DCHAR_CNAME=\"ztrtri_LU_parallel\" -DNO_AFFINITY -I../.. -DDOUBLE  -DCOMPLEX -DCOMPLEX -DDOUBLE -DUNIT trtri_L_parallel.c -o ztrtri_LU_parallel.o
clang -c -O2 -DMAX_STACK_ALLOC=2048 -fopenmp -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DNO_AVX512 -DSMP_SERVER -DUSE_OPENMP -DNO_WARMUP -DMAX_CPU_NUMBER=32 -DMAX_PARALLEL_NUMBER=1 -DASMNAME=ztrtri_LN_parallel -DASMFNAME=ztrtri_LN_parallel_ -DNAME=ztrtri_LN_parallel_ -DCNAME=ztrtri_LN_parallel -DCHAR_NAME=\"ztrtri_LN_parallel_\" -DCHAR_CNAME=\"ztrtri_LN_parallel\" -DNO_AFFINITY -I../.. -DDOUBLE  -DCOMPLEX -DCOMPLEX -DDOUBLE -UUNIT trtri_L_parallel.c -o ztrtri_LN_parallel.o
ar  -ru ../../libopenblas_haswellp-r0.3.1.dev.a strtri_UU_single.o strtri_UN_single.o strtri_LU_single.o strtri_LN_single.o strtri_UU_parallel.o strtri_UN_parallel.o strtri_LU_parallel.o strtri_LN_parallel.o dtrtri_UU_single.o dtrtri_UN_single.o dtrtri_LU_single.o dtrtri_LN_single.o dtrtri_UU_parallel.o dtrtri_UN_parallel.o dtrtri_LU_parallel.o dtrtri_LN_parallel.o ctrtri_UU_single.o ctrtri_UN_single.o ctrtri_LU_single.o ctrtri_LN_single.o ctrtri_UU_parallel.o ctrtri_UN_parallel.o ctrtri_LU_parallel.o ctrtri_LN_parallel.o ztrtri_UU_single.o ztrtri_UN_single.o ztrtri_LU_single.o ztrtri_LN_single.o ztrtri_UU_parallel.o ztrtri_UN_parallel.o ztrtri_LU_parallel.o ztrtri_LN_parallel.o
make[2]: Leaving directory '/home/shahrzad/src/OpenBLAS_clang/OpenBLAS/lapack/trtri'
make[1]: Leaving directory '/home/shahrzad/src/OpenBLAS_clang/OpenBLAS/lapack'
make[1]: Entering directory '/home/shahrzad/src/OpenBLAS_clang/OpenBLAS/lapack-netlib'
Makefile:7: make.inc: No such file or directory
make[1]: *** No rule to make target 'make.inc'.  Stop.
make[1]: Leaving directory '/home/shahrzad/src/OpenBLAS_clang/OpenBLAS/lapack-netlib'
make: *** [Makefile:218: netlib] Error 2

for openmp, clang and gfortran I 'm using:

libomp-6.0.0-2.fc28.x86_64 : OpenMP runtime for clang
gcc-gfortran-8.0.1-0.20.fc28.x86_64 
clang-6.0.0-5.fc28.x86_64 : A C language family front-end for LLVM

Am I doing something wrong here?

@martin-frbg
Copy link
Collaborator

Not sure yet why it is failing to link against the clang openmp runtime (-lomp) in the first case. (I assume you did make clean before trying with different options ?)

Second case, make option handling in OpenBLAS is still a bit wonky as noted in #1422 - most of the time, the opposite of SOMEOPTION=1 is not SOMEOPTION=0 but just running without SOMEOPTION. (Some places only check if the option is defined or not, and not if it is set to one or zero...)

@shahrzad
Copy link
Author

Thanks for your reply. Yes I do make clean before trying each option.
The thing is if I use make CC=clang USE_OPENMP=1 NOFORTRAN=1 everything works fine

OpenBLAS build complete. (BLAS CBLAS)

  OS               ... Linux             
  Architecture     ... x86_64               
  BINARY           ... 64bit                 
  C compiler       ... CLANG  (command line : clang)
  Library Name     ... libopenblas_haswellp-r0.3.1.dev.a (Multi threaded; Max num-threads is 32)

 Use OpenMP in the multithreading. Because of ignoring OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS flags, 
 you should use OMP_NUM_THREADS environment variable to control the number of threads.

but if I don't specify it I get the error mentioned above.

@martin-frbg
Copy link
Collaborator

(1) seems the Makefiles in ctest and test both need to set CEXTRALIB=lomp in this case
(2) NOFORTRAN=0 is not yet handled correctly
#1629 should fix both these problems

@shahrzad
Copy link
Author

Everything is built properly now using make CC=clang USE_OPENMP=1

OpenBLAS build complete. (BLAS CBLAS LAPACK LAPACKE)

  OS               ... Linux             
  Architecture     ... x86_64               
  BINARY           ... 64bit                 
  C compiler       ... CLANG  (command line : clang)
  Fortran compiler ... GFORTRAN  (command line : gfortran)
  Library Name     ... libopenblas_haswellp-r0.3.1.dev.a (Multi threaded; Max num-threads is 32)

 Use OpenMP in the multithreading. Because of ignoring OPENBLAS_NUM_THREADS and GOTO_NUM_THREADS flags, 
 you should use OMP_NUM_THREADS environment variable to control the number of threads.

Thank you so much for your fast reply and fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants