我试图在__global__函数中使用数学函数(pow),但是我得到了这个错误:
calling a __host__ function("std::pow<float, double> ") from a __global__ function is not allowed
Run Code Online (Sandbox Code Playgroud)
我试图检查项目属性下的"使用快速数学库"复选框 - >构建 - >设置 - >工具设置 - >优化,没有运气.
我检查了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"
Run Code Online (Sandbox Code Playgroud)
也没有使用命名空间std
有想法该怎么解决这个吗?
您需要更仔细地阅读错误消息.关键信息是
std::pow<float, double>
Run Code Online (Sandbox Code Playgroud)
注意:<float,double>
.您可以pow
使用双精度和单精度参数进行调用.CUDA数学库是通过模板重载选定的标准库函数实现的,但是您的参数没有匹配的重载.修复代码以获得所有双精度或所有单精度参数,并且错误将消失.
归档时间: |
|
查看次数: |
5317 次 |
最近记录: |