Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6956 Discussions

Problem with MKL 10 update 3 and newer versions

jpeinado
Beginner
1,533 Views
Hi:

I am working in a program using LINUX (64 bits) and MATLAB R2010b, CUDA and CULA (environments to use GPUs) and MKL.

Before, when working with MKL 10 update 2, all worked well. Now, when working with last version of MKL, I have a runtime error....It seems a MKL problem:

*** libmkl_mc3.so *** failed with error : /opt/intel/composerxe-2011.1.107/mkl/lib/intel64/libmkl_mc3.so: undefined symbol: i_free
*** libmkl_def.so *** failed with error : /opt/intel/composerxe-2011.1.107/mkl/lib/intel64/libmkl_def.so: undefined symbol: i_free
MKL FATAL ERROR: Cannot load neither libmkl_mc3.so nor libmkl_def.so



I read some about this (I think it is a similar problem) here: http://software.intel.com/en-us/forums/showthread.php?t=60460

but I don't understand what must I do to solve the problem. Now, I include the following libraries:

-lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread -liomp5

What must I change? Couuld you give me a line telling me the libraries to include?

Thank you very much

jpeinado
0 Kudos
31 Replies
Gennady_F_Intel
Moderator
1,137 Views
do you mean that with 10.0 Update2 all worked well. right? and which version of mkl you use now?
0 Kudos
barragan_villanueva_
Valued Contributor I
1,137 Views
...Now, I include the following libraries:

-lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread -liomp5

Hi,

