0

上下文:我正在尝试使用 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

任何想法我如何解决这个问题。

4

1 回答 1

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)

那行不通,您必须在调用中具有相同的类型。

如果删除接口的表面名称,使接口泛型,您将从编译器获得更直接的错误消息。

于 2014-10-21T15:31:16.653 回答