cuda - 在 __global__ 函数中使用 CUDA 数学函数 - Nsight Eclipse 版

标签 cuda

我正在尝试在 __global__ 函数中使用数学函数(pow),但出现此错误:

 calling a __host__ function("std::pow<float, double> ") from a __global__ function is not allowed

我试图检查项目属性->构建->设置->工具设置->优化下的“使用快速数学库”复选框,但没有运气。

我检查了 pow 函数中的类型,它们都是浮点数,我还包含了这些头文件:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <math.h>
#include <sys/times.h>
#include <sys/resource.h>
#include <limits.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include "utils.h"

也没有 using namespace std

有想法该怎么解决这个吗?

最佳答案

您需要更仔细地阅读错误消息。关键信息是

std::pow<float, double>

注:<float,double> .您可以调用pow具有 double 和单精度参数。 CUDA 数学库是通过选定标准库函数的模板重载实现的,但您拥有的参数没有匹配的重载。修复您的代码以具有所有 double 或所有单精度参数,并且错误将消失。

关于cuda - 在 __global__ 函数中使用 CUDA 数学函数 - Nsight Eclipse 版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14760893/

相关文章:

c++ - CUDA复制图像只复制图像的一部分

cuda - "SASS"是什么缩写?

c++ - CUDA Nsight 调试焦点,Visual Studio 2012 版

c++ - CUDA 错误 - 虚函数、继承、新运算符

cuda - 尝试在 Ubuntu 18.04 上安装 CUDA 9.2

cuda内存复制强制对齐

cuda - 在 PyCUDA 中打印消息

CUDA - 在远程计算机上运行 NVVP,在没有启用 CUDA 的设备的本地计算机上显示结果

cuda - 在 LabVIEW 中执行 CUDA

cuda - 在 CUDA 中,非合并内存访问会导致分支发散吗?