gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 22:50:36 25 4
gpt4 key购买 nike

我正在尝试在 __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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com