简体   繁体   中英

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 => 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:

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, eg

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM