OpenMP for loop with master region: “master region may not be closely nested inside of work-sharing or explicit task region”

左心房为你撑大大i 提交于 2019-12-05 09:45:25

It is giving you the warning because A master region may not be closely nested inside a worksharing, atomic, or explicit task region.

#pragma omp master is a master region as the name suggests and #pragma omp parallel for is a task sharing region.

They are closely nested because no function call or statement separates them.

In order to avoid the warning replace the #pragma omp master with something like

tid = omp_get_thread_num();
if(tid == 0)
{
   progress_bar(x*omp_get_num_threads());
}

as per the example here.

See Guide into OpenMP: Easy multithreading programming for C++ for more information and examples.

For further information see the OpenMP Specification or see Intel's Documentation on Improper nesting of OpenMP constructs.

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