繁体   English   中英

如何在Thrust在GPU上使用的仿函数中使用boost.compute函数?

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

我正在尝试在推力算法中使用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的行上, warning: calling a __host__ function from a __host__ __device__ function is not allowed

我是在做错什么还是boost.math不适合GPGPU使用(因为我读过的书,我绝对认为是这样)?

__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的通用算法和容器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM