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

OpenMP with MKL - Get Thread Num

Raphael_P_
Beginner
517 Views

When using OpenMP I can get the thread num by using:

omp_get_thread_num()

However when using it with MKL the, the command doesn't work. Is there ano MKL command which replaces this?

Thank you,

Raphael

0 Kudos
1 Solution
SergeyKostrov
Valued Contributor II
517 Views
Here is a simple example how I use it:

...
    #if ( defined ( _RTPRAGMAOMP_PARALLEL ) )
    #pragma omp parallel
    #endif
    {
     RTinumber iId = OmpGetThreadId();
     #ifdef _RTMATRIXSETCORE_DIAGNOSTICS
     CrtPrintf( RTU("ThreadID=%2ld\n"), ( RTINT )iId );
     #endif
     RTiterator i;        // VR: Vectorized
     for( i = iStart[iId]; i < iEnd[iId]; i += 1 )
     {
      ptR = ptA + ptB;
     }
     CrtSfence();
    }
...

Note: OmpGetThreadId is a macro wrapper for omp_get_thread_num function.

 

View solution in original post

0 Kudos
3 Replies
SergeyKostrov
Valued Contributor II
517 Views
>>...However when using it with MKL the, the command doesn't work... OpenMP function omp_get_thread_num() should work in a parallel region(s) and it doesn't matter if MKL is used or not used. Could you post a piece of codes for review?
0 Kudos
SergeyKostrov
Valued Contributor II
518 Views
Here is a simple example how I use it:

...
    #if ( defined ( _RTPRAGMAOMP_PARALLEL ) )
    #pragma omp parallel
    #endif
    {
     RTinumber iId = OmpGetThreadId();
     #ifdef _RTMATRIXSETCORE_DIAGNOSTICS
     CrtPrintf( RTU("ThreadID=%2ld\n"), ( RTINT )iId );
     #endif
     RTiterator i;        // VR: Vectorized
     for( i = iStart[iId]; i < iEnd[iId]; i += 1 )
     {
      ptR = ptA + ptB;
     }
     CrtSfence();
    }
...

Note: OmpGetThreadId is a macro wrapper for omp_get_thread_num function.

 

0 Kudos
Gennady_F_Intel
Moderator
517 Views

You may try to use verbose mode to take the OpenMP thread number of the calling thread. pls see MKL User's Guide for details.

 

 

0 Kudos
Reply