PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Updating an array
Goto page Previous  1, 2
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
mkcolg



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

PostPosted: Thu Feb 28, 2013 11:58 am    Post subject: Reply with quote

Hi Sotiris,

Quote:
i have a counter K which tells me how many times my program gets inside this IF statement.
Unfortunately, this isn't parallel since you now have dependency on "k".

What I would recommend is to create a temp array to hold the found values, then perform the reduction into the array sequentially. How beneficial this is will depend upon how computationally intensive the "SOME INDEPENDENT CALCULATIONS" are.

Something like:

Code:
!$acc data region create(value,found), copyout (array)
!$acc kernels
do j=1,L
 array(j) = 0
enddo

!$acc kernels
do j=1,N
 do i= 1,M
 
  !In the beginning SOME INDEPENDENT CALCULATIONS

  found(j,i) = 0
  If (condition) then
   found(j,i) = 1
   value(j,i) = <value>
  end if
 enddo
enddo

!$acc parallel
!$acc loop seq
do j=1,N
 do i= 1,M
    if (found(j,i) .eq 1) then
       k = k+1
       array(k) = value(j,i)
    endif
  enddo
enddo

!$acc end data region


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



Joined: 06 Feb 2011
Posts: 24

PostPosted: Fri Mar 01, 2013 12:49 am    Post subject: Reply with quote

Thank you Mat,

This is exactly what i did as a solution. I can't avoid the sequantial loop. Thabk you very much for your help.

Sotiris
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
Page 2 of 2

 
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