Test with clang offloading to GPU

Hi,

I’m trying to run some examples using OpenMP offloading to GPU, and I’m having some issues. See this function below:

void doWork(const double *inputData, // the input data
double *outputData) // where computation goes
{
#pragma omp target data map(inputData) map(outputData)
{
#pragma omp target teams distribute parallel for
for (int j=0; j<10; j++)
{
for (int i=0; i< 10; i++)
{
outputData[indx] = inputData[indx];
}
}
}
}

When I try to run this code, I get something like this:

Libomptarget fatal error 1: failure of target construct while offloading is mandatory

This is probably something stupid, sorry about that. It seems that the problem is that the data from inputData is not mapped to the device. Could you please help me with that?

Thanks,
Talita

Seems to me, you want to map arrays but instead you're mapping pointers. Try something like this:

map(to:inputData[0:10]) map(from:outputData[0:10])

Best regards,
Alexey Bataev

Hi Alexey,

Thanks for the reply. I was wondering, what if I have something like this:

void doWork(const double *inputData, // the input data
double *outputData,
int *start[3])

How would I map start? Is there a way?

Thanks,
Talita

Hi Talita,

In your example, "int* start[3] " is no different from other pointers. Think of it as "int** start".
If you want to map nested pointer structures, you can (and for now have to) deconstruct them:

map(start[0:3]) // map outer layer
for ( i = 0 ... 3)
   map(start[i][0:size(i)]) // map inner layer

Is that what you were looking for?

Cheers,
  Johannes