Software Archive
Read-only legacy content
17060 Discussions

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

Martyn_C_Intel
Employee
619 Views

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.

[cpp]   double sum=0.;

   #pragma offload target(mic) inout(sum)

   #pragma omp parallel for reduction(+:sum)

       for(i=1;i<=n;i++)  sum += (double)i;

    [/cpp]

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.

 [cpp] __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);

   } 

[/cpp]

This issue will be addressed in a forthcoming compiler update.

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

 

0 Kudos
1 Reply
Kevin_D_Intel
Employee
619 Views

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 13.1.2.183 build date 20130514

0 Kudos
Reply