hypre
hypre copied to clipboard
Compilation with OpenMP without MPI fails with clang
When compiling with cland and OpenMP bu without MPI, one gets a link error building libHYPRE.so
Here it is :
FC=/opt/AMD/aocc-compiler-3.0.0/bin/flang CC=/opt/AMD/aocc-compiler-3.0.0/bin/clang
configure --without-MPI --with-openmp --enable-shared
the link for libHYPRE.so fails on
<<
ld.lld: error: undefined symbol: omp_get_max_threads
referenced by threading.c /tmp/cessenat/spack-stage/spack-stage-hypre-develop-gfxxuas2re4iiaa2bb3qtgswpgphg5ex/spack-src/src/utilities/threading.o:(hypre_NumThreads)
ld.lld: error: undefined symbol: omp_get_num_threads
referenced by threading.c /tmp/cessenat/spack-stage/spack-stage-hypre-develop-gfxxuas2re4iiaa2bb3qtgswpgphg5ex/spack-src/src/utilities/threading.o:(hypre_NumActiveThreads) ... bla bla bla ...
since the link failed to add -lomp or -lompstub. When compiling --with-MPI it succeeds.
I'm not that keen at configure scripts to alter it myself so I can only report the incident. To test rapidly (using AMD aocc compiler): spack install --keep-stage hypre@develop+openmp~mpi %aocc ^openblas threads=openmp %aocc or (on raspberry-pi, or whetever): spack install hypre@develop+openmp~mpi %clang ^openblas threads=openmp
Thanks,
Olivier Cessenat
@cessenat Thanks for reporting this. Hypre should have -fopenmp
in the link line. I haven't seen -lomp
before. Is it clang
specific?
Hello @liruipeng I do not master the subject but just observed that nm -D /path/libomp.so or libstub.so provided the OpenMP functions (T omp_...), for instance, if I run configure with --with-blas-libs="openblas omp", then the link was OK. Does it make sense ?
Hello @liruipeng I do not master the subject but just observed that nm -D /path/libomp.so or libstub.so provided the OpenMP functions (T omp_...), for instance, if I run configure with --with-blas-libs="openblas omp", then the link was OK. Does it make sense ?
@cessenat Do you know whether it is openblas (suppose it's a threaded version) that needs libomp
? Anyways, you fix makes sense to me. We need to add -lomp
in the linking somehow.
The problem comes from Hypre's direct call to OpenMP functions, whether openblas is a threaded version or not, openblas being compiled with aocc or gcc, whether we use openblas or Intel MKL. It also happens with clang on Rasp Pi Ubuntu 20.4. I also found out that linking with -fopenmp works with aocc. Adding -fopenmp does not work with clang that complains it cannot find -lomp : adding -lgomp instead (the OpenMP from gcc) works. This might be due to the fact my flang does not know about OpenMP. I hope it helps.