上下文:我尝试使用CURAND在GPU上进行伪随机数生成,但由于我使用CUDA fortran,我必须创建一个接口模块,它接口用C编写的CURAND LIBRARY函数这是界面代码:
interface curand_init
attributes(device) subroutine curand_init(seed,sequence,offset,state) &
bind(C,name='curand_init')
use iso_c_binding
integer(c_long_long),value :: seed
integer(c_long_long),value :: sequence
integer(c_long_long),value :: offset
!pgi$ ignore_tr state
real(c_float), device :: state(*)
end subroutine curand_init
end interface curand_init
interface curand
attributes(device) subroutine curand(state) &
bind(C,name='curand')
use iso_c_binding
!pgi$ ignore_tr state
real(c_float),device :: state(*)
end subroutine curand
end interface curand
interface curand_uniform
attributes(device) subroutine curand_uniform(state) &
bind(C,name='curand_uniform')
use iso_c_binding
!pgi$ ignore_tr state
real(c_float),device :: state(*)
end subroutine curand_uniform
attributes(device) subroutine curand_uniform_double(state) &
bind(C,name='curand_uniform_double')
use iso_c_binding
!pgi$ ignore_tr state
real(c_double),device :: state(*)
end subroutine curand_uniform_double
end interface curand_uniform
interface curand_normal
attributes(device) subroutine curand_normal(state) &
bind(C,name='curand_normal')
use iso_c_binding
!pgi$ ignore_tr state
real(c_float),device :: state(*)
end subroutine curand_normal
attributes(device) subroutine curand_normal_double(state) &
bind(C,name='curand_normal_double')
use iso_c_binding
!pgi$ ignore_tr state
real(c_double),device :: state(*)
end subroutine curand_normal_double
end interface curand_normal
在同一模块中,我在全局内核中调用此设备子例程call curand_init(seed,id,0,tmpconf)
。当我调用全局内核时,我收到此错误。
gpu_gen_m.CUF:
PGF90-S-0155-Could not resolve generic procedure curand_init (gpu_gen_m.CUF: 99)
0 inform, 0 warnings, 1 severes, 0 fatal for gen_conf
任何想法我如何解决这个问题。
答案 0 :(得分:1)
在您拥有的界面中
integer(c_long_long),value :: seed
integer(c_long_long),value :: sequence
integer(c_long_long),value :: offset
!pgi$ ignore_tr state
real(c_float), device :: state(*)
但在你使用的电话中
两次integer(kind=int_ptr_kind ())
,一次integer
和一次real(fp_kind)
这不起作用,您必须在通话中使用相同的类型。
如果删除接口的表面名称(使接口成为通用名称),您将从编译器获得更直接的错误消息。