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

How to let Matlab use Lapack of MKL8? ACML3.1 has successed.

p4top
Beginner
825 Views
Matlab7 can use blas-lib of MKL8, but not use lapack-lib of MKL8!

MKL8 can be used in matlab7, but matlab only use blas-lib, and do not use lapack-lib.

Matlab6.5 can use MKL(both blas and lapack lib), by copying mkl_P4.dll to atlas_P4.dll and copying mkl_lapack64.dll to lapack.dll. A easy way? But it is so great! So fast!

But matlab7 begins to support single precision floating-point data, so we can not copy mkl_lapack64.dll to lapack.dll, because mkl_lapack64.dll lack of cgesvd,....
Of course, we can not copy mkl_lapack32.dll to lapack.dll, because mkl_lapack32.dll lack of zgesvd,....

How to build a new lapack.dll from MKL which can run correctly?
I have try it, but always failed.

It often shows:
Errors: _kmp_openmp_thread... be modified...

Even when I use C-mex to call lapack functions of MKL, these errors often ocurr.
Please help me.
Thank you very much!

------------------------------------------------------------
"I have build new lapack.dll for matlab6.5 from ACML3.1(ICC Version) successfully. But it is unfair for Intel CPU to run at AMCL, so we need the new lapack.dll from MKL8, which can inflate the great floating-point performance of Intel CPU."
0 Kudos
7 Replies
TimP
Honored Contributor III
825 Views
Could you post more to the point? What compiler are you using, what is your link command, and what error messages?
If you require functions from both libmkl_lapack32.so and libmkl_lapack64.so, then you should specify both in your link command.
Saying that you have a setup where it is easy to use ACML tells little, except that you probably aren't using ifort, and that could make it difficult to use lapack.
0 Kudos
p4top
Beginner
825 Views
The problem seems caused by linking with libguide.lib or libguide40.lib. Can I rename libguide40.lib to libguide.lib?

Should the environment variable KMP_DUPLICATE_LIB_OK be set?
After,
SET KMP_DUPLICATE_LIB_OK=TRUE

It seems the problem is resolved.
Let's roll it! LAPACK of MKL8 is too fast!
For example:
For A is a 256X256 complex random matrix, [U,S,V]=svd(A) only spends 0.xx Seconds? Surprising!

But Matlab7 (without MKL LAPACK) need 2 Seconds at least...

MKL8 is so powerful?!
0 Kudos
p4top
Beginner
825 Views
Thank you.
It is for matlab(win32).

For building the lapack.dll, I do not use the compiler, but just use the masm8's lib.exe/link.exe...

First step, I extract the dbdsdc.obj/.../zupmtr.obj from MKL_LAPACK.LIB(lapack static lib) by lib.exe.

Second step, I build these .obj into lapack.dll by link.exe.

I can build the lapack.dll successfully, but it can't run correctly.

But the problem seems resolved, after SET KMP_DUPLICATE_LIB_OK=TRUE.

(I compile C-mex codes under matlab with ICC9.0 or MS C-Compiler8.0)
0 Kudos
p4top
Beginner
825 Views
Now, we have get a prefect patch (for Intel) of Matlab -- both Intel's blas and lapack lib.
Too fast...
atlas_P4.dll(MKL8 Version)--from mkl_p4.dll and lapack.dll(MKL8 Version) from mkl_lapack.lib
0 Kudos
p4top
Beginner
825 Views
Only for Matlab6.5, not for Matlab7! This demo patch do not support the 32-bit floating-point.
If you have mkl8, matlab6.5 and this demo patch, you can enable the MKL LAPACK LIB by:
0. Close matlab
1. find and goto ..MATLABinwin32 directory.
2. Bak the lapack.dll for recovery, then replace it with this patch file.
3. You have to copy all relative dll files into ..MATLABinwin32 directory. (such as all mkl*.dll, libguide40.dll, ect on...)
4. SET KMP_DUPLICATE_LIB_OK=TRUE
5. Reopen matlab.
0 Kudos
p4top
Beginner
825 Views
This patch support some 32-bit floating-point functions, but some miss maybe exist.
Matlab7 maybe can use this patch.
0 Kudos
p4top
Beginner
825 Views
Copy below DLL files of MKL into ..matlabinwin32 directory.
libguide40.dll
mkl_def.dll
mkl_ias.dll
mkl_lapack32.dll
mkl_lapack64.dll
mkl_p3.dll
mkl_p4.dll
mkl_p4p.dll

Find and open matlab.bat in ..matlabin directory.
Edit matlab.bat, add SET KMP_DUPLICATE_LIB_OK=TRUE into the first line of matlab.bat.
For example:
matlab.bat
SET KMP_DUPLICATE_LIB_OK=TRUE
@echo off
................
0 Kudos
Reply