mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Thu Feb 28, 2013 11:58 am Post subject: |
|
|
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 |
|