c - maximum number of variables in private() clause in OpenMP -
i want know whether there limitation on number of variables can defined in private() clause in openmp.
i have code has 4 loops lot of variables. outermost loop can parallelized using pragma. inner loop can parallelized using pragma. using 1 pragma @ time. (either outermost or innermost) of course, using pragma in innermost loop not advisable because overhead of thread creation because of 3 loops above it. put pragma correctness test purposes.
#pragma omp parallel private(var1,var2,...i,k,l) for(j = ...) { int var1; int var2; (i = ... ) { ... for(k = ... ) { ... for(l = ... ) { ... ... } } } }
or
for(j = ...) { int var1; int var2; (i = ... ) { ... for(k = ... ) { ... #pragma omp parallel private(var3,var4) for(l = ... ) { int var3; int var4; } } } }
correctness test fails outermost loop. compared inner loop, private variables list outermost loop 29 while inner pragma contains 21 variables in private variable list.
i compare c version openmp version, print values in array , sort , compare.
your problem has nothing number of variable names, allowed in private
clause. rather first example syntactically incorrect.
#pragma omp parallel private(var1,var2,...i,k,l) for(j = ...) { int var1; int var2; ... }
both var1
, var2
undeclared @ point parallel for
directive , clauses parsed. don't have (and cannot) specify sharing class. belong inner scope , therefore have predetermined sharing class private
. §2.9.1.1 openmp specification v3.1:
certain variables , objects have predetermined data-sharing attributes follows:
- variables automatic storage duration declared in scope inside construct private.
variables predetermined data-sharing attributes may not listed in data-sharing attribute clauses, except cases listed below.
it advisable use c99 features if possible , declare loop variables in scope referenced, e.g.:
#pragma omp parallel private(...) (int j = ...) { int var1; int var2; (int = ... ) { ... (int k = ... ) { ... (int l = ... ) { ... ... } } } }
in case no variable (i
, j
, k
, l
, var1
, var2
) list should appear in private
clause.
Comments
Post a Comment