OMP_DYNAMIC

The OMP_DYNAMIC environment variable controls dynamic adjustment of the number of threads available for running parallel regions.

Read syntax diagramSkip visual syntax diagram
                   .-TRUE--.   
>>-OMP_DYNAMIC--=--+-FALSE-+-----------------------------------><

When OMP_DYNAMIC is set to TRUE, the number of threads that are created and then assigned to a place must not exceed the value of THREADS_PER_PLACE. The thread number includes the currently allocated threads of all active parallel regions. Under a given OMP_PROC_BIND policy, THREADS_PER_PLACE takes precedence in all situations.

When OMP_DYNAMIC is set to FALSE, if an application requires more threads than the value of THREADS_PER_PLACE in any place under a given OMP_PROC_BIND policy, the excess threads beyond the value of THREADS_PER_PLACE for all such places are assigned with priority to the following places:
  1. Places that have not reached THREADS_PER_PLACE.
  2. Places where the master thread is not running.

Examples

Example 1

Suppose OMP_THREAD_LIMIT=48 and OMP_PLACES={0,1,2,3,4,5,6,7},{8,9,10,11,12,13,14,15},{16,17,18,19}, the THREADS_PER_PLACE values are calculated as follows:

P0={0,1,2,3,4,5,6,7}: size = 8, total size = 20, THREADS_PER_PLACE = floor((8/20)*48) = floor(19.2) = 19

P1={8,9,10,11,12,13,14,15}: size = 8, total size = 20, THREADS_PER_PLACE = floor((8/20)*48) = floor(19.2) = 19

P2={16,17,18,19}: size = 4, total size = 20, THREADS_PER_PLACE = floor((4/20)*48) = floor(9.6) = 9

The number of total allocated threads is 47. Threads are allocated by place size. Because P0 and P1 have the same largest size and P0 comes first in OMP_PLACES, threads are allocated starting with P0. The thread allocation order is: P0, P1, P2. Only one thread is unallocated, so it is allocated to P0. Therefore, THREADS_PER_PLACE={20},{19},{9}.

Example 2

Suppose OMP_THREAD_LIMIT=17 and OMP_PLACES={0,1,2,3,0,1,2,3},{4,5,6,7,},{8,9,10,11}, the THREADS_PER_PLACE values are calculated as follows:

P0={0,1,2,3,0,1,2,3}: size = 8, total size = 16, THREADS_PER_PLACE = floor((8/16)*17) = floor(8.5) = 8

P1={4,5,6,7}: size = 4, total size = 16, THREADS_PER_PLACE = floor((4/16)*17) = floor(4.25) = 4

P2={8,9,10,11}: size = 4, total size = 16, THREADS_PER_PLACE = floor((4/16)*17) = floor(4.25) = 4

The number of total allocated threads is 16. Threads are allocated by place size, so the thread allocation order is: P0, P1, P2. Only one thread is unallocated, so it is allocated to P0. Therefore, THREADS_PER_PLACE={9},{4},{4}.

Example 3

Suppose OMP_THREAD_LIMIT=394 and OMP_PLACES={0,1},{2,3,4,5}, {6,7,8,9,10,11},{12,13,14,15},{16,17,18,19,20,21,22,23}, the THREADS_PER_PLACE values are calculated as follows:

P0={0,1}: size = 2, total size = 24, THREADS_PER_PLACE = floor((2/24)*394) = floor(32.8) = 32

P1={2,3,4,5}: size = 4, total size = 24, THREADS_PER_PLACE = floor((4/24)*394) = floor(65.7) = 65

P2={6,7,8,9,10,11}: size = 6, total size = 24, THREADS_PER_PLACE = floor((6/24)*394) = floor(98.5) = 98

P3={12,13,14,15}: size = 4, total size = 24, THREADS_PER_PLACE = floor((4/24)*394) = floor(65.7) = 65

P4={16,17,18,19,20,21,22,23}: size = 8, total size = 24, THREADS_PER_PLACE = floor((8/24)*394) = floor(131.3) = 131

The number of total allocated threads is 391. Threads are allocated by place size, so the thread allocation order is: P4, P2, P1, P3, P0. Three threads are unallocated, so the THREADS_PER_PLACE values of P4, P2, and P1 are increased by one each. Therefore, THREADS_PER_PLACE={32},{66},{99},{65},{132}.

Related information

OMP_PLACES

OMP_PROC_BIND



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us