Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

OMP_WAIT_POLICY and KMP_BLOCKTIME

Ronald_G_2
Beginner
5,098 Views

I had assumed that the Intel OpenMP Runtime library would respect OMP_WAIT_POLICY, and further I assumed that

OMP_WAIT_POLICY=passive

would be the same as KMP_BLOCKTIME=0.  I think this is a wrong assumption. 

 

BUT After some timing I believe it's true that:

OMP_WAIT_POLICY=passive is same as KMP_BLOCKTIME=<default 200ms>

OMP_WAIT_POLICY=active is same as KMP_BLOCKTIME=infinite

Can someone confirm the above?

0 Kudos
7 Replies
SergeyKostrov
Valued Contributor II
5,097 Views
>>... >>OMP_WAIT_POLICY=passive is same as KMP_BLOCKTIME= >> >>OMP_WAIT_POLICY=active is same as KMP_BLOCKTIME=infinite >> >>Can someone confirm the above? I don't confirm it. There is another environment variable of the Intel OpenMP Runtime library that needs to be taken into account and this is KMP_LIBRARY. In your interpretation KMP_LIBRARY is not considered, its default value is throughtput, and relations should be extended to: OMP_WAIT_POLICY=passive = KMP_LIBRARY=throughtput and KMP_BLOCKTIME= OMP_WAIT_POLICY=active = KMP_LIBRARY=throughtput and KMP_BLOCKTIME=infinite and that is not correct because: OMP_WAIT_POLICY=ACTIVE is an alias for KMP_LIBRARY=turnaround, and OMP_WAIT_POLICY=PASSIVE is an alias for KMP_LIBRARY=throughtput.
0 Kudos
SergeyKostrov
Valued Contributor II
5,097 Views
Correct relations are as follows: OMP_WAIT_POLICY=passive is the same as KMP_LIBRARY=throughtput and KMP_BLOCKTIME=( default 200ms ) OMP_WAIT_POLICY=active is the same as KMP_LIBRARY=turnaround and KMP_BLOCKTIME=infinite Next step for you is: Verify these relations using a test program you've used to get "...some timing...". My understanding is that you have the test program and used it for investigation.
0 Kudos
SergeyKostrov
Valued Contributor II
5,097 Views
Here are more technical details for your review: OMP_WAIT_POLICY Decides whether threads spin (active) or yield (passive) while they are waiting. Or, Specifies whether waiting threads should be active or passive. If the value is PASSIVE, waiting threads should not consume CPU power while waiting; while the value is ACTIVE specifies that they should. If undefined, threads wait actively for a short time before waiting passively. OMP_WAIT_POLICY=ACTIVE is an alias for KMP_LIBRARY=turnaround, and OMP_WAIT_POLICY=PASSIVE is an alias for KMP_LIBRARY=throughtput. Default: Passive Syntax: OMP_WAIT_POLICY=value
0 Kudos
SergeyKostrov
Valued Contributor II
5,097 Views
KMP_BLOCKTIME Sets the time, in milliseconds, that a thread should wait, after completing the execution of a parallel region, before sleeping. Use the optional character suffixes: s (seconds), m (minutes), h (hours), or d (days) to specify the units. Specify infinite for an unlimited wait time. Default: 200 milliseconds Related Environment Variable: KMP_LIBRARY environment variable.
0 Kudos
SergeyKostrov
Valued Contributor II
5,098 Views
KMP_LIBRARY Selects the OpenMP run-time library execution mode. The values for this variable are serial, turnaround, or throughput. Default: throughput Throughput mode: The throughput mode allows the program to yield to other running programs and adjust resource usage to produce efficient execution in a dynamic environment. In a multi-user environment where the load on the parallel machine is not constant or where the job stream is not predictable, it may be better to design and tune for throughput. This minimizes the total time to run multiple jobs simultaneously. In this mode, the worker threads yield to other threads while waiting for more parallel work. After completing the execution of a parallel region, threads wait for new parallel work to become available. After a certain period of time has elapsed, they stop waiting and sleep. Until more parallel work becomes available, sleeping allows processor and resources to be used for other work by non-OpenMP threaded code that may execute between parallel regions, or by other applications. The amount of time to wait before sleeping is set either by the KMP_BLOCKTIME environment variable or by the kmp_set_blocktime() function. A small blocktime value may offer better overall performance if your application contains non-OpenMP threaded code that executes between parallel regions. A larger blocktime value may be more appropriate if threads are to be reserved solely for use for OpenMP execution, but may penalize other concurrently-running OpenMP or threaded applications. Turnaround mode: The turnaround mode is designed to keep active all processors involved in the parallel computation, which minimizes execution time of a single job. In this mode, the worker threads actively wait for more parallel work, without yielding to other threads (although they are still subject to KMP_BLOCKTIME control). In a dedicated (batch or single user) parallel environment where all processors are exclusively allocated to the program for its entire run, it is most important to effectively use all processors all of the time. Note: Avoid over-allocating system resources. The condition can occur if either too many threads have been specified, or if too few processors are available at run time. If system resources are over-allocated, this mode will cause poor performance. The throughput mode should be used instead if this occurs. Serial mode: The serial mode forces parallel applications to run as a single thread. Intel extension to OpenMP run-time library API: ... void kmp_set_library_throughput() void kmp_set_library_turnaround() void kmp_set_library_serial() void kmp_set_library(int) 1 - serial mode / 2 - turnaround mode / 3 - throughput mode int kmp_get_library() 1 - serial mode / 2 - turnaround mode / 3 - throughput mode ... In the throughput OpenMP Support Libraries, threads wait for new parallel work at the ends of parallel regions, and then sleep, after a specified period of time. This time interval can be set by the KMP_BLOCKTIME environment variable or by the kmp_set_blocktime() function. ... int kmp_get_blocktime(void) Returns the number of milliseconds that a thread should wait, after completing the execution of a parallel region, before sleeping, as set either by the KMP_BLOCKTIME environment variable or by kmp_set_blocktime(). void kmp_set_blocktime(int msec) Sets the number of milliseconds that a thread should wait, after completing the execution of a parallel region, before sleeping. This routine affects the block time setting for the calling thread and any OpenMP team threads formed by the calling thread. The routine does not affect the block time for any other threads. ...
0 Kudos
SergeyKostrov
Valued Contributor II
5,097 Views
OpenMP Support Libraries . https://software.intel.com/en-us/node/522689 ( version 15.x ) . Topics to look at: Execution modes Thread Sleep Time
0 Kudos
Reply