gccg++openmpgnuxlc

Equivalent of KMP_AFFINITY=verbose for gnu and ibm openmp libraries?


When using OpenMP on Intel systems, I often find it useful to set KMP_AFFINITY=verbose,(other options...) so the library spits out which cores my threads are actually bound to. I find this helpful when experimenting with different thread binding options. Currently I'm working with a Power8 system, and wondering if there's an equivalent of KMP_AFFINITY=verbose for the GNU and/or IBM OpenMP distributions. In other words, how can I get information on where my threads are placed if I compile my OpenMP executable with g++ or xlc++?


Solution

  • GCC OpenMP documentation (libgomp) says this is currently not possible:

    There is no libgomp library routine to determine whether a CPU affinity specification is in effect. As a workaround, language-specific library functions, e.g., getenv in C or GET_ENVIRONMENT_VARIABLE in Fortran, may be used to query the setting of the GOMP_CPU_AFFINITY environment variable. A defined CPU affinity on startup cannot be changed or disabled during the runtime of the application.

    You can try to use GOMP_DEBUG and see if it does what you are looking for.