Hi,
I am having an issue with OpenACC and CUDA interacting.
I have a Fortran code where an array x
is put onto the GPU with
!$acc enter data create(x)
.
Later in the code, this array is sent into a C code that calls CUDA libraries
using an !$acc host_data use_device(x)
region and C_LOC
as:
!$acc host_data use_device(x)
call routine_in_c_code(C_LOC(x(1)))
!$acc end host_data
Now, in the C code, the routine has the signature:
void routine_in_c_code(double* x){
If I use the x
array in CUDA library calls, it works fine:
cusparseDnVecSetValues(DenseVecX,x);
However now I need to modify the array in the C code itself.
I wanted to avoid writing a CUDA kernel, so instead I make an OpenACC loop in the C code:
#pragma acc parallel loop default(present)
for (int i=0;i<N;i++){
<CODE THAT USES x[i]>;
}
The code compiles fine (using nvc
and -acc=gpu
) but the run crashes with:
FATAL ERROR: data in PRESENT clause was not found on device 1: name=x host:0x7f5255400000
Any ideas?
My initial thought is that even though x
is a device pointer,
the OpenACC runtime in the C code does not see it in the present table?
â Ron