OS 线程是否与不同 OpenMP 并行区域中的 thread_num 绑定?
Are OS threads tied to thread_num in different OpenMP parallel regions?
如果我有多个并行区域,这些并行区域中的给定线程索引(由 omp_get_thread_num()
返回)是否会使用同一个线程?
OpenMP标准(5.1版)未定义,除了主线程(主线程)遇到这两个部分(假设它们在您的应用程序中被同一个线程遇到):
The thread that encountered the parallel
construct becomes the primary thread of the new team, with a thread number of zero for the duration of the new parallel
region.
请注意,如果您在并行部分使用 未绑定的任务,则这不可能成立:
The thread number may change during the execution of an untied task. The value returned by omp_get_thread_num
is not generally useful during the execution of such a task region.
如果我有多个并行区域,这些并行区域中的给定线程索引(由 omp_get_thread_num()
返回)是否会使用同一个线程?
OpenMP标准(5.1版)未定义,除了主线程(主线程)遇到这两个部分(假设它们在您的应用程序中被同一个线程遇到):
The thread that encountered the
parallel
construct becomes the primary thread of the new team, with a thread number of zero for the duration of the newparallel
region.
请注意,如果您在并行部分使用 未绑定的任务,则这不可能成立:
The thread number may change during the execution of an untied task. The value returned by
omp_get_thread_num
is not generally useful during the execution of such a task region.