C++ 与CUDA/OpenMP兼容的`boost::numeric::odeint::runge_kutta-X`的模板参数

C++ 与CUDA/OpenMP兼容的`boost::numeric::odeint::runge_kutta-X`的模板参数,c++,boost,cuda,odeint,C++,Boost,Cuda,Odeint,我正在使用的stepper类的类型签名总结如下: 它可以按如下方式实例化: boost::numeric::odeint::runge_kutta_dopri5< state_type_ > stepper; boost::numeric::odeint::runge\u kutta\u dopri5步进器; 到目前为止还不错。它起作用了 我计划将我的程序移植到cuda(使用推力),然后再移植到openmp。我将声明更改为以下内容: boost::numeric::odein

我正在使用的stepper类的类型签名总结如下:

它可以按如下方式实例化:

 boost::numeric::odeint::runge_kutta_dopri5< state_type_ > stepper;
boost::numeric::odeint::runge\u kutta\u dopri5步进器;
到目前为止还不错。它起作用了

我计划将我的程序移植到cuda(使用推力),然后再移植到openmp。我将声明更改为以下内容:

boost::numeric::odeint::runge_kutta_dopri5< state_type_
        , double
        , state_type_
        , double
        , boost::numeric::odeint::vector_space_algebra 
        > stepper;
boost::numeric::odeint::runge\u kutta\u dopri5步进机;
我遵循了的解决方案,但这并没有编译

In file included from /usr/include/boost/numeric/odeint/stepper/euler.hpp:26:
/usr/include/boost/numeric/odeint/algebra/default_operations.hpp:87:27: error: invalid operands to binary expression ('double' and 'const std::vector<double, std::allocator<double> >')
            t1 = m_alpha1 * t2 + m_alpha2 * t3;
                 ~~~~~~~~ ^ ~~
包含在/usr/include/boost/numeric/odeint/stepper/euler.hpp:26中的文件中:
/usr/include/boost/numeric/odeint/algebra/default_operations.hpp:87:27:错误:二进制表达式的操作数无效('double'和'const std::vector'))
t1=m_字母1*t2+m_字母2*t3;
~~~~~~~~ ^ ~~

我想知道什么是最可移植的方式来声明stepper,以便在以后移植到cuda时需要最少的更改

这取决于你想做什么。如果要使用推力,需要将声明更改为

boost::numeric::odeint::runge_kutta_dopri5<
    state_type , double , state_type , double ,
    thrust_algebra , thrust_operations >;
boost::numeric::odeint::runge\u kutta\u dopri5<
状态类型,双精度,状态类型,双精度,
推力代数,推力运算>;

推力代数
推力运算
确保在使用压缩迭代器的每个调用中,所有计算都重定向到适当的
推力::for_。如果您想使用在GPU上运行的高级线性代数库(如VexCL或ViennaCL),您可以使用上述声明,只需将
状态类型
更改为正确的类型,例如
VexCL::vector
向量空间代数
假设您的
状态类型
可以处理像
y=a1*x1+a2*x2
这样的操作,由于使用了表达式模板,VexCL和ViennaCL就是这种情况。你也可以看看。

我明白了。这很好。此外,我还添加了使用clang++获得的编译错误消息。我对这个警告一无所知;我使用的是示例代码中的模板类型名。对于第一个声明,我只传递一个模板typename,它工作得很好(事实上,它的性能比现有的GSL integrator稍好)。向量空间代数意味着您可以编写像
a*x+b*y
这样的表达式,这在
Vector
中是不可能的。使用线性代数库,如Eigen!