PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

traversing array

 
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 5:36 pm    Post subject: traversing array Reply with quote

I know that Fortran store array in column-major while C store array in row-major. So, with the current implementation of CUDA Fortran, as I may call C CUDA to do the computation, I'm not sure if between the two following code (one access row-based, and one use column-based), basically, which one should work faster with CUDA Fortran (given that M, N big enough)

Code:
real, device, dimension(M, N) :: Ab

attributes(global) subroutine dosomething()

 do i =1, M
  do j = 1,N
   A(i,j) = A(i,j) * (i+j)
 endo
enddo
end subroutine


Code:
real, device, dimension(M, N) :: Ab

attributes(global) subroutine dosomething()
   do j =1, N
      do i = 1,M
        A(i,j)=A(i,j) * (i+j)
     endo
   enddo
end subroutine


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



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

PostPosted: Fri Feb 19, 2010 3:07 pm    Post subject: Reply with quote

Hi Tuan,

Sorry, I missed this post earlier.

I would keep it column major here.

- Mat
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