我如何在函数中使用boost.com pupute函数,该功能将由推力在GPU上使用

How do I use boost.compute functions in a functor which will be used by Thrust on a GPU?

本文关键字:函数 功能 GPU com boost pupute      更新时间:2023-10-16

我正在尝试使用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的线路。

我是在做错事还是boost。

__device__内部称为__device__的任何功能也必须是CC_5合格的函数。boost::math::ellint_1()没有这样的预选赛。

请参阅CUDA编程指南B.1。 - 功能执行空间指定符https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#function-declaration-declaration-pecifiers

和boost :: Math无关以boost ::计算,后者专注于通用的STL样算法和容器。