interoperability with C, device data

I have a shared library (written in C) that has a device function which return some data on device memory.

!test.c 
  __device__ int foofunc(uint64_t * somedata, int n)
{
 
! somedata will reside on device memory
}

If I call to this function via interoperability with C from Fortran, my question is "is it possible to have a Fortran pointer (or by any mean) get access directly to this data on device memory.

Tuan

Hi Tuan,

CUDA Fortran device arrays are really just device pointers so all you need to do is pass in the device pointer when you call the CUDA Fortran kernel.

I’m currently working on a sample code which shows how to call CUDA Fortran from CUDA C, and might help you here. I’ll try an finish it up on Monday and post it on a new Accelerator programing FAQ page I’m putting together.

  • Mat

Is that

integer(c_int64_t), device :: somedata



I’m currently working on a sample code which shows how to call CUDA Fortran from CUDA C, and might help you here. I’ll try an finish it up on Monday and post it on a new Accelerator programing FAQ page I’m putting together.

Please add how to call call CUDA C from CUDA Fortran also.

Tuan