Community
cancel
Showing results for 
Search instead for 
Did you mean: 
pwschuck
Beginner
326 Views

Problems linking MKL

Hi,

I'm trying to compile a shared library with intel icc. The code calls fftw though mkl and uses openMP. Under normal operation several c-objects are bundled together and linked to a ".a" static library. The suggested link flags from the documentation are "-mkl -lm." When example executables are linked to this library the codes execute and perform as advertised.

export INTEL=/software/intel/
source $INTEL/compilers_and_libraries/linux/bin/compilervars.sh intel64

is executed in bash and LD_LIBRARY_PATH seems properly set.

Now I am trying to bundle this code into a shared library (.so) that's called from another language through c-wrappers. However, I have not been able to get the shared library to work with just linker options.

What I've tried:

(1) Using Suggested library flags: "-mkl -lm"

Error:

INTEL MKL ERROR: /software/intel/compilers_and_libraries_2019.4.243/linux/mkl/lib/intel64_lin/libmkl_avx512.so: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8.
Intel MKL FATAL ERROR: Cannot load libmkl_avx512.so or libmkl_def.so.

(2) Using Single Dynamic Library with suggested flags from Intel® Math Kernel Library Link Line Advisor https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor ; "-lmkl_rt -lpthread -lm -ldl"

Error:
INTEL MKL ERROR: /software/intel/compilers_and_libraries_2019.4.243/linux/mkl/lib/intel64_lin/libmkl_avx512.so: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8.
Intel MKL FATAL ERROR: Cannot load libmkl_avx512.so or libmkl_def.so.

(3) Using static linking with suggested flags from Intel® Math Kernel Library Link Line Advisor      /32bit integer/openMP threading (libiomp5)/ : "-Wl,--start-group '+MKLROOT+'/lib/intel64/libmkl_intel_lp64.a '+MKLROOT+'/lib/intel64/libmkl_intel_thread.a '+MKLROOT+'/lib/intel64/libmkl_core.a -Wl,--end-group -liomp5 -lpthread -lm -ldl "

Error:
INTEL MKL ERROR: /software/intel/compilers_and_libraries_2019.4.243/linux/mkl/lib/intel64_lin/libmkl_avx512.so: undefined symbol: mkl_sparse_optimize_bsr_trsm_i8.
Intel MKL FATAL ERROR: Cannot load libmkl_avx512.so or libmkl_def.so.

Now I have gotten the shared object to work by explicitly setting LD_PRELOAD:

LIBS=${MKLROOT}/lib/intel64_lin/
export LD_PRELOAD=${LIBS}/libmkl_def.so:${LIBS}/libmkl_avx512.so:${LIBS}/libmkl_core.so:${LIBS}/libmkl_intel_lp64.so:${LIBS}/libmkl_intel_thread.so:/software/intel/compilers_and_libraries_2019.4.227/linux/compiler/lib/intel64_lin/libiomp5.so

However this solution is as awkward, particularly for a code that I'd like to offer up opensource. Is there a way to get EVERYTHING I need in the shared library on the link line without getting the kitchen sink in addition or having to explicitly set LD_PRELOAD?

Thanks,

-- Pete

Tags (1)
0 Kudos
0 Replies
Reply