PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

how to avoid the global memory latency in selection

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



Joined: 01 Jul 2005
Posts: 5

PostPosted: Thu Oct 13, 2011 8:03 pm    Post subject: how to avoid the global memory latency in selection Reply with quote

Dear All,

I try to select, nforc, datas from a array, w(ndata) if its element is larger than the value, tol,

my code is (in which 256 threads are used):

Code:

       real*8, device :: w(n), blk(100*256)

         isub=threadidx%x
        ipx=(isub-1)*100

         iforc=0
         do i=isub,ndata,256
            if(w(il).gt.tol) then
               iforc=iforc+1
               blk(ipx+ijforc)=i
              endif
          enddo

          nsav(isub)=iforc
          call syncthreads()


However, I found most time used is the statement

blk(ipx+ijforc)=i

I seems the problem is due to the global memory latency.

Does anyone have a better solution ?

Thanks in advance

Minghui
Back to top
View user's profile
mkcolg



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

PostPosted: Fri Oct 14, 2011 12:52 pm    Post subject: Reply with quote

Hi yangmh,

It's not the latency. Rather, it's that the data is not contiguous across threads in a warp leading to memory divergence. To fix, you'll need to change your algorithm so that blk can be accessed using "i" instead of "ipx+ijforce".

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



Joined: 01 Jul 2005
Posts: 5

PostPosted: Sun Oct 16, 2011 4:21 pm    Post subject: Reply with quote

Hi, Mat,

Thanks for your help !

That means, If the array w(ndata) is divided into several parts, each of them is treated in shared memory, the memory divergence could be avoided ?

Minghui
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