【发布时间】:2019-09-21 03:11:19
【问题描述】:
我正在尝试在推力算法中使用 boost.math 提供的特殊函数。
基本上,我想做一个转换,像这样
thrust::device_vector<double> in(1000);
thrust::device_vector<double> out(1000);
thrust::transform(in.begin(), in.end(), out.begin(), myfunctor());
myfunctor() 由下式给出
#include <boost/math/special_functions/ellint_1.hpp>
.
.
.
struct myfunctor {
__host__ __device__
double operator()(double k) {
return boost::math::ellint_1(sqrt(k));
}
};
我不断在仿函数中调用ellint_1 的那一行得到warning: calling a __host__ function from a __host__ __device__ function is not allowed。
是我做错了什么还是 boost.math 不适合 GPGPU 使用(因为从我所读的内容来看,我确实认为它是)?
【问题讨论】:
-
我现在无法测试或检查,但问题可能出在
sqrt。 -
Boost.compute 是OpenCL 的助手。一个example 当 NVIDEA Thrust 是类似的助手但用于CUDA API。 boost::math - 是一个 CPU 库。
-
所以,我在设备代码中使用了 CPU 库。不知道我是怎么错过的。我只是搜索了可用于设备代码的此类特殊功能,但似乎找不到任何东西。你会碰巧知道什么吗?
-
您似乎需要通过 OpenCL 或 CUDA 内核实现第一类 Legendre 完全椭圆积分。或者找到一个现有的 GPGPU 实现并使用它。
标签: c++ boost gpgpu thrust boost-compute