是否有一种方法可以跨越多个功能跨越openMP并行区域?
void run()
{
omp_set_num_threads(2);
#pragma omp parallel
{
foo();
#pragma omp for
for(int i = 0; i < 10; ++i)
{
//Do stuff here
}
}
}
void foo()
{
#pragma omp for
for(int j = 0; j < 10; ++j)
{
// Have this code be run as a worksharing loop by the OMP threads
// spawned in run
}
}
在此示例中,我希望在运行函数中的OMP并行区域中启动线程以输入FOO,并将其作为工作共享循环运行,就像它们在运行中运行for Loop一样。这是默认情况下发生的情况还是每个线程独立运行循环?您如何测试每个?
在我的示例中,函数foo和运行是成员函数是单独的类。
谢谢!
您所说的欲望是OpenMP的工作方式。