[英]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? 确实有可能在CUDA Fortran中分配多个共享数组,而不必求助于仅拥有一个共享数组并使用索引偏移吗?
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 => alldata(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: 从波特兰CUDA Fortran手册中:
These rules apply to device data: 这些规则适用于设备数据:
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, eg
至于其他方式,您可以手动跟踪索引(这似乎是您不想做的),或使用具有3列的矩阵,例如
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.