Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Raphael_P_
Beginner
111 Views

OpenMP with MKL - Get Thread Num

Jump to solution

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
111 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
111 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
112 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

Gennady_F_Intel
Moderator
111 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