Forum Jump

Select Group :
Select Forum :
Sorted By :
Sort Order :
From The :
 
Thread Tools  Search this thread 
jasperjones
Total Points:
75
Status Points:
25
Green Belt
June 29, 2009 2:37 PM PDT
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
Andrey Nikolaev (Intel)
Total Points:
1,025
Status Points:
525
Brown Belt
June 30, 2009 2:58 AM PDT
Rate
 
#1
Hello, can you please clarify how you build/link your application? Thanks, Andrey


Ying H (Intel)
Total Points:
4,882
Status Points:
4,382
Brown Belt
June 30, 2009 3:28 AM PDT
Rate
 
#2

Hi Jasperjones, 

Your assumption is right. The libmkl_VML_* library include both VML and VSL function (no libmkl_VSL * library) . So when you call VSL function, the library was needed.  

We introduced the symbol: mkl_serv_mkl_malloc in recent libmkl_VML library in MKL 10.2 version, that may why the error arise when you upgade to 10.2. But the symbol were defined in libmkl_core library

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

And in general, we always use the mkl libraries together. 
for example, 
$  ifort vslTest_main.F90 vslTest.F90 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 

Thus, the symbol would be resolved automatically. 
So could you please check where your application or the matlab link the MKL library and in which way?  The key is to link to mkl_core library at the same time. 

Best Regards,
Ying  



jasperjones
Total Points:
75
Status Points:
25
Green Belt
June 30, 2009 12:33 PM PDT
Rate
 
#3
@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.)


Andrey Nikolaev (Intel)
Total Points:
1,025
Status Points:
525
Brown Belt
June 30, 2009 11:54 PM PDT
Rate
 
#4 Reply to #3
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 which is a useful tool to determine MKL link line for your specific environment.

Thanks,
Andrey


jasperjones
Total Points:
75
Status Points:
25
Green Belt
July 2, 2009 11:20 AM PDT
Rate
 
#5 Reply to #4
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 which is a useful tool to determine MKL link line for 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.)




jasperjones
Total Points:
75
Status Points:
25
Green Belt
July 2, 2009 4:24 PM PDT
Rate
 
#6 Reply to #5
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)
>>



Ying H (Intel)
Total Points:
4,882
Status Points:
4,382
Brown Belt
July 2, 2009 8:48 PM PDT
Rate
 
#7 Reply to #6

Hello Jasperjones, 

It seems you are facing the openmp thread library (libiomp5 and libguide)  conflict issue as mentioned in
<http://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-for-windows-using-intel-mkl-in-matlab-executable-mex-files/>

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).


and some of Intel Compiler KB and Intel IPP KB also talking about these at
<http://software.intel.com/en-us/articles/opm-abort-initializing-libguide40dll/>
http://software.intel.com/en-us/articles/omp-error-15-initia.....ed/
<http://software.intel.com/en-us/articles/omp-error-15-initia.....ed/>

In summary, there are two version threading libraries (libguide and libiomp5) used in your run environment. 
The libguide may come from Matlab, it seems use MKL 9.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 link back to libgude.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





Intel Software Network Forums Statistics

8286 users have contributed to 31231 threads and 99107 posts to date.
In the past 24 hours, we have 7 new thread(s) 31 new posts(s), and 43 new user(s).

In the past 3 days, the most popular thread for everyone has been comparison cilk++, openmp, pthreads first results The most posts were made to comparison cilk++, openmp, pthreads first results The post with the most views is Very amusing...  Escalated as

Please welcome our newest member titanius.anglesmith