After update to MKL 10.2, code chrashes with undefined symbol: mkl_serv_mkl_malloc

After update to MKL 10.2, code chrashes with undefined symbol: mkl_serv_mkl_malloc

Hi,

I recently updated to the Intel Professional 11.1.038 compiler (Linux, Intel 64). I have some code that ran under 11.0.84 but now crashes.

The error is: /usr/local/matlab77/bin/glnxa64/MATLAB: symbol lookup error: /opt/intel/Compiler/11.1/038/mkl/lib/em64t/libmkl_vml_mc3.so: undefined symbol: mkl_serv_mkl_malloc

I don't have any direct VML calls in my code, therefore my assumption at this point is that the error stems from my usage of the VSL library. (Am I wrong here? Is it possible that the error stems from my usage of BLAS/LAPACK routines?)

My assumption at this point is that the error is related to the subroutine below (this is the only routine in the project which uses VSL). This subroutine is called out of a Fortran mex file. I'm not a user with particularly high technological knowledge, so any comments would be much appreciated.

Thanks in advance!

include 'mkl_vsl.fi'
include "errcheck.inc"

subroutine normrandintel(entry,var,n,rands)

USE MKL_VSL_TYPE
USE MKL_VSL

implicit none

real(8), intent(in) :: var
integer(8), intent(in) :: n
real(8), dimension(n), intent(out) :: rands
integer(4), intent(in) :: entry
integer(4) :: gn

integer(4) :: errcode

real(8) :: mu
integer :: brng,method,seed

TYPE (VSL_STREAM_STATE), save :: stream

brng=VSL_BRNG_MT19937 ! this is Mersenne-Twister as in Matlab
method=VSL_METHOD_DGAUSSIAN_BOXMULLER ! use Box-Muller transform
seed=1758101503

mu=0.0d0

gn=n

! ***** Initialize *****
if(entry==1) then
errcode=vslnewstream( stream, brng, seed )
call CheckVslError(errcode)
endif

! ***** Call RNG *****
errcode=vdrnggaussian( method, stream, gn, rands, mu, var)
call CheckVslError(errcode)

if(entry==3) then
! ***** Deinitialize *****
errcode=vsldeletestream( stream )
call CheckVslError(errcode)
endif

end subroutine normrandintel

8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hello, can you please clarify how you build/link your application? Thanks, Andrey

Hi Jasperjones,

Your assumption is right. The libmkl_VML_* libraryinclude bothVML andVSLfunction (no libmkl_VSL * library) . So when you call VSL function, the librarywas needed.

We introduced the symbol: mkl_serv_mkl_malloc inrecent libmkl_VML library in MKL 10.2 version,that may whythe errorarisewhen youupgade to 10.2. But the symbolwere defined in libmkl_core library

$ nm libmkl_core.so | grep mkl_serv_mkl_malloc
0000000000026e76 T mkl_serv_mkl_malloc

And in general, wealways usethe mkl libraries together.
for example,
$ifort vslTest_main.F90 vslTest.F90 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5

Thus, the symbolwould be resolved automatically.
Socould you please check where your application or the matlab link the MKL library and in which way? The key istolink to mkl_core libraryat the same time.

Best Regards,
Ying

@Andrey: Please see the following makefile below (I only provide the relevant portion). Needless to say, I source iccvars.sh (with argument intel64) as required in the documentation, so the declarations of CPATH and MKLROOT should be obvious.

SHELL = /bin/bash
MATHOME = /usr/local/matlab77
FC = ifort
FFLAGS = -O3 -xHost -openmp -warn -shared -fexceptions -fPIC
-fno-omit-frame-pointer -DMX_COMPAT_32
INCL = -I${CPATH} -I${MATHOME}/extern/include
LIBS = -L${MKLROOT}/lib/em64t
${INCL} -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lguide -lpthread -lm
EXT = mexa64
OBJ = normrandintel.o # and lots of other stuff here...

mymatlabmexfile.${EXT}: ${OBJ}
${FC} ${FFLAGS} mymatlabmexfile.F90 ${OBJ} -o $@ ${LIBS}

