From 8ae7941013b2a9bdab54461ae0fcac4747d851e3 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 20 Apr 2011 23:11:56 -0400 Subject: CarpetReduce: Rewrite OpenMP parallelisation for PGI compilers Special case the OpenMP parallelisation of the main reduction loop for PGI compilers to circumvent a compiler bug. --- Carpet/CarpetReduce/src/reduce.cc | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'Carpet/CarpetReduce') diff --git a/Carpet/CarpetReduce/src/reduce.cc b/Carpet/CarpetReduce/src/reduce.cc index 9d977a52c..26711fef6 100644 --- a/Carpet/CarpetReduce/src/reduce.cc +++ b/Carpet/CarpetReduce/src/reduce.cc @@ -613,6 +613,10 @@ namespace CarpetReduce { imin[d] = (bbox[2*d ] ? 0 : nghostzones[d]); imax[d] = lsh[d] - (bbox[2*d+1] ? 0 : nghostzones[d]); } + +#if ! (defined(__PGI) && (__PGIC__>9)) + // Regular case + #pragma omp parallel { T myoutval_local; @@ -659,6 +663,72 @@ namespace CarpetReduce { OP::combine (myoutval, mycnt, myoutval_local, mycnt_local); } } // end omp parallel + +#else + // Special case for PGI 10 and later + + int const num_threads = dist::num_threads(); + T myoutval_locals[num_threads]; + T mycnt_locals [num_threads]; + // This is probably not worthwhile: + // #pragma omp parallel + for (int n=0; n(inarrays.AT(tl))[index] * tfacs.AT(tl); + } + OP::reduce (myoutval_local, mycnt_local, myinval, w); + } + } + } +#elif CARPET_DIM == 4 +#pragma omp parallel for + for (int l=imin[3]; l(inarrays.AT(tl))[index] * tfacs.AT(tl); + } + OP::reduce (myoutval_local, mycnt_local, myinval, w); + } + } + } + } +#else +# error "Value of CARPET_DIM is not supported" +#endif + // This loop is not parallel + for (int n=0; n -- cgit v1.2.3