Originally posted by: RoyHu
The IBM XL C/C++ compiler, V12.1 starts to support the OpenMP 3.1 extension to the OMP_NUM_THREADS environment variable.
With this extension, you can use OMP_NUM_THREADS to specify the number of threads to use for nested parallel regions.
Syntax:
>>-OMP_NUM_THREADS=--num_list----------------------------------><
num_list
A list of one or more positive integer values separated by commas.
Example:
export OMP_NUM_THREADS=3,4,5
export OMP_DYNAMIC=false
// omp_get_max_threads() returns 3
#pragma omp parallel
{
// Three threads running the parallel region
// omp_get_max_threads() returns 4
#pragma omp parallel if(0)
{
// One thread running the parallel region
// omp_get_max_threads() returns 5
#pragma omp parallel
{
// Five threads running the parallel region
// omp_get_max_threads() returns 5
}
}
}
Reference:
For more information about the usage of the OMP_NUM_THREADS environment variable, visit the topic at http://pic.dhe.ibm.com/infocenter/comphelp/v121v141/topic/com.ibm.xlc121.aix.doc/compiler_ref/ruomprun4.html