在__global__函数中使用CUDA数学函数 - Nsight Eclipse Edition [英] Using CUDA math functions in a __global__ function - Nsight Eclipse Edition

查看:1393
本文介绍了在__global__函数中使用CUDA数学函数 - Nsight Eclipse Edition的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在__global__函数中使用数学函数(pow),但我遇到这个错误:

I am trying to use a math function (pow) in a __global__ function but I get this error :

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

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

and I tried to check the "Make use of fast math library" check box under project properties -> build -> settings -> Tool Settings -> optimization and no luck.

我检查了pow函数内的类型,并且都是浮点数,我还包括这些头文件:

I checked the types inside the pow function and both are floats, and I've also included these header files:

#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"

也没有使用命名空间std

also no using namespace std

有关如何解决此问题的任何想法?

any ideas on how to fix this?

推荐答案

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

You need to read the error message more carefully. The key piece of information is

std::pow<float, double>

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

Note: <float,double>. You have a call to pow with a double precision and a single precision argument. The CUDA math library is implemented by template overloading of selected standard library functions, but the arguments you have don't have a matching overload. Fix you code to have either all double precision or all single precision arguments, and the error will disappear.

这篇关于在__global__函数中使用CUDA数学函数 - Nsight Eclipse Edition的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