Copy a 2D array from host to device

Hello. I allocated memory for a 2D array using

int **Ints;
Ints=(int**)malloc(M*sizeof(int*));
for(j=0;j<M;j++){
Ints[j]=(int*)malloc(N*sizeof(int));
}

where Ints is a global int pointer. The allocation is done in a function. The copy is done in another function

#pragma acc data copy(Ints)

but i get this message.
“PGCC-S-0155-Cannot determine bounds for array Ints”

What could be the problem???

Hi kspan,

“Ints” is an unbounded pointer so the compiler doesn’t know it’s shape. To fix, add the starting element and the number of elements to copy. For example:

#pragma acc data copy(Ints[0:M][0:N])

For details see the OpenACC best practices guide, in particular chapter four’s section on “Shaping Arrays”.




Hope this helps,
Mat

mkcolg, I did what you said and it worked. Thanks mate