OMP_NUM_THREADS
>>-OMP_NUM_THREADS=--num_list----------------------------------><
- num_list
- A list of one or more positive integer values separated by commas.
If you do not set the OMP_NUM_THREADS environment variable, the number of processors available is the default value to form a new team for the first encountered parallel construct. By default, any nested constructs are run by one thread.
If num_list contains a single value, dynamic adjustment of the number of threads is enabled (OMP_DYNAMIC is set to true), a parallel construct without a NUM_THREADS clause is encountered, the value is the maximum number of threads that can be used to form a new team for the encountered parallel construct.
If num_list contains a single value, dynamic adjustment of the number of threads is not enabled (OMP_DYNAMIC is set to false), a parallel construct without a NUM_THREADS clause is encountered, the value is the exact number of threads that can be used to form a new team for the encountered parallel construct.
If num_list contains multiple values, dynamic adjustment of the number of threads is enabled (OMP_DYNAMIC is set to true), a parallel construct without a NUM_THREADS clause is encountered, the first value is the maximum number of threads that can be used to form a new team for the encountered parallel construct. After the encountered construct is entered, the first value is removed and the remaining values form a new num_list. The new num_list is in turn used in the same way for any closely nested parallel constructs inside the encountered parallel construct.
If the number of threads requested exceeds the system resources available, the program stops.
The omp_set_num_threads routine sets the first value of num_list. The omp_get_max_threads routine returns the first value of num_list.
- The number of threads set using the NUM_THREADS clause takes precedence over that set using the omp_set_num_threads routine.
- The number of threads set using the omp_set_num_threads routine takes precedence over that set using the OMP_NUM_THREADS environment variable.
- The number of threads set using the OMP_NUM_THREADS environment variable takes precedence over that set using the PARTHDS suboption of the XLSMPOPTS environment variable.
export OMP_NUM_THREADS=5,10
export OMP_DYNAMIC=false
! OMP_GET_MAX_THREADS() returns 5 threads
!$omp parallel
! OMP_GET_MAX_THREADS() returns 10 threads
!$omp parallel
! OMP_GET_MAX_THREADS() returns 10 threads
!$omp parallel
! OMP_GET_MAX_THREADS() returns 10 threads
!$omp end parallel
!$omp end parallel
!$omp end parallel