How to embed omp for omp single using OpenMP

I have a for loop that I don’t want to parallelize, which calls the function I want to parallelize (which has a for loop that I want to parallelize). I want to put a parallel area outside the entire batch, so that my threads are created only once (to reduce the overhead of creating threads).

However, at the moment, I have an omp singleencompassing for loop that calls the function and omp forinside the function to handle the inner loop. He hands in, and according to OMP single hangs inside , this is because it is illegal!

If I cannot do this, how can I approach him? I want to make sure that only one thread starts the outer loop and calls the function, but inside the function I can get full parallelism.

Is it possible? Any ideas?

+3
source share
2 answers

- , . , , , ( OpenMP), . , , . , , .

+1

:  - #pragma omp  -  - N  - #pragma omp

?

OMP, . /.

0

All Articles