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

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

Bild des Benutzers Martyn Corden (Intel)

Product:  Intel® Composer XE 2013 update 1

Compiler Version:  Intel® C/C++ Compiler version 13.0.1.117, 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 13.0.0.079). 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.

 

1 Beitrag / 0 neu
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.