CUDA Fortran: Multiple shared arrays with seperate names?
Is it indeed possible to allocate multiple shared arrays in CUDA Fortran without having to resort to having just one shared array and using index offsetting?
Pointers don't work, the 'pointer' and 'target' attributes conflict with the 'shared' attribute.
This is what I want to acheive:
attributes(global) subroutine shared_sub_arrays()
integer :: i
real, shared, dimension(*), target :: alldata
real, shared, dimension(:), pointer :: left
real, shared, dimension(:), pointer :: centre
real, shared, dimension(:), pointer :: right
i = threadIdx%x
left => alldata(1:3)
centre => 开发者_如何学Pythonalldata(4:6)
right => alldata(7:9)
left(i) = 1.0
centre(i) = 2.0
right(i) = 3.0
end subroutine shared_sub_arrays
Does anyone know of another way to do this?
Thanks in advance for the help
From the Portland CUDA Fortran manual:
These rules apply to device data:
- Device variables and arrays may not have the Pointer or Target attributes.
So I guess that's just not possible. As for other ways to do it, you could manually keep track of the indices (which seems you don't want to do), or use a matrix with 3 columns, e.g.
real, shared, dimension(:,:) :: alldata
allocate(data(N,3))
! name indices
left=1
centre=2
right=3
! access the columns
alldata(i,left)
alldata(i,centre)
alldata(i,right)
精彩评论