Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
公告
Important Update: Community Platform Migration​. Learn more​>

MKL sgemm executed serial

Bjoern_B_
初学者
2,611 次查看

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 项奖励
2 回复数
Gennady_F_Intel
主持人
2,611 次查看

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 项奖励
Bjoern_B_
初学者
2,611 次查看

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 项奖励
回复