I am a bit confused with the usage and purpose of kmp_set_blocktime:

From and the source code (__kmp_aux_set_blocktime), the set_block_time change the block time for the calling thread and the team threads, no body else.

If the function is called in the sequential region, there is no team during the region. if it should be called in the parallel region, it should be in a critical section (or called by one thread only) so do not introduce traces since the call clearly updates some fields in the team object. I assume the intention is the latter case, which is for impacting the waiting behavior of the team thread after a parallel region. It however would not impact the them after the parallel region since the team is gone by that. did I miss anything?


Hi Yonghong!

The documentation says:

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 key words here is “formed by the calling thread”. That means there is no race conditions here as each thread only sets its own control variable. Calling the setter from inside the parallel region will affect nested parallel regions created by the calling thread, this does not affect current team members.