compatibility between OpenMP and POSIX threads

compatibility between OpenMP and POSIX threads

Hi all,

I'm implementing a multi-threaded application with POSIX threads for a multi-core platform. I would need to set the threads affinity to bind each thread to a core as suggested in this post: http://software.intel.com/en-us/forums/topic/289210

I'm compiling with ICC. I've added the -openmp compilation switch. I call the omp_get_num_procs() from each thread body to let openmp see the threads. I set export KMP_AFFINITY="verbose,compact,granularity=core".

However, when I run the application it looks like only the main thread is detected and bound to some cores. The threads that the main thread create are not seen, as reported here:

OMP: Info #204: KMP_AFFINITY: decoding x2APIC ids.
OMP: Info #202: KMP_AFFINITY: Affinity capable, using global cpuid leaf 11 info
OMP: Info #154: KMP_AFFINITY: Initial OS proc set respected: {0,1,2,3,4,5,6,7}
OMP: Info #156: KMP_AFFINITY: 8 available OS procs
OMP: Info #157: KMP_AFFINITY: Uniform topology
OMP: Info #179: KMP_AFFINITY: 1 packages x 4 cores/pkg x 2 threads/core (4 total cores)
OMP: Info #206: KMP_AFFINITY: OS proc to physical thread map:
OMP: Info #171: KMP_AFFINITY: OS proc 0 maps to package 0 core 0 thread 0
OMP: Info #171: KMP_AFFINITY: OS proc 4 maps to package 0 core 0 thread 1
OMP: Info #171: KMP_AFFINITY: OS proc 1 maps to package 0 core 1 thread 0
OMP: Info #171: KMP_AFFINITY: OS proc 5 maps to package 0 core 1 thread 1
OMP: Info #171: KMP_AFFINITY: OS proc 2 maps to package 0 core 2 thread 0
OMP: Info #171: KMP_AFFINITY: OS proc 6 maps to package 0 core 2 thread 1
OMP: Info #171: KMP_AFFINITY: OS proc 3 maps to package 0 core 3 thread 0
OMP: Info #171: KMP_AFFINITY: OS proc 7 maps to package 0 core 3 thread 1
OMP: Info #144: KMP_AFFINITY: Threads may migrate across 1 innermost levels of machine
OMP: Info #147: KMP_AFFINITY: Internal thread 0 bound to OS proc set {0,4}

Any help would be very appreciated.

Thanks

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Try omp_get_max_threads() instead of omp_get_num_procs(). The latter initializes the library, but does not resister the thread if the library is already initialized. So only the first thread is registered. The former routine also initializes the library but also registers the thread always.  Probably the omp_get_num_procs() was changed since the time of post you mentioned.

Alternatively you can use low level affinity api provided by the OpenMP RTL (kmp_set_affinity() and others) to manually bind threads. See Intel Compiler documentation for more details.

- Andrey

That sorted the issue.

Thanks

Login to leave a comment.