本帖最后由 Jackdaw 于 2019-3-15 16:04 编辑
写法有问题吧,可以参考下面两种
[Fortran] 纯文本查看 复制代码 !$acc parallel copyin(mat) private(idx1, idx2, idx3)
!$acc loop
do d = 1, num
do c = 1, num
do b =1, c -1
do a = 1, b -1
idx1 = (d-1)*num**3 + (c-1)*num**2 + (b-1)*num + a
idx2 = (d-1)*num**3 + (a-1)*num**2 + (c-1)*num + b
idx3 = (d-1)*num**3 + (b-1)*num**2 + (a-1)*num + c
tmp = tmp + mat( idx1 ) + mat( idx2 ) + mat( idx3 )
end do
end do
end do
end do
!$acc end loop
!$acc end parallel
[Fortran] 纯文本查看 复制代码 !$acc kernels copyin(mat) private(idx1, idx2, idx3)
do d = 1, num
do c = 1, num
do b =1, c -1
do a = 1, b -1
idx1 = (d-1)*num**3 + (c-1)*num**2 + (b-1)*num + a
idx2 = (d-1)*num**3 + (a-1)*num**2 + (c-1)*num + b
idx3 = (d-1)*num**3 + (b-1)*num**2 + (a-1)*num + c
tmp = tmp + mat( idx1 ) + mat( idx2 ) + mat( idx3 )
end do
end do
end do
end do
!$acc end kernels
|