等待OpenMP任务在隐性障碍下完成? [英] Waiting for OpenMP task completion at implicit barriers?

查看:202
本文介绍了等待OpenMP任务在隐性障碍下完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我创建了一堆OpenMP任务并且不使用taskwait,程序将在哪里等待任务完成?考虑以下示例:

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?
}

程序是否在single块末尾的隐式屏障处等待任务完成?我认为是这样,但是在OpenMP规范中找不到有关此问题的任何信息.

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.

编辑

来自OpenMP规范中的barrier描述:

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.

但是,这并没有说明我是负责任务完成还是OpenMP运行时为我完成任务.

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

推荐答案

OpenMP中的任务完成是隐式的,不是显式的(1.2.5任务术语)

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

任务完成 任务完成发生在与生成该事件的 construct 相关的结构化块的末尾. 任务已达到.

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

single工作共享结构的末尾有一个隐式障碍.如您所述,障碍等待明确的任务.因此,所有任务将在single块的处完成.

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.

这篇关于等待OpenMP任务在隐性障碍下完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