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

cblas_sgemm executes on single thread when invoked in .Net

sugarpie
Beginner
335 Views
I'm having a issue where cblas_sgemm wont execute on all cores when it's called from a .Net application. The following code executes on all cores when invoked from native code (Win32 - Console application):

const int M = m;
const int N = n;
const int K = k;

const float alpha = 1;
const float beta = 1;

const int lda = K;//K;//M;//K;//M;
const int ldb = N;//N;//K;//M;//N;
const int ldc = N;//M;//K;//M;


const CBLAS_ORDER rowOrder = CblasRowMajor;
const CBLAS_TRANSPOSE alphaTrans = CblasNoTrans;
const CBLAS_TRANSPOSE betaTrans = CblasNoTrans;

cblas_sgemm(rowOrder,
alphaTrans,
betaTrans,
(MKL_INT)M,
(MKL_INT)N,
(MKL_INT)K,
alpha,
a,
(MKL_INT)lda,
b,
(MKL_INT)ldb,
beta,
c,
(MKL_INT)ldc);

But the code is called from .Net, where the code has been put into a DLL which the .Net code uses, the computation is done but only on a single thread. I'm having the same issue when other native code which uses OpenMP. I suspect there's something fishy with the managed code since the multithreading using OpenMP has worked before, it's like it has stopped working for some reason. Any ideas or input would be appreciated.

I'm using Visual Studio 2008 and MKL: 10.1
0 Kudos
2 Replies
TimP
Honored Contributor III
335 Views
Quoting - sugarpie
But the code is called from .Net, where the code has been put into a DLL which the .Net code uses, the computation is done but only on a single thread. I'm having the same issue when other native code which uses OpenMP.
Do you check status of relevant environment variables when you reach the OpenMP part of the application?
0 Kudos
Vladimir_Koldakov__I
New Contributor III
335 Views

Hello,

Could you please provide some more details?

What means "...worked before"?

How do you declare and call cblas_sgemm from managed code?

And how do you build the native dll?

Thanks,

-Vladimir

0 Kudos
Reply