2 arrays in shared memory in Fortran CUDA

Any idea how to achieve this in CUDA Fortran. I want two arrays in shared memory

__global__ void kernel(int aSize)
{
   extern __shared__ float sData[];
   float *a, *b;

   a = sData;
   b = &a[aSize];

Thanks,

Tuan
[/code]

Hi Tuan,

Without EQUIVALENCE or Fortran pointers I can’t think of a good way of doing this. Though can you post what you’re trying to accomplish? Maybe there is another way to solve the problem.

  • Mat

So basically I want to use 2 dynamically allocates shared arrays. In CUDA Fortran, we declare as
integer, dimension(*), shared:: arr1, arr2

Is it correct that arr1 and arr2 all point to the same address?
In CUDA C, shared arrays (in a kernel) with dynamically allocated memory start from the same address in the shared memory.

If arra1 and arr2 point to the same address as in CUDA C, I need a way to tell “first share array use the first OFF elements, and the second share array use the other elements” (OFF is smaller than the size (in bytes) pass to the third argument in the chevron syntax).

Thanks,

Tuan

Is it correct that arr1 and arr2 all point to the same address?

Correct.

If arra1 and arr2 point to the same address as in CUDA C, I need a way to tell “first share array use the first OFF elements, and the second share array use the other elements” (OFF is smaller than the size (in bytes) pass to the third argument in the chevron syntax).

Maybe there are better solutions, but it seems to me the simplest way is to just use arr2[OFF] as the starting element and then index off that, i.e arr2[OFF+idx]

  • Mat

Thanks, Mat. I guess there is no way we can name them as 2 separate variable names in CUDA Fortran, at least for now.


Tuan