OpenMP任务计划策略 [英] OpenMP Task Scheduling Policies

查看:101
本文介绍了OpenMP任务计划策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道OpenMP任务队列的任务调度是如何执行的.

I would like to know how the task scheduling of the OpenMP task queue is performed.

这里我读到,默认情况下,OpenMP强制采用广度优先的调度程序,并且他们对FIFO与LIFO进行了一些测试,但是他们没有说默认值.由于我只有一个线程(我使用单个指令)来创建多个任务,因此比较它们的广度优先与工作优先的调度没有任何意义.

Here I read that, by default, OpenMP imposes a breadth-first scheduler and that they did some tests FIFO vs. LIFO, but they don't say anything about the default. Since I only have a single thread (I use the single directive) creating multiple tasks, I don't think it makes any sense comparing their breadth-first vs work-first scheduling.

那么,默认的FIFO还是LIFO?可以更改它吗?

So, is the default FIFO or LIFO? And is it possible to change it?

谢谢

推荐答案

我想知道OpenMP任务队列的任务调度是如何执行的

I would like to know how the task scheduling of the OpenMP task queue is performed

摘要版本

即使标准,OpenMP中的任务调度也是由实现定义的对算法施加了一些限制.如果您需要操纵调度程序,则搜索的地方就是您要定位的特定OpenMP实现.

Abstract version

Task scheduling in OpenMP is implementation defined, even though the standard imposes some restrictions on the algorithm. Should you need to manipulate the scheduler, the place to search is the particular OpenMP implementation you are targeting.

定义所有任务调度机制的基本概念是任务调度点的概念(请参阅第2.11.3节):

The basic concept upon which all the task scheduling machinery is defined is that of task scheduling point (see section 2.11.3):

只要线程到达任务调度点,就执行 可能导致它执行任务切换,开始执行或恢复执行 与当前团队绑定的另一项任务.

Whenever a thread reaches a task scheduling point, the implementation may cause it to perform a task switch, beginning or resuming execution of a different task bound to the current team.

在下面的注释中,他们对预期行为(强调我的行为)进行了更广泛的解释:

In the notes below they give a broader explanation of what should be the expected behavior (emphasis mine):

任务计划动态地动态将任务区域划分为多个部分. 每个部分从头到尾不间断地执行.不同的部分 相同任务区域中的任务按它们执行的顺序执行 遭遇.在没有任务同步结构的情况下, 线程执行不同可调度任务的部分的顺序 未指定.

Task scheduling points dynamically divide task regions into parts. Each part is executed uninterrupted from start to end. Different parts of the same task region are executed in the order in which they are encountered. In the absence of task synchronization constructs, the order in which a thread executes parts of different schedulable tasks is unspecified.

正确的程序必须与所有程序正确一致地运行 与规则兼容的可想象的调度顺序 以上 ...

A correct program must behave correctly and consistently with all conceivable scheduling sequences that are compatible with the rules above ...

该标准还指定了隐含任务安排点的位置:

  • 紧接明确任务生成的点
  • 完成任务区域后
  • 任务产生区
  • 在任务等待区域中
  • 在任务组区域的末尾
  • 在隐式和显式障碍区域中
  • 紧随目标区域生成的点
  • 在目标数据区域的开头和结尾
  • 在目标更新区域中
  • the point immediately following the generation of an explicit task
  • after the point of completion of a task region
  • in a taskyield region
  • in a taskwait region
  • at the end of a taskgroup region
  • in an implicit and explicit barrier region
  • the point immediately following the generation of a target region
  • at the beginning and end of a target data region
  • in a target update region

遇到一个线程时,

做什么:

and what a thread may do when it meets one of them:

  • 开始执行绑定到当前团队的绑定任务
  • 恢复绑定到当前团队的任何暂停的任务区域
  • 开始执行绑定到当前团队的未绑定任务
  • 恢复绑定到当前团队的任何暂停的非绑定任务区域.
  • begin execution of a tied task bound to the current team
  • resume any suspended task region, bound to the current team, to which it is tied
  • begin execution of an untied task bound to the current team
  • resume any suspended untied task region bound to the current team.

它明确地说:

如果以上选择之一可用,则未指定 关于哪个将被选择.

If more than one of the above choices is available, it is unspecified as to which will be chosen.

为不同的遵循行为留出空间.它仅施加四个约束:

leaving space for different conforming behaviors. It only imposes four constraints:

  1. 包含的任务在生成任务后立即执行.
  2. 新的绑定任务的调度受当前绑定到线程的任务区域集约束,而不是 悬浮在障碍区域.如果此集合为空,则任何新的绑定任务 可能是预定的.否则,只有在以下情况下才可以安排新的捆绑任务: 这是集合中每个任务的后代任务.
  3. 从属任务必须在满足其任务依赖关系后才能安排.
  4. 当由包含if子句的构造生成显式任务时,如果该子句的表达式求值为false,则前一个 约束已经满足,任务将在之后立即执行 任务的生成.
  1. An included task is executed immediately after generation of the task.
  2. Scheduling of new tied tasks is constrained by the set of task regions that are currently tied to the thread, and that are not suspended in a barrier region. If this set is empty, any new tied task may be scheduled. Otherwise, a new tied task may be scheduled only if it is a descendent task of every task in the set.
  3. A dependent task shall not be scheduled until its task dependences are fulfilled.
  4. When an explicit task is generated by a construct containing an if clause for which the expression evaluated to false, and the previous constraints are already met, the task is executed immediately after generation of the task.

每个调度算法都必须满足才能被视为符合条件.

that every scheduling algorithm must fulfill to be considered conforming.

这篇关于OpenMP任务计划策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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