【问题标题】:Error- a __global__ function call must be configured错误 - 必须配置 __global__ 函数调用
【发布时间】:2021-07-14 13:59:17
【问题描述】:

我正在编写大整数加法、减法、乘法和除法的代码。但是在编译代码时,我收到了这个错误,以及另一个错误error: a __global__ function must have a void return type

代码长 700 行,错误多行。因此,为了方便起见,我附上了我的 Google Colab 笔记本的链接。请查收here

这是我遇到的错误

/content/src/omp_cuda80.cu(94): error: a __global__ function must have a void return type

/content/src/omp_cuda80.cu(139): warning: missing return statement at end of non-void function "addition"

/content/src/omp_cuda80.cu(265): warning: variable "n" was declared but never referenced

/content/src/omp_cuda80.cu(367): error: a __global__ function call must be configured

/content/src/omp_cuda80.cu(381): error: a __global__ function call must be configured

/content/src/omp_cuda80.cu(390): error: a __global__ function call must be configured

/content/src/omp_cuda80.cu(442): error: a __global__ function call must be configured

/content/src/omp_cuda80.cu(456): error: a __global__ function call must be configured

/content/src/omp_cuda80.cu(465): error: a __global__ function call must be configured

/content/src/omp_cuda80.cu(533): error: a __global__ function call must be configured

/content/src/omp_cuda80.cu(538): error: a __global__ function call must be configured

/content/src/omp_cuda80.cu(548): error: a __global__ function call must be configured

/content/src/omp_cuda80.cu(553): error: a __global__ function call must be configured

11 errors detected in the compilation of "/content/src/omp_cuda80.cu".
/bin/bash: /content/src/omp_cuda80: No such file or directory

【问题讨论】:

  • 我认为你需要最基本的 CUDA 教程,因为现在,你只是“猜测”了 CUDA 是如何编写的,不出所料,猜测是错误的。

标签: parallel-processing cuda


【解决方案1】:

如果您使用 __global__ 定义 CUDA 函数,则需要使用语法调用它

function<<<grid,block>>>(param1,param2,...); 

你称他们为

function(param1,param2,...);

这就是你得到 a __global__ function call must be configured的原因。

GPU 函数也不返回值,它们必须返回 void。您可以在指针中获取返回值,并在需要时将其复制到 CPU 进行检查。还有其他方法,但它超出了这个答案的范围。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-03
    • 1970-01-01
    • 2014-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-01
    相关资源
    最近更新 更多