Software Archive
Read-only legacy content
17061 Discussions

Offloading of a simple code that includes a User Defined Reduction

Italo_E_
Beginner
278 Views

Dear all,

I am trying to compile with the latest Intel compiler (version 16.0.3) the following simple code in which an OpenMP v4.x user defined reduction is offloaded to a MIC.

#pragma offload_attribute (push,target(mic))
#include <stdio.h>

typedef struct {
   double real;
   double imag;
} complex_t;

complex_t complex_add (complex_t a, complex_t b)
{
   complex_t c;
   c.real = a.real + b.real;
   c.imag = a.imag + b.imag;
   return c;
}

#pragma offload_attribute (pop)

int main ()
{
   complex_t x;

#pragma omp declare reduction(cmplxAdd: complex_t: omp_out=complex_add(omp_out, omp_in)) initializer( omp_priv={0.0, 0.0} )
#pragma offload target(mic) out(x)
   {
      x = (complex_t) {0.0, 0.0};

#pragma omp parallel num_threads(48) reduction(cmplxAdd: x)
      {
         x = (complex_t) {1.0, -1.0};
      }
   }

   printf ("Done: result is  %f,%f\n", x.real, x.imag);
}

The code is compiled using

icc -O3 -qopenmp -o mytest mytest.c

The compiler fails, producing the following error message:

/tmp/iccI8DGFd.o: In function `main':
main.c:(.text+0x199): undefined reference to `__udr_i_0x4633c48'
main.c:(.text+0x1d6): undefined reference to `__udr_c_0x4633658'

If I understand correctly, the first undefined reference is for the user defined reduction initializer, and the second one for the user defined reduction combiner (the reduction function). However, searching the Internet for related documentation I was not able to find anything about. What should I do to properly compile the code ? Am I missing linking one or more specific libraries ?

Thank you in advance for your kind assistance.

Italo Epicoco

0 Kudos
4 Replies
Kevin_D_Intel
Employee
278 Views

The cause of the undefined references is unclear so I’m consulting w/Developers. Even a pure OpenMP version (i.e. no mixing of Intel’s LEO + OpenMP) produces the same undefined references.

0 Kudos
Italo_E_
Beginner
278 Views

Dear Kevin,

thanks for your reply. Please also consider that when compiled in native mode (with -mmic flag) the "pure" OpenMP code does not produce any error

0 Kudos
jimdempseyatthecove
Honored Contributor III
278 Views

I may be wrong on this, but the scope of the function complex_add, is that of a global function inside the mic (not on host).

Your declare pragma is issued in the scope of the main (host) program... no such symbol.

What happens when you move line 23 to line 27? (inside the MIC/offload region)

Jim Dempsey

0 Kudos
Kevin_D_Intel
Employee
278 Views

Development confirmed this was a compiler defect. The compiler is not generating the user defined reduction for the target and this results in the undefined references. I escalated this to our internal tracking system (see id below) and will keep this post updated on the progress of a fix. Unfortunately there was no work around offered at this time but I will share if one comes to light.

(Internal tracking id: DPD200411555)

0 Kudos
Reply