I'm trying to write a parallel code for a function that has the following scheme, using OpenMP:
1. Begin of data-dependent loop
2. Some computation
3. If the result of 2 equals 0 then
3.1. Begin of data-independent loop
3.2. Some computation
3.3. End of data-independent loop
4. Some computation by a single thread
5. Begin of data-independent loop
6. Some computation
7. End of data-independent loop
8. End of data-dependent loop
The issue is - I'd like to enclose the regions with something like:
#pragma omp parallel
1. Begin of data-dependent loop
#pragma omp master
2. Some computation by a single thread
3. If the result of 2 equals 0 then
#pragma omp for
3.1. Begin of data-independent loop
3.2. Some computation
3.3. End of data-independent loop
4. Some computation by a single thread
#pragma omp for
5. Begin of data-independent loop
6. Some computation
7. End of data-independent loop
8. End of data-dependent loop
However, the compiler does not allow me to have the pragma omp for
nested with pragma omp master
. Is there any solution to that, besides changing them to pragma omp parallel for
and giving up the fork outside the main loop?
Let me know if it isn't clear enough.
Thanks in advance