Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

Regrding target construct error (mic offload)

psing51
New Contributor I
564 Views

i have started exploring openmp 4.0 constructs for intel xeon phi architecture by writing small code snippets.
So, i wrote the following code:

int a[100],b[100],c[100],i;
#pragma omp  target device(mic0) map(a,b)  //offload target(mic:0)
{
  for(i=0;i<100;i++)
        {
                a=i;b=i;
                c=a+b;

        }
        system("uname -r");
}

but the compilation of this code gives following error:
icc -openmp test.c

test.c(6): error: identifier "mic0" is undefined
 #pragma omp  target device(mic0) map(a,b)  //offload target(mic:0)

but if i change my code as:

#pragma offload target(mic:0)// map(a,b)  //offload target(mic:0)
{
  for(i=0;i<100;i++)
        {
                a=i;b=i;
                c=a+b;

        }
        system("uname -r");
}

 


the compilation succeeds.
What is the reason for this behaviour ? is the #pragma omp target device incorrect  for icc?
Eagerly awaiting your reply


Regards,
Puneet Singh

PS: i can login to my mic0 card using ssh mic0 (passwordless ssh)

0 Kudos
1 Reply
pbkenned1
Employee
564 Views

'#pragma omp  target device()' and '#pragma offload target()' are different offload directives and have different syntax.  For the 'omp' flavor, the argument for 'device' has to be an integer expression, eg:

  int d = f ? omp_get_num_devices () : omp_get_default_device ();
  #pragma omp target device (d)

For the non-omp flavor, the argument to 'device' is considerably more rich: target ( target-name [ :target-number ] ); target-name could be 'mic' or 'gfx', and target-number takes various integer values, eg, -1 lets the runtime system decide the target, as described in the compiler User and Reference Guide.

Patrick

0 Kudos
Reply