normrandintel.o:
${FC} ${FFLAGS} -c normrandintel.F90 ${LIBS}

# lots of other dependencies here...

@Ying: Thanks for your clarifications, this is useful to know. Needless to say, when I do the nm command you give on my machine the symbol is listed. Please see above for the building/linking.

Finally, note that I have openmp in the FFLAGS since part of the code uses OpenMP directives. I also tried linking against libiomp5 but Matlab doesn't seem to like it. (I since reverted back to 11.0.84, I think at some point when using MKL 10.2 I also experimented with the additional flag to ifort "-openmp-lib legacy" without success.)

Can you please modify LIBs in your makefile as shown below and let us know how it works?

LIBS = -L${MKLROOT}/lib/em64t
${INCL} -Wl,--start-group -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group -openmp -lpthread -lm

Also, the link http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/ contains Link Line Advisor whichis auseful tool to determine MKL link linefor your specific environment.

Thanks,
Andrey

Quoting - Andrey Nikolaev (Intel)
Can you please modify LIBs in your makefile as shown below and let us know how it works?

LIBS = -L${MKLROOT}/lib/em64t
${INCL} -Wl,--start-group -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group -openmp -lpthread -lm

Also, the link http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/ contains Link Line Advisor whichis auseful tool to determine MKL link linefor your specific environment.

Thanks,
Andrey

Andrey, thanks again for offering your help. After making the suggested modification, the mex-file won't run. The new error message is:
OMP: Error #15: Initializing libiomp5.so, but found libguide.so already initialized.
OMP: Hint: This may cause performance degradation and correctness issues. Set environment variable KMP_DUPLICATE_LIB_OK=TRUE to ignore this problem and force the program to continue anyway. Please note that the use of KMP_DUPLICATE_LIB_OK is unsupported and using it may cause undefined behavior. For more information, please see http://www.intel.com/software/products/support/.
Aborted

(Matlab session aborts.)

Quoting - jasperjones

Andrey, thanks again for offering your help. After making the suggested modification, the mex-file won't run. The new error message is:
OMP: Error #15: Initializing libiomp5.so, but found libguide.so already initialized.
OMP: Hint: This may cause performance degradation and correctness issues. Set environment variable KMP_DUPLICATE_LIB_OK=TRUE to ignore this problem and force the program to continue anyway. Please note that the use of KMP_DUPLICATE_LIB_OK is unsupported and using it may cause undefined behavior. For more information, please see http://www.intel.com/software/products/support/.
Aborted

(Matlab session aborts.)

Andrey, while further suggestions from you would most certainly be appreciated, I feel I have to ask my IT department to take this to Matlab support. It seems Matlab at startup messes with LD_LIBRARY_PATH, so that the output from "ldd mymexfile.mexa64" from the command line (outside Matlab) is quite different from the output of "!ldd mymexfile.mexa64" from within Matlab.

From the command line:
me@linux:~/workspace/matlab> ldd mymatlabmexfile.mexa64
linux-vdso.so.1 => (0x00007fff627fd000)
libmkl_intel_lp64.so => /opt/intel/Compiler/11.1/038/mkl/lib/em64t/libmkl_intel_lp64.so (0x00007f2e58aa9000)
libmkl_intel_thread.so => /opt/intel/Compiler/11.1/038/mkl/lib/em64t/libmkl_intel_thread.so (0x00007f2e57bf8000)
libmkl_core.so => /opt/intel/Compiler/11.1/038/mkl/lib/em64t/libmkl_core.so (0x00007f2e579cc000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2e5778a000)
libm.so.6 => /lib64/libm.so.6 (0x00007f2e57533000)
libifport.so.5 => /opt/intel/Compiler/11.1/038/lib/intel64/libifport.so.5 (0x00007f2e573fa000)
libifcoremt.so.5 => /opt/intel/Compiler/11.1/038/lib/intel64/libifcoremt.so.5 (0x00007f2e57157000)
libimf.so => /opt/intel/Compiler/11.1/038/lib/intel64/libimf.so (0x00007f2e56e04000)
libsvml.so => /opt/intel/Compiler/11.1/038/lib/intel64/libsvml.so (0x00007f2e56bed000)
libiomp5.so => /opt/intel/Compiler/11.1/038/lib/intel64/libiomp5.so (0x00007f2e56a59000)
libintlc.so.5 => /opt/intel/Compiler/11.1/038/lib/intel64/libintlc.so.5 (0x00007f2e5691b000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2e565c2000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f2e563aa000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f2e561a5000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2e5a6cd000)

