Problem with MKL 10 update 3 and newer versions

Problem with MKL 10 update 3 and newer versions

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

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

do you mean that with 10.0 Update2 all worked well. right? and which version of mkl you use now?

Quoting jpeinado@gmail.com...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

Thanks,
-- Victor

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?Thanksjpeinado

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

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

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 muchjpeinado

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 -lpthreadbut 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_freeMKL 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.soWhat is happening?Thank you very muchjpeinado

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

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 copyThank you very muchjpeinado

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

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

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.

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

Yup good point by Tim, just concatenate blas_list and cblas_list together into my_blas_list and call cblas_idamax instead.

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 muchjpeinado

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 workdgeidreplpa_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_"

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.

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

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

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

Just put in the mex C++ file...before the call to idamax_
extern "C" int idamax_(int n, double *x,int incx);

And on your link linereplace libMyBlas.so by-L. -lMyblas

Hi:

I did but using extern "C" int idamax_(int *n, double *x,int *incx);

Anyway

dgeidreplpa_cu.o: In function `mexFunction':

tmpxft_00006849_000000001_dgeidreplpa_cu.cudafe1.cpp:(.text+0x142e): undefined reference to `idamax_'

tmpxft_00006849_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_00006849_00000000-1_dgeidreplpa_cu.cudafe1.cpp:(.text+0x142e): undefined reference to `idamax_'tmpxft_00006849_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.

It seems that the linker dont see the routines contained in libMyblas.so but I don't know why

Thanks

jpeinado

Hi again:

I am sure that the problem is that routines contained in libMyblas.so (MKL) generated following your instructions are not found. I will try to explain this.

To test what is happening, I did the following:

- I downloaded the "idamax.f" file from the Netlib repository

- I compiled it and converted in a shared library.

- Then I compiled and linked all, using that shared library

This worked OK.

Anyway I would like to use the MKL. I have one doubt...When I have libMyblas.so (MKL), where are the original libraries? May I use any path to tell where are that libraries? Could this be the problem?

Thank you very much

jpeinado

Oops, I made as mistake in what I told you earlier... the command to create the custom DLL should bemake libintel64 export=my_blas_list name=libMyblasIf you create it that way, you should be good to go. The critical parameter islibintel64 which means "make a library including all the functions"

When you install the MKL which comes with recent Intel compilers, if you accept the installation path which you chose for the compilers, sourceing the compilervars script will set up LD_LIBRARY_PATH for MKL dynamic libraries. You could also set LD_LIBRARY_PATH specifically to where you installed MKL. If you chose the default,

find /opt/intel -name libmkl_core.so

should show you where such libraries are. There should also be an mklvars script in your MKL installation, regardless of whether you installed a compiler.

Hi Again:

OK.

Thank you very much....I will test it on Monday :-) Tomorrow, the University is closed....

Thank you very much for your answer

About the paths...I think (I must test it) they are correctly installed

Anyway, thank you very much

jpeinado

Hi vasci_intel:

1) I redid the library as you told me and also generated my_blas_list (adding idamax without "_") and it worked OK...Than you very much!!!

2) I studied the make libintel64 command and the exact command is

make libintel64 export=my_blas_list interface=ilp64 name=my_blas
Creates my_blas.so for processors using the Intel 64 architecture.
Function list is taken from the file my_blas_list.
The parallel Intel MKL supporting ilp64 programming is used to build my_blas.so.

The question is, Must I use interface=ilp64 ? What is this?

3) Is there any list to use the functions without "_" with and without adding them manually?

Thank you very much for your help

jpeinado

Hi again:Anyone can answer to my questions:Must I use interface=ilp64 ? What is this?

Is there any list to use the functions without "_" with and without adding them manually?

Thank you very much for your helpjpeinado

Hi,

The short answer is "read the documentation" - there is a lot of information in the MKL docs folder. You should be reading that before posting to these forum.

Quick answer: ILP64 is the MKL interface using 64-bit "integers" not the default "32-bit" int type. Needed when working with huge datasets. You should not need to use it.

You do not, and never needed to add "_" manually as long as you linked against the correct library.

include "mkl_blas.h" in you C++ header file, link against the library, and you are done.

Again, please read the docs. People will not answer pleas for help if it does not appear you have made an effort to help yourself.

Hi again:

Thank you very much for your answer.

But the problem is that INTEL changed something in MKL update 3 and newer. Before, I linked with MKL and MATLAB without problems. Yes, I know, it is a strange thing.....

In fact, you can see (several posts before) that you advised me about adding the "_". Later you told me redoing the library (first and incorrect way, and later a correct way).

Later to use the call idamax, to add (at last line) idamax with ( and later without the _). This is because the blas_list file (used to rebuild libraries) have all the calls with "_". I asked about the same file (blas_list) without the "_"

I apologize you for giving to much work to you (you helped to me much redoing the libraries), but you must understand that before INTEL make some changes, all worked OK.....

I am not sure if the documentation talks about this method of rebuilding the libraries, when someone have problems. I am sure that I solved my problem due to your great help

Again, thank you very much

jpeinado

Leave a Comment

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