Waiting for OpenMP task completion at implicit barriers?

雨燕双飞 提交于 2019-12-11 05:53:00

问题


If I create a bunch of OpenMP tasks and do not use taskwait, where does the program wait for that tasks completion? Consider the following example:

#pragma omp parallel
{
   #pragma omp single
   {
      for (int i = 0; i < 1000; i++) {
         #pragma omp task
         ... // e.g., call some independent function
      }
      // no taskwait here
   }
   // all the tasks completed now?
}

Does the program wait for task completion at the implicit barrier at the end of the single block? I assume so, but cannot find any information about this issue in the OpenMP Specification.

EDIT

From barrier description in OpenMP Spec.:

All threads of the team executing the binding parallel region must execute the barrier region and complete execution of all explicit tasks bound to this parallel region before any are allowed to continue execution beyond the barrier.

This, however, does not says whether I am responsible for task completion or the OpenMP runtime does it for me.


回答1:


Task completion in OpenMP is implicit, not explicit (1.2.5 Tasking Terminology)

task completion Task completion occurs when the end of the structured block associated with the construct that generated the task is reached.

There is an implicit barrier at the end of the single worksharing construct. As you mentioned, barriers wait for explicit tasks. Therefore all tasks will be completed at the of the single block.



来源:https://stackoverflow.com/questions/42202436/waiting-for-openmp-task-completion-at-implicit-barriers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!