pgi cuda fortran编译错误
pgi cuda fortran compiling error
当我编译单个 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) 上的子例程,在语法上都是不正确的.您可能希望参考此 blog post 作为快速入门指南。
如果你想运行GPU上的子程序increment
,你没有正确调用它:
调用增量(a,b)
GPU 子程序调用需要内核启动参数,这些参数包含在 "triple chevron" <<<...>>>
语法中,应该放在 increment
及其参数列表之间,如下所示:
call increment<<<1,1>>> ( a , b )
这导致了错误消息:
Attempt to call global subroutine without chevrons
相反,如果您打算 运行 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 版本,请从您的程序中删除 all 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
当我编译单个 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) 上的子例程,在语法上都是不正确的.您可能希望参考此 blog post 作为快速入门指南。
如果你想运行GPU上的子程序increment
,你没有正确调用它:
调用增量(a,b)
GPU 子程序调用需要内核启动参数,这些参数包含在 "triple chevron" <<<...>>>
语法中,应该放在 increment
及其参数列表之间,如下所示:
call increment<<<1,1>>> ( a , b )
这导致了错误消息:
Attempt to call global subroutine without chevrons
相反,如果您打算 运行 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 版本,请从您的程序中删除 all 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