pgi cuda fortran编译错误 [英] pgi cuda fortran compiling error

查看:318
本文介绍了pgi cuda fortran编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译一个单独的cuda fortran代码,编译器给我以下错误,
PGF90-F-0000-内部编译器错误。设备编译器退出时带有错误状态代码和
尝试调用没有chevrons的全局子例程:increment



arch linux,pgf90 2013
代码如下:

 模块简单
包含
属性(全局)子程序增量(a,b)
implicit none
integer,intent(inout):: a(:)
integer,intent(in):: b
integer :: i,n
n = size )
do i = 1,n
a(i)= a(i)+ b
end do
结束子程序增量
结束模块简单
b
$ b程序incrementTestCPU
使用简单
implicit none
integer :: n = 256
integer :: a(n),b
a = 1
b = 3
调用增量(a,b)
if(any(a / = 4))then
write(*,*)pass

write(*,*)not passed
end if
结束程序incrementTestCPU


<你称这是一个cuda fortran代码,但是在语法上是否要最终在主机(CPU)或设备上运行子例程是不正确的(

GPU)。您可以参考此博文作为快速入门指南。



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



调用增量(a,b)



GPU子程序调用需要内核启动参数,三角形<< ...>>> 语法,应该放在 increment 及其参数列表,如下:

 调用增量<< 1,1> (a,b)

这会导致错误信息:


尝试调用没有chevrons的全局子程序


你打算在CPU上运行这个子程序,只是将它传递给CUDA Fortran编译器,那么在子程序中指定 global 属性是不正确的:

 属性(全局)子程序增量(a,b)

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

  $ cat test3.cuf 
模块简单
包含
属性(全局)子程序增量(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
结束子程序增量
结束模块简单


程序incrementTestCPU
使用简单
使用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
调用增量<< 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,内存集成语,循环由调用__c_mset4
替换29,任何减少内联
$ pgf90 --version

pgf90 14.9-0 x86-64上的64位目标Linux -tp nehalem
波特兰集团 - PGI编译器和工具
版权所有(c)2014,NVIDIA CORPORATION。版权所有。
$

如果您尝试创建一个仅限CPU的版本, > all CUDA Fortran语法。如果你仍然有困难,你可以问一个Fortran导向的问题,因为它不是一个CUDA问题在那一点。例如,以下(非CUDA)代码为我编译干净:

 模块简单
包含
子程序增量(a,b)
隐含无
整数,意图(inout):: a(:)
整数,意向(in):: b
integer: :i,n
n = size(a)
do i = 1,n
a(i)= a(i)+ b
end do
结束子程序增量
结束模块简单


程序incrementTestCPU
使用简单
implicit none
integer,parameter :: n = 256
integer :: a(n),b
a = 1
b = 3
调用增量(a,b)
if(any(a / = 4))then
写(*,*)pass
else
write(*,*)not passed
end if
结束程序incrementTestCPU


As I compile a single cuda fortran code , the compiler give me the following error, PGF90-F-0000-Internal compiler error. Device compiler exited with error status code and Attempt to call global subroutine without chevrons: increment

arch linux, pgf90 2013 the code is as follow:

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

解决方案

You're calling this a "cuda fortran" code, but it is syntactically incorrect whether you want to ultimately run the subroutine on the host (CPU) or device (GPU). You may wish to refer to this blog post as a quick start guide.

If you want to run the subroutine increment on the GPU, you have not called it correctly:

call increment ( a , b )

A GPU subroutine call needs kernel launch parameters, which are contained in the "triple chevron" <<<...>>> syntax which should be placed between the increment and its parameter list, like so:

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

and this is giving rise to the error message:

Attempt to call global subroutine without chevrons

If, instead, you intend to run this subroutine on the CPU, and are just passing it through the CUDA fortran compiler, then it is incorrect to specify the global attribute on the subroutine:

attributes (global) subroutine increment(a,b)

The following is a modification of your code which would run the subroutine on the GPU, and compiles cleanly for me with PGI 14.9 tools:

$ 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.
$

If you are trying to create a CPU-only version, then remove all CUDA Fortran syntax from your program. If you still have difficulty, you can ask a Fortran-directed question, as it is not a CUDA issue at that point. As an example, the following (non-CUDA) code compiled cleanly for me:

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

这篇关于pgi cuda fortran编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