Reputation: 2026
i have the following code :
#pragma omp parallel sections num_threads(2) {
#pragma omp section
Function_1;
#pragma omp section
Function_2;
}
but within the Function_1 and Function_2, i have a parallel for but just one thread run it. So, how run the Function_1 and Function_2 in parallel and run several threads within these functions?
thx!
Upvotes: 2
Views: 227
Reputation: 74495
Having one parallel
region inside another is called nesting. By default nested regions are inactive, which means that they execute serially. In order to make them active, you can:
OMP_NESTED
to true
parallel
region: omp_set_nested(1);
One can also limit the number of levels, where nested parallelism works, by:
OMP_MAX_ACTIVE_LEVELS
to num
, oromp_set_max_active_levels(num);
where num
is the desired maximum active level, e.g. a value of 3
would render all parallel
regions, nested more than 3
levels deep, inactive.
Upvotes: 3