openmp taskwait 是否释放任务 运行 所在的核心?

Does openmp taskwait free the core the task is running on?

基本上就是问题的意思。

假设我在核心上有一个任务 运行,在某个时候我想等待它的子任务完成(使用 taskwait 指令)。在任务等待期间,其他任务是否可以使用绑定到等待任务的核心?还是那个核心被阻塞了?

,OpenMP 运行时可以在taskwait 指令期间执行 其他任务,因为该指令是隐式的OpenMP 中的调度点。但是,这 不是强制性的 。 Intel/Clang OpenMP 运行时 (IOMP) 和 GCC (GOMP) 都这样做。大多数运行时为了性能而尝试这样做。

以下是 OpenMP 5.1 标准的规定:

Section 2.12.6:
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. Task scheduling points are implied at the following locations:

  • [...] in a taskwait region [...].

请注意,其他线程可以主动或被动地等待新的传入任务。因此,如果没有任务可用(即核心不空闲),核心可能会忙于等待安排新任务。您可以使用环境变量 OMP_WAIT_POLICY.

来控制它