0

我正在尝试在推力算法中使用 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));
  }
};

我一直在仿函数中调用warning: calling a __host__ function from a __host__ __device__ function is not allowed的那一行。ellint_1

我做错了什么还是 boost.math 不适合 GPGPU 使用(因为从我读过的内容来看,我绝对认为是这样)?

4

1 回答 1

1

在限定函数内部调用的任何函数__device__也必须是__device__限定函数。并且boost::math::ellint_1()没有这样的限定词。

请参阅 CUDA 编程指南 B.1。- 函数执行空间说明符 https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#function-declaration-specifiers

而 boost::math 与 boost::compute 无关,后者专注于通用的类似 STL 的算法和容器。

于 2019-06-02T06:49:56.980 回答