簡體   English   中英

CUDA Fortran:具有單獨名稱的多個共享陣列?

[英]CUDA Fortran: Multiple shared arrays with seperate names?

確實有可能在CUDA Fortran中分配多個共享數組,而不必求助於僅擁有一個共享數組並使用索引偏移嗎?

指針不起作用,“指針”和“目標”屬性與“共享”屬性沖突。

這就是我要實現的目標:

  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

有人知道這樣做的另一種方法嗎?

先謝謝您的幫助

從波特蘭CUDA Fortran手冊中:

這些規則適用於設備數據:

  • 設備變量和數組可能沒有Pointer或Target屬性。

所以我想那是不可能的。 至於其他方式,您可以手動跟蹤索引(這似乎是您不想做的),或使用具有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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM