Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

OpenMP with MKL - Get Thread Num

Raphael_P_
Beginner
217 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
217 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

3 Replies
SergeyKostrov
Valued Contributor II
217 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?
SergeyKostrov
Valued Contributor II
218 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.

 

Gennady_F_Intel
Moderator
217 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.

 

 

Reply