Would it be possible to provide guidance on thread data concatenation with OpenACC?
I am using OpenACC to accelerate an N-body problem. I am currently trying to solve a problem in which my computational domain is subdivided into a large number of sub-volumes. I have a number of points within the computational domain and am essentially developing a list of which points are in each subvolume. I am looping through all the points and, for each point, determining which subvolume the point is in. I have a three dimensional array which I have called NPIZPL which stores the number of points in each subvolume and an array ZPLIST which lists the point indices.
The issue is that each of the threads have their own instances of NPIZPL and ZPLIST. I would like to find a way of joining these together - concatenating them. There is no requirement for the points to be in any order.
I have simplified my code and pasted it below. This is only looking at one subvolume (index 3,3,3) and 10 points, each of which are assume to lie in subvolume 3,3,3.
On CPU the output is NPIZPL = 10 and NPIZPL = 1,2,3,4,5,6,7,8,9,10
On GPU the output is NPIZPL = 1 and NPIZPL = single integer between 1 and 10.
I would be grateful for any advice you could provide.
Tim.
! --------------------------------------------------------------------
!
! this sub creates zone particle list
!
! --------------------------------------------------------------------
subroutine gpu_zone_data_test()
use memory_allocation
! --------------------------------------------------------------------
! start off by zero-ing arrays
!$acc kernels
NPIZPL(:,:,:) = 0.00
ZPLIST(:,:,:,:) = 0.00
!$acc end kernels
! --------------------------------------------------------------------
!$acc parallel loop
do p = 1,10
NPIZPL(3,3,3) = NPIZPL(3,3,3) + 1
ZPLIST(3,3,3,NPIZPL(3,3,3)) = p
enddo ! p
!$acc wait
!$acc update host(NPIZPL,ZPLIST)
print*,'---------333--------------'
print*,' '
print*,NPIZPL(3,3,3)
print*,' '
print*,ZPLIST(3,3,3,1:NPIZPL(3,3,3))
print*,' '
! -----------------------------------------------------------------
return
end