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

MKL Performance on Ubuntu 10.10 64 bit

Pham_Hoai_Vu
Beginner
306 Views
Hello everyone,

I used MKL in my project. On Windows, it compiles correctly and gives some speedup, but on Ubuntu 10.10 64 bit, it doesn't compile at all. The compiling process stops at the linking stage with the following error:

undefined reference to 'mkl_blas_dgemv'

In the code, I call cblas_dgemm() function. Even when I commented this function, and the application compiles OK, but it is really slow (in respect with the speedup it gives on Windows). Besides cblas_dgemm(), I also use other function like adding, subtracting vectors....

Some more details about my apps:
1. I used the library files from MKL package for 32-bit/x86-64bit development (338 MB). Although the installer told that it doesn't support the Ubuntu 10.10, but it installed successfully.

2. My application uses boost::thread to create some threads. MKL functions are likely called from multiple threads. On linux, boost seems to utilize Posix threads.

3. The linking command is:
-Wl,--start-group $MKL_PATH/libmkl_intel_lp64.a $MKL_PATH/libmkl_intel_thread.a $MKL_PATH/libmkl_core.a -Wl,--end-group -liomp5 -lpthread

(I have tried replacing libmkl_intel_thread.a by libmkl_sequential.a but it still doesn't compile at all)

So I would like to ask:
1. Which library I have to link to get around the "undefined reference to 'mkl_blas_dgemv'" error? On windows it works well, but on Ubuntu 10.10 64 bit, it simply cannot be compiled.
2. Why does MKL slows down the application on Ubuntu 10.10 64 bit? Is this a known-issue, or I did something wrong with the application?

Any help would be greatly appreciated. I'm pretty new with MKL, so I hope that there was something wrong with my configuration...
Thanks a lot :x
0 Kudos
4 Replies
Todd_R_Intel
Employee
306 Views
Let's start with your first question.
You are using the right libraries and the link line looks good. Have you set MKL_PATH correctly (it must point to the directory containing those libraries of course). Are there any other error messages?

Finally, what version of MKL are you using?

Todd
0 Kudos
mecej4
Honored Contributor III
306 Views
A suggestion, to make it easier for others to understand the problem: please do not confuse compilation errors with linker errors. The former class of errors occur because of errors in the source code, and will result in no object file being produced and, possibly, linking will not even be attempted. Linker errors, on the other hand, are caused most often by some routines being called from your Fortran source that are not present in the files (objects and libraries) presented to the linker.

Along the same lines, I cannot make sense of your second question. Since, on Ubuntu, the linking step failed (or, in your words, "it simply cannot be compiled"), the question "Why does MKL slows down the application on Ubuntu 10.10 64 bit?" makes no sense, since it refers to the execution speed of a program that could not be produced.
0 Kudos
Pham_Hoai_Vu
Beginner
306 Views
Sorry for the misunderstanding. To make it clear, I meant:
When using cblas_dgemm, the linking step failed under Ubuntu 10.10 64 bit (while it works on Windows).
When I commented cblas_dgemm() function (I used the traditional loop to multiply the 2 matrices), the source code compiles successfully on Ubuntu, but it is slow. Besides cblas_dgemm() function, I used many other MKL functions, e.g. Sub, Add ... in may places, and I hope that they can also provide some speedup. Nonetheless, it couldn't accelarate the application.

Finally, I used MKL 10.3. I downloaded the file named "l_mkl_10.3.0.084.tgz". And I have checked the MKL_PATH many times, it points to the right directory.

Thanks

0 Kudos
mecej4
Honored Contributor III
306 Views
So far, you have not shown any code to help pinpoint the problem. It is odd that your code calls cblas_dgemm, yet you received a linker error for a reference to mkl_dgemm. It is difficult to debug code that has not been seen.

Here are two things to try.

1. On Ubuntu, repeat what you did before but add the -v flag to the compiler command, i.e, instead of icc say icc -v. Report the output.

2. Try the following toy example of calling cblas_dgemm.

[cpp]/* Test program for cblas_dgemm.
   Expected results:
   
     374.10   397.20   420.30
     695.10   738.20   781.30 
    1016.10  1079.20  1142.30 

*/
#include 
#include 
int main(int argc,char *argv[]){
CBLAS_ORDER order=CblasColMajor;
CBLAS_TRANSPOSE transA=CblasNoTrans,transB=CblasTrans;
int M=3,N=3,K=2,ldA=3,ldB=3,ldC=3; double alpha=1.0, beta=10.0;
double A[]={11.0,21.0,31.0,12.0,22.0,32.0};
double B[]={11.0,12.0,13.0,21.0,22.0,23.0};
double C[9]={0.11,0.21,0.31,0.12,0.22,0.32,0.13,0.23,0.33};
int i,j;
cblas_dgemm(order, 
            transA, 
            transB, 
            M, N, K, 
            alpha, A, ldA, 
            B, ldB, 
            beta, 
            C, ldC);
for(i=0; i
0 Kudos
Reply