0

我需要使用 OpenACC 检测 Fortran 代码。以下是相关部分:

program myprogram


real :: x(160,100,100,8)
!$acc declare create(x(:,:,:,:))
integer, parameter :: ns1=1
integer, parameter :: ns2=8
integer, parameter :: nx=160
!$acc declare create(ns1,ns2,nx)   ! apparently I don't need this line?

! lots of stuff happens to define x and plenty of
! other things, then …

subroutine myroutine(id1,id2)

real xin(160,8)

!$acc update device(x(:,:,:,:))

!$acc data copyin(id1,id2,taskid) create(xin(:,:))

!debug
      print *, 'in dat',taskid,x(80,id1,id2,1),x(81,id1,id2,1),x(82,id1,id2,1)
! define new arrays for velocity and density

!$acc parallel num_gangs(8) vector_length(160)
!debug
      print *, 'in par',taskid,x(80,id1,id2,1),x(81,id1,id2,1),x(82,id1,id2,1)

!$acc loop gang
      do ni = ns1,ns2
!$acc loop vector
        do i = 1,nx
          xin(i,ni) = x(i,id1,id2,ni)
        enddo
      enddo
!debug
      print *, 'xin vals',taskid,xin(80,1),xin(81,1),xin(82,1)

!$acc end parallel

!$acc end data

end subroutine


end program

当我检查“in dat”行和“in par”行的输出时,这些数字看起来很合理。当我检查“xin vals”行时,我看到了几个 NaN。不是所有的 NaN,而是几个。xin的任务就是这么简单!可能出了什么问题?(如果你没有猜到,我对 OpenACC 还是很陌生。谢谢。)

编辑:这是用 PGI Fortran 编译的。

4

1 回答 1

0

不知道你的编译器(你没有说是哪一个)在做什么,但print在一个parallel区域内实现肯定是不平凡的。如果将调试prints 移到并行区域之外(data实际上是在区域之外),您会看到什么结果?然后,create(xin(:,:))您将不想使用copyout子句,以便您可以在data区域之后检查主机上的数据。

于 2016-03-18T13:46:32.603 回答