I have two kind of jobs to do, foobar1
to be done 3 times in parallel and foobar2
to be done 5 times in parallel.
My Idea is to make the master thread create those two teams of work. but I face one difficulty.
Is It possible to make a thread escape from a parallel loop ? I mean to realize such a code where the master task can escape the first team of work to create the second team
#pragma omp parallel num_threads(8)
{
// first team of task which will execute the foobar1 function in parallel
#pragma omp for schedule(static,1) nowait
for(i = 0; i < 3; i++)
{
#pragma omp master
{
//escape here to create a second team in parallel
}
foobar1();
}
// second team of task which will execute the foobar2
#pragma omp for schedule(static,1) nowait
for(j = 0; j < 5; j++)
{
foobar2();
}
}