I want to bind the threads in my code to each physical core.
With GCC I have successfully done this using sched_setaffinity
so I no longer have to set exp
You should use the SetThreadAffinityMask
function (see MSDN reference). You are setting the process's mask.
You can obtain a thread ID
in OpenMP with this code:
int tid = omp_get_thread_num();
However the code above provides OpenMP's internal thread ID
, and not the system thread ID
. This article explains more on the subject:
http://msdn.microsoft.com/en-us/magazine/cc163717.aspx
if you need to explicitly work with those trheads - use the explicit affinity type
as explained in this Intel documentation:
https://software.intel.com/sites/products/documentation/studio/composer/en-us/2011Update/compiler_c/optaps/common/optaps_openmp_thread_affinity.htm