I wanted to study about the basis on which OpenMP API allocates threads to the cores. What factors does it take under consideration while doing so? Can this allocation be modified according to the programmer's needs?
How does OpenMP do thread allocation?
587 views Asked by Vaishali Aggarwal At
2
There are 2 answers
0
On
Yes, the number of threads can definitely be modified as per a programmer's judgment.
Refer to : OpenMp set number of threads for parallel loop depending on variable
By default, OpenMP allocates as many threads as the number of cores on the machine/node (in case of a distributed system) it is running on.
I believe that you're looking for the affinity between open-mouthed threads and hardware threads/cores. The answer is yes, btw.
If you use Intel compilers you can take a look at this site for KMP_AAFFINITY environment variable. https://software.intel.com/en-us/node/522691
If you use GNU compilers you might be interested in these official OpenMP environment variables. https://gcc.gnu.org/onlinedocs/libgomp/OMP_005fPLACES.html https://gcc.gnu.org/onlinedocs/libgomp/OMP_005fPROC_005fBIND.html