I have a piece of code in the following style:
for (set=0; set < n; set++) //For1
{
#pragma omp parallel for num_threads(x)
for (i=0; i < m; i++) //For2: this loop can be executed in parallel
{
commands...
}
for (j=0; j < m; j++) //For3: this loop depends on the output of the For2 and also should be executed in a sequential way
{
commands...
}
}
As you notice, I have n independent Sets (outer loop, i.e. For1). Each Set consists of a parallel loop (For2) and a sequential section (For3) which should be executed after For2.
I already used "#pragma omp parallel for num_threads(x)" for For2 to make it parallel.
Now I wanna to make the outer loop (For1) parallel as well. In other words, I wanna to run each Set in parallel.
I really appreciate if you could let me know how it is possible in openmp.
one way might be creating n threads corresponding to each Set. is it correct? But I am wondering if there is another way by entirely using openmp features?
thanks in advance.