From within Matlab:
>> !ldd mymatlabmexfile.mexa64
linux-vdso.so.1 => (0x00007fff08ffd000)
libmkl_intel_lp64.so => /opt/intel/Compiler/11.1/038/mkl/lib/em64t/libmkl_intel_lp64.so (0x00007f94ff217000)
libmkl_intel_thread.so => /opt/intel/Compiler/11.1/038/mkl/lib/em64t/libmkl_intel_thread.so (0x00007f94fe366000)
libmkl_core.so => /opt/intel/Compiler/11.1/038/mkl/lib/em64t/libmkl_core.so (0x00007f94fe13a000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f94fdef8000)
libm.so.6 => /lib64/libm.so.6 (0x00007f94fdca1000)
libifport.so.5 => /usr/local/matlab77/sys/os/glnxa64/libifport.so.5 (0x00007f94fdb6a000)
libifcoremt.so.5 => /opt/intel/Compiler/11.1/038/lib/intel64/libifcoremt.so.5 (0x00007f94fd8c7000)
libimf.so => /usr/local/matlab77/sys/os/glnxa64/libimf.so (0x00007f94fd550000)
libsvml.so => /usr/local/matlab77/sys/os/glnxa64/libsvml.so (0x00007f94fd40d000)
libiomp5.so => /opt/intel/Compiler/11.1/038/lib/intel64/libiomp5.so (0x00007f94fd279000)
libintlc.so.5 => /opt/intel/Compiler/11.1/038/lib/intel64/libintlc.so.5 (0x00007f94fd13b000)
libc.so.6 => /lib64/libc.so.6 (0x00007f94fcde2000)
libgcc_s.so.1 => /usr/local/matlab77/sys/os/glnxa64/libgcc_s.so.1 (0x00007f94fccd5000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f94fcad0000)
/lib64/ld-linux-x86-64.so.2 (0x00007f9500e3b000)
libirc.so => /usr/local/matlab77/sys/os/glnxa64/libirc.so (0x00007f94fc991000)
>>

Hello Jasperjones,

It seems you arefacingthe openmpthread library (libiomp5 and libguide) conflict issue as mentioned in
<">http://software.intel.com/en-us/articles/intel-math-kernel-library-intel...

This occurs when the threading library used by the mex file is conflicting with the threading library used by MATLAB. To resolve the problem, link the mex file to the dynamic threading library, libiomp5 (we recomment use this one since 10.x).

andsome of Intel Compiler KB and Intel IPP KB also talkingabout these at
<">http://software.intel.com/en-us/articles/opm-abort-initializing-libguide...
>" href="http://software.intel.com/en-us/articles/omp-error-15-initializing-libgu..." target="_blank">http://software.intel.com/en-us/articles/omp-error-15-initia.....ed/
<>" href="http://software.intel.com/en-us/articles/omp-error-15-initializing-libgu..." target="_blank">http://software.intel.com/en-us/articles/omp-error-15-initia.....ed/>

Insummary, there are two version threading libraries(libguide and libiomp5)used in your run environment.
The libguide may come from Matlab, it seems use MKL9.x,which use libguide.so by default.
And your mex file may call libiomp5 by default. (-openmp option trigger it).

SO you may either find where Matab use the libguide.so and update it to libiomp5
or let your mex linkback tolibgude.so, for example,build your mex file with
LIBS = -L${MKLROOT}/lib/em64t
${INCL} -Wl,--start-group -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group -openmp -openmp-lib legacy -lpthread -lm
( You mentioned you have tried this, is there any error message?).

Best Wishes,
Ying

Leave a Comment

Please sign in to add a comment. Not a member? Join today