PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Parallel Prefix Sum on the GPU (Scan)

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



Joined: 24 Feb 2011
Posts: 22

PostPosted: Thu Apr 28, 2011 4:24 am    Post subject: Parallel Prefix Sum on the GPU (Scan) Reply with quote

Hello,

does anybody have a FORTRAN code example for an "up-sweep" of an array that is optimal for the PGI Accelerator Programming Model?

1, 2, 3, 4, 5, 6, 7, 8, 9, ...
1, 1+2, 3, 3+4, 5, 5+6, 7, 7+8, 9,....
...

Thank you!
Back to top
View user's profile
mkcolg



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

PostPosted: Thu Apr 28, 2011 4:00 pm    Post subject: Reply with quote

Hi elephant,

I don't, but maybe someone else does.

Do you have an non-accelerator example source (that's parallel) you could post? Granted, I'm not sure upsweep will work well on a GPU, but having something to start from would be helpful.

- Mat
Back to top
View user's profile
elephant



Joined: 24 Feb 2011
Posts: 22

PostPosted: Fri May 06, 2011 2:40 am    Post subject: Reply with quote

Hi,
The example source for an up-sweep would look something like this:

Code:

do d=0,int(log(dble(N))/log(2.0)-1)
   do i=0,N-1,(2**(d+1))
      T(i+2**(d+1)-1)=T(i+2**d-1)+T(i+2**(d+1)-1)
   end do
end do

Where T is the 1-dim array of size N which entries has to be summed up.

But since I only have to sum up every 8 neighboring entries (sum(1:8), sum(9:16),... ) and not the whole array, I rearanged N to another array Q of size (N/8,8) and wrote a code like the following and got very good speed-up!!!

Code:

!$acc region
   do i=1,N/8
      Qtemp1(i) = Q(i,1)+Q(i,2)+Q(i,3)+Q(i,4)     &
                 +Q(i,5)+Q(i,6)+Q(i,7)+Q(i,8)
   end do    
!$acc end region


So, problem solved.
Thank you!
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