PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

data locally defined in a kernel
Goto page Previous  1, 2, 3  Next
 
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: Wed Feb 17, 2010 9:07 pm    Post subject: Reply with quote

mkcolg wrote:
Hi Tuan,

They would be placed in global memory by default.

- Mat


It seems that "local" is not an attribute to indicate a thread private variable (to reside on processor registers). Is that using "value" attribute correct?

Thanks,
Tuan
Back to top
View user's profile
mkcolg



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

PostPosted: Thu Feb 18, 2010 9:41 pm    Post subject: Reply with quote

No, 'value' mean to pass by value. There currently isn't a way for the user to request that a variable be placed in a register. I'll put in a feature request.

- Mat
Back to top
View user's profile
goblinsqueen



Joined: 04 Feb 2010
Posts: 14

PostPosted: Fri Mar 05, 2010 7:14 am    Post subject: Reply with quote

If I understood correctly, all the variables declared in a device routine are saved in the device global memory.
The following is a part of code taken from the PGI CUDA Fortran Programming Guide
Code:

attributes(global) subroutine mmul_kernel( A, B, C, N, M, L )
real :: A(N,M), B(M,L), C(N,L)
integer, value :: N, M, L
integer :: i, j, kb, k, tx, ty
! submatrices stored in shared memory
real, shared :: Asub(16,16), Bsub(16,16)
! the value of C(i,j) being computed
real :: Cij
! Get the thread indices
tx = threadidx%x
ty = threadidx%y
! This thread computes C(i,j) = sum(A(i,:) * B(:,j))
i = (blockidx%x-1) * 16 + tx
j = (blockidx%y-1) * 16 + ty
Cij = 0.0
[ other code]


My question is: if i, j, Cij, and so on, are in the global device memory, and therefore are not private to each thread, why there aren't data races or other problems accessing the same place in memory?

I'm writing some programs in CUDA fortran and I don't understand when a variable is private to a single thread (and if it is possible).

Thank you
Back to top
View user's profile
mkcolg



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

PostPosted: Fri Mar 05, 2010 10:12 am    Post subject: Reply with quote

Hi goblinsqueen,

By 'global', I meant by default the local variables will be placed in the device memory (i.e. global memory). This does not mean that these variables have a global scope. Rather, each thread will have it's own private copy of the local variables.

Also, some variables may be placed in a multi-processor's local memory (i.e. it's registers). However, you the programmer do not have control over this. It ultimately up to the NVIDA tools to determine exactly where the variable is stored.

Hope this helps,
Mat
Back to top
View user's profile
goblinsqueen



Joined: 04 Feb 2010
Posts: 14

PostPosted: Mon Mar 08, 2010 4:14 am    Post subject: Reply with quote

Thank you Mat,
now it's clearer.
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
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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