This MKL libraries are in incorrect order and not grouped :(
Please use Intel MKL Link Line Advisorfor help.
It recommends:
-L$(MKLROOT)/lib/intel64 -Wl,--start-group -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group -openmp -lpthread

0 Kudos
jpeinado
Beginner
1,137 Views
Thank you very much Victor (I didnt know the MKL Advisor). The problem with your advice, is that I use this in a MATLAB MEX command:

Usage:
MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
[objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
Usage: MEX [option1 ... optionN] sourcefile1 [... sourcefileN] [objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]

Then, I cant use options as start/end group or -openmp...I have to put the exact library (objectfile) name. Is this possible?
Thanks
jpeinado
0 Kudos
TimP
Honored Contributor III
1,137 Views
The start-group/end-group directives are taken by gnu ld. If you are compiling on a linux system, there should be no reason why you can't use them. If you don't want to use them, you can use the .so libraries (ask link advisor about dynamic libraries), or you can repeat the .a library list several times (e.g. 3 times, if you use the proper order).
0 Kudos
VipinKumar_E_Intel
1,137 Views
Please also refer the thread on start-group/end-group symbols

http://software.intel.com/en-us/forums/showthread.php?t=83330&o=a&s=lr


--Vipin
0 Kudos
jpeinado
Beginner
1,137 Views
The problem is that I am using the MATLAB MEX command. I don't know why the MEX command don't know the start-group/end group directives. Anyway, I have not experience with the link advisor. Could you please write for me the exact name and order of libraries? I apologize for given too much work but I have no idea of how to do it. By the way, MATLAB needs dynamic libraries

Thank you very much
jpeinado
0 Kudos
jpeinado
Beginner
1,137 Views
Hi again:

I learnt to use the Linker Line Advisor with MEX MATLAB compiler and now it compiles OK:
I used this line got wit the MKL Linker Line Advisor:
-L$(MKLROOT)/lib/intel64 -Wl,--start-group -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group -liomp5 -lpthread
but I have the same results when running my program:
*** libmkl_mc3.so *** failed with error : /opt/intel/composerxe-2011.1.107/mkl/lib/intel64/libmkl_mc3.so: undefined symbol: i_free
*** libmkl_def.so *** failed with error : /opt/intel/composerxe-2011.1.107/mkl/lib/intel64/libmkl_def.so: undefined symbol: i_free
MKL FATAL ERROR: Cannot load neither libmkl_mc3.so nor libmkl_def.so
*** libmkl_mc3.so *** failed with error : /opt/intel/composerxe-2011.1.107/mkl/lib/intel64/libmkl_mc3.so: undefined symbol: i_free*** libmkl_def.so *** failed with error : /opt/intel/composerxe-2011.1.107/mkl/lib/intel64/libmkl_def.so: undefined symbol: i_freeMKL FATAL ERROR: Cannot load neither libmkl_mc3.so nor libmkl_def.so
What is happening?
Thank you very much
jpeinado
0 Kudos
AndrewC
New Contributor III
1,137 Views
Hi,
Your problems with Matlab can be due to conflicts with Matlabs MKL DLL/.so ( Matlab uses MKL but an older version). This caused me a lot of grief!

But...you can avoid all these problems by building a "custom" MKL DLL using the tools/builder makefiles (found in the MKL area). It is really easy and you end up with one DLL/.so to link against. And there is no conflict with the Matlab MKL DLL's/.so as your dll has a different name....

This also helps a lot when building a MKL extension to Python as well.



Andrew
0 Kudos
jpeinado
Beginner
1,137 Views
Hi:

The strange thing is that MKL 10 Update 2 works OK, but update 3 does not work. Could you explain me how to do that please?
By theway. Is there any way to know the MKL version of my MATLAB copy
Thank you very much
jpeinado

0 Kudos
AndrewC
New Contributor III
1,137 Views
I can't explain why changes in MKL upset Matlab. But I do know that creating a custom DLL will probably solve your problem.
Creating a custom DLL is easier than creating a MEX file!

cd /opt/intel/composerxe-2011.3.174/mkl/tools/builder

make sointel64 export=lapack_list name=libMyMKL

Then link your MEX file against libMyMKL.so
0 Kudos
jpeinado
Beginner
1,137 Views
Hi:

I did what you told me and almost work....but

make sointel64 export=blas_list name=libMyblas


The problem now is:

dgeidreplpa_cu.o: In function `mexFunction':
tmpxft_000045b0_00000000-1_dgeidreplpa_cu.cudafe1.cpp:(.text+0x142e): undefined reference to `idamax'
tmpxft_000045b0_00000000-1_dgeidreplpa_cu.cudafe1.cpp:(.text+0x150d): undefined reference to `idamax'
collect2: ld returned 1 exit status

mex: link of ' "dgeidreplpa_cu.mexa64"' failed.

nm libMyblas.so |grep "idamax"
U idamax_

The "typical" problem of "_"

How can I solve this?

Thank you

jpeinado
0 Kudos
TimP
Honored Contributor III
1,137 Views

Well, yes, if you wish to call idamax directly from C with Fortran style parameters, you must spell it idamax_
I suppose there is a cblas wrapper as well.
0 Kudos
AndrewC
New Contributor III
1,137 Views
Make a copy of blas_list ( call it my_blas_list) and add one line with "idamax" to the end of my_blas_list

then do...

make sointel64 export=my_blas_list name=libMyblas

See if that works...

0 Kudos
AndrewC
New Contributor III
1,137 Views
Yup good point by Tim, just concatenate blas_list and cblas_list together into my_blas_list and call cblas_idamax instead.
0 Kudos
jpeinado
Beginner
1,137 Views
There is a cblas_wrapper but the function it is called cblas_idamax....I dont understand this, because it works with the original MKL . I would try it the idea of creating my own blas list. I will do this on Monday, and inform you as soon as possible.
Thank you very much
jpeinado
0 Kudos
jpeinado
Beginner
1,137 Views
I did this:
Make a copy of blas_list ( call it my_blas_list) and add one line with "idamax" to the end of my_blas_list

then do...

make sointel64 export=my_blas_list name=libMyblas

See if that works...
But it does not work
dgeidreplpa_cu.o: In function `mexFunction':
tmpxft_00005d80_00000000-1_dgeidreplpa_cu.cudafe1.cpp:(.text+0x142e): undefined reference to `idamax'
tmpxft_00005d80_00000000-1_dgeidreplpa_cu.cudafe1.cpp:(.text+0x150d): undefined reference to `idamax'
collect2: ld returned 1 exit status
mex: link of ' "dgeidreplpa_cu.mexa64"' failed.
dgeidreplpa_cu.o: In function `mexFunction':tmpxft_00005d80_00000000-1_dgeidreplpa_cu.cudafe1.cpp:(.text+0x142e): undefined reference to `idamax'tmpxft_00005d80_00000000-1_dgeidreplpa_cu.cudafe1.cpp:(.text+0x150d): undefined reference to `idamax'collect2: ld returned 1 exit status
mex: link of ' "dgeidreplpa_cu.mexa64"' failed.
If I do nm |libMyblas.so the function is found.....
I dont understand why the original MKL library finds "idamax" but muy built library only find "idamax_"
0 Kudos
AndrewC
New Contributor III
1,137 Views
I think you need to double check you are linking against the correct libMyblas.so ( the one created with the extra idamax), as it works for me.

Anyway, don't get hung up on this. I assume you have the source code to the MEX , change reference to idamax to idamax_ and move on.
0 Kudos
jpeinado
Beginner
1,137 Views
Hi:
Thank you very much for your fast answer. Later, I am going to go to my University Office (today On saturday) because I am very interested in solve this :-)
As you told me, I will try again to link against my correct libMyBlas.so and later, I will change my MEX source code (you are right, I have it) and will change idamax to idamax_
Thank you again for your patience with me.
jpeinado
0 Kudos
AndrewC
New Contributor III
1,137 Views
Just to be clear, your mex command line will be something like ( I forget exact mex syntax on Linux). You do not include any other MKL libraries.

mex mymexfile.c -I -lMyBlas
0 Kudos
jpeinado
Beginner
1,041 Views

Hi again:

I tested your two ideas and they did not work

1) I got my own myblas_list and added a line with the "idamax" line. Also I generated libMyBlas.so file correctly. It did not worked

