Hello,
I am using the icc v14.0.0 compiler and I would like to use the #pragma omp target data directive as described here:
https://software.intel.com/en-us/node/514568
I have made a small example program that, to my eye, looks very similar to the example given in the above link. However, it produces a compile error.
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
int main(int argc, char* argv[])
{
int *a, *b;
a = (int *) malloc(sizeof(int));
b = (int *) malloc(sizeof(int));
*a = 1;
#pragma omp target data map(to:a) map(from:b)
{
#pragma omp target
{
*b = *a;
}
}
printf("%d\n", *b);
return 0;
}The compile error is the following:
$ icc -openmp -o test test.c test.c(13): error: pointer variable "b" in this offload region must be specified in an in/out/inout/nocopy clause #pragma omp target ^ test.c(13): error: pointer variable "a" in this offload region must be specified in an in/out/inout/nocopy clause #pragma omp target ^ compilation aborted for test.c (code 2)
If I remove the 'target data' pragma and move the two map() clauses to the 'target' pragma, it compiles and runs on the target device as expected (according to the OFFLOAD_REPORT output).
What is the correct syntax for using the 'target data' pragma in OpenMP 4.0? How should I modify the above code so that it compiles with the 'target data' pragma?
Thank you for your help!
-Dan