PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

2 arrays in shared memory in Fortran CUDA

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
Tuan



Joined: 11 Jun 2009
Posts: 233

PostPosted: Mon Nov 22, 2010 4:41 pm    Post subject: 2 arrays in shared memory in Fortran CUDA Reply with quote

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

Code:

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

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


Thanks,

Tuan
[/code]
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6119
Location: The Portland Group Inc.

PostPosted: Wed Nov 24, 2010 5:24 pm    Post subject: Reply with quote

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
Back to top
View user's profile
Tuan



Joined: 11 Jun 2009
Posts: 233

PostPosted: Wed Nov 24, 2010 8:25 pm    Post subject: Reply with quote

mkcolg wrote:
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
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6119
Location: The Portland Group Inc.

PostPosted: Mon Nov 29, 2010 2:56 pm    Post subject: Reply with quote

Quote:
Is it correct that arr1 and arr2 all point to the same address?
Correct.
Quote:

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
Back to top
View user's profile
Tuan



Joined: 11 Jun 2009
Posts: 233

PostPosted: Sat Dec 04, 2010 12:57 am    Post subject: Reply with quote

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
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group