dgeidreplpa_cu.o: In function `mexFunction':

tmpxft_000061b6_00000000-1_dgeidreplpa_cu.cudafe1.cpp:(.text+0x142e): undefined reference to `idamax'

tmpxft_000061b6_00000000-1_dgeidreplpa_cu.cudafe1.cpp:(.text+0x150d): undefined reference to `idamax'

collect2: ld returned 1 exit status

mex: link of ' "dgeidreplpa_cu.mexa64"' failed.

dgeidreplpa_cu.o: In function `mexFunction':tmpxft_000061b6_000000001_dgeidreplpa_cu.cudafe1.cpp:(.text+0x142e): undefined reference to `idamax'tmpxft_000061b6_00000000-1_dgeidreplpa_cu.cudafe1.cpp:(.text+0x150d): undefined reference to `idamax'collect2: ld returned 1 exit status

mex: link of ' "dgeidreplpa_cu.mexa64"' failed.

2) Then in the mex source (C++) file I changed idamax with idamax_ :

dgeidreplpa_cu.cu(406): error: identifier "idamax_" is undefined

1 error detected in the compilation of "/tmp/tmpxft_00006434_00000000-4_dgeidreplpa_cu.cpp1.ii".

There are some important questions here...The compilation steps are 2:

- A Compile step with nvcc (a g++ wrapper to work with CUDA files from NVIDIA)

- A link step using MEX

I give the file to you:

!nvcc -c dgeidreplpa_cu.cu -Xcompiler -fPIC -I/usr/local/cula/include -I/usr/local/cuda/include -I/usr/local/MATLAB/R2010b/extern/include -I/opt/intel/composerxe-2011.1.107/mkl/include

!mex dgeidreplpa_cu.o cudaDMatrixPlusIdentity.o -cxx -L/usr/local/cula/lib64-lcula -lcublas -lcudart -lpthread libMyblas.so

It is very strange. All this worked with the former MKL 10 update 2

Again thank you very much

jpeinado


0 Kudos
Reply