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

MKL sgemm executed serial

Bjoern_B_
Beginner
642 Views

Hi people,

I am struggling with the threading of SGEMM in MKL called from C++. I am working on a rather big software that is parallelized with OpenMP. In one of the functions, I first set up matrices A (14000,1300)  and B (1300,14000) within an OpenMP loop, and then want to calculate the product.

#pragma openmp parallel for

for (.....){ fill A,B }

C=prod(A,B);

prod() is supposed to call SGEMM. I also tried cblas_sgemm directly. In both cases, SGEMM is executed on one thread only, even though in other parts of the code, MKL calls to LAPACK are threaded. Any idea of why it switches to serial here?

 

 

0 Kudos
2 Replies
Gennady_F_Intel
Moderator
642 Views

Bjoern,

pls try to set  mkl_set_num_threads( #num of cores on your system ) before C=prod(A,B).

What would you see in then case?

 

0 Kudos
Bjoern_B_
Beginner
642 Views

Thanks Gennady,

turns out it was not a problem with MKL but with cmake caused linking of both GSL and MKL cblas, and the overloaded prod() took SGEMM from GSL...

I have another question regarding parallelization: Currently I have a construction:

 

#pragma omp parallel for

for ( int i =0 , i < mtot; i++) {                                                                                       

                B = ub::prod(A, B[ i ]);                                                                              

       }                         

Is it advisable to do this? Will every OMP thread try to execute a threaded prod()? Then I assume that means threads getting into conflict. In my case, A is 2700x2700 and each B 2700x2300 matrix.

0 Kudos
Reply