Issue with explicit offload of OpenMP reduction construct in C/C++ programs

Issue with explicit offload of OpenMP reduction construct in C/C++ programs

Product:  Intel® Composer XE 2013 update 1

Compiler Version:  Intel® C/C++ Compiler version, build date 20121010

Problem:    If a C or C++ main program explicitly offloads an OpenMP construct containing an OpenMP parallel reduction to a coprocessor, it may give an incorrect result, e.g.

   double sum=0.;
   #pragma offload target(mic) inout(sum)
   #pragma omp parallel for reduction(+:sum)
       for(i=1;i<=n;i++)  sum += (double)i;

The problem does not affect native applications for Intel® Xeon Phi™ coprocessors, Fortran applications, or applications built with the original release of Intel Composer XE 2013 (Intel C/C++ compiler Entire functions that are offloaded, that internally contain OpenMP reductions, are not affected; neither are offloads of OpenMP constructs from functions other than the main program.

Workaround:     The problem may be worked around by wrapping the offloaded OpenMP construct within a function, e.g.


 __attribute((target(mic))) double reduce(int n)  {
int i;
               double sum=0.;
#pragma omp parallel for reduction(+:sum)
for(i=1;i<=n;i++) sum += (double)i;
  return sum;
   double mysum;
#pragma offload target(mic:0) inout(mysum) in(n)
     mysum = reduce(n);

This issue will be addressed in a forthcoming compiler update.

Additional information may be requested via your Intel Premier Support account.


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

This defect (internal tracking id: DPD200240132) is resolved in the Intel® Composer XE 2013 Update 4 release (pkg id 2013.4.183 - Linux), Compiler Version:  Intel® C/C++ Compiler Version build date 20130514

Leave a Comment

Please sign in to add a comment. Not a member? Join today