pgi cuda fortran编译错误



当我编译一个cuda fortran代码时,编译器会给我以下错误,PGF90-F-0000-内部编译器错误。设备编译器已退出,返回错误状态代码和尝试在没有V形符的情况下调用全局子例程:递增

arch-linux,pgf90 2013代码如下:

module simple
contains
  attributes (global) subroutine increment(a,b)
    implicit none
    integer, intent(inout) :: a(:)
    integer , intent(in) :: b
    integer :: i , n
    n = size( a )
    do i = 1 , n
       a ( i ) = a ( i )+ b
    end do
  end subroutine increment
end module simple

program incrementTestCPU
  use simple
  implicit none
  integer  :: n = 256
  integer :: a ( n ) , b
  a = 1
  b = 3
  call increment ( a , b )
  if ( any ( a /= 4)) then
     write (* ,*) "pass"
  else
     write(*,*) "not passed"
  end if
end program incrementTestCPU

您将其称为"cuda fortran"代码,但无论您最终是想在主机(CPU)还是设备(GPU)上运行子例程,这在语法上都是不正确的。你可以参考这篇博客文章作为快速入门指南。

如果你想在GPU上运行子程序increment,你没有正确调用它:

呼叫增量(a,b)

GPU子例程调用需要内核启动参数,这些参数包含在"三重V形"<<<...>>>语法中,该语法应位于increment及其参数列表之间,如下所示:

call increment<<<1,1>>> ( a , b )

这就产生了错误消息:

尝试在没有V形的情况下调用全局子程序

相反,如果您打算在CPU上运行此子例程,并且只是将其通过CUDA fortran编译器,那么在子例程上指定global属性是不正确的:

attributes (global) subroutine increment(a,b)

以下是对您的代码的修改,它将在GPU上运行子例程,并使用PGI 14.9工具为我干净地编译:

$ cat test3.cuf
module simple
contains
  attributes (global) subroutine increment(a,b)
    implicit none
    integer :: a(:)
    integer, value :: b
    integer :: i , n
    n = size( a )
    do i = 1 , n
       a ( i ) = a ( i )+ b
    end do
  end subroutine increment
end module simple

program incrementTestCPU
  use simple
  use cudafor
  implicit none
  integer, parameter  :: n = 256
  integer, device :: a_d(n), b_d
  integer :: a ( n ) , b
  a = 1
  b = 3
  a_d = a
  b_d = b
  call increment<<<1,1>>> ( a_d , b_d )
  a = a_d
  if ( any ( a /= 4)) then
     write (* ,*) "pass"
  else
     write(*,*) "not passed"
  end if
end program incrementTestCPU
$ pgf90 -Mcuda -ta=nvidia,cc20,cuda6.5 -Minfo test3.cuf -o test3
incrementtestcpu:
     23, Memory set idiom, loop replaced by call to __c_mset4
     29, any reduction inlined
$ pgf90 --version
pgf90 14.9-0 64-bit target on x86-64 Linux -tp nehalem
The Portland Group - PGI Compilers and Tools
Copyright (c) 2014, NVIDIA CORPORATION.  All rights reserved.
$

如果您试图创建仅限CPU的版本,请从程序中删除所有CUDA Fortran语法。如果您仍然有困难,您可以问一个Fortran指导的问题,因为这不是CUDA的问题。例如,以下(非CUDA)代码为我干净地编译:

module simple
contains
  subroutine increment(a,b)
    implicit none
    integer, intent(inout) :: a(:)
    integer , intent(in) :: b
    integer :: i , n
    n = size( a )
    do i = 1 , n
       a ( i ) = a ( i )+ b
    end do
  end subroutine increment
end module simple

program incrementTestCPU
  use simple
  implicit none
  integer, parameter  :: n = 256
  integer :: a ( n ) , b
  a = 1
  b = 3
  call increment ( a , b )
  if ( any ( a /= 4)) then
     write (* ,*) "pass"
  else
     write(*,*) "not passed"
  end if
end program incrementTestCPU

相关内容

最新更新