File indexing completed on 2025-01-18 09:42:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_VIENNACL_VIENNACL_OPERATIONS_HPP_INCLUDED
0020 #define BOOST_NUMERIC_ODEINT_EXTERNAL_VIENNACL_VIENNACL_OPERATIONS_HPP_INCLUDED
0021
0022 #include <viennacl/vector.hpp>
0023
0024 #ifdef VIENNACL_WITH_OPENCL
0025 # include <viennacl/generator/custom_operation.hpp>
0026 #endif
0027
0028 namespace boost {
0029 namespace numeric {
0030 namespace odeint {
0031
0032
0033 #ifdef VIENNACL_WITH_OPENCL
0034 struct viennacl_operations
0035 {
0036
0037 template< class Fac1 = double , class Fac2 = Fac1 >
0038 struct scale_sum2
0039 {
0040 const Fac1 m_alpha1;
0041 const Fac2 m_alpha2;
0042
0043 scale_sum2( Fac1 alpha1 , Fac2 alpha2 )
0044 : m_alpha1( alpha1 ) , m_alpha2( alpha2 )
0045 { }
0046
0047 template< class T1 , class T2 , class T3 >
0048 void operator()( viennacl::vector<T1> &v1 ,
0049 const viennacl::vector<T2> &v2 ,
0050 const viennacl::vector<T3> &v3
0051 ) const
0052 {
0053 using namespace viennacl;
0054
0055 static generator::symbolic_vector <0, T1> sym_v1;
0056 static generator::symbolic_vector <1, T2> sym_v2;
0057 static generator::symbolic_vector <2, T3> sym_v3;
0058 static generator::cpu_symbolic_scalar<3, Fac1> sym_a1;
0059 static generator::cpu_symbolic_scalar<4, Fac2> sym_a2;
0060
0061 static generator::custom_operation op(
0062 sym_v1 = sym_a1 * sym_v2
0063 + sym_a2 * sym_v3,
0064 "scale_sum2"
0065 );
0066
0067 ocl::enqueue( op(v1, v2, v3, m_alpha1, m_alpha2) );
0068 }
0069
0070 typedef void result_type;
0071 };
0072
0073
0074 template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 >
0075 struct scale_sum3
0076 {
0077 const Fac1 m_alpha1;
0078 const Fac2 m_alpha2;
0079 const Fac3 m_alpha3;
0080
0081 scale_sum3( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 )
0082 : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 )
0083 { }
0084
0085 template< class T1 , class T2 , class T3 , class T4 >
0086 void operator()( viennacl::vector<T1> &v1 ,
0087 const viennacl::vector<T2> &v2 ,
0088 const viennacl::vector<T3> &v3 ,
0089 const viennacl::vector<T4> &v4
0090 ) const
0091 {
0092 using namespace viennacl;
0093
0094 static generator::symbolic_vector <0, T1> sym_v1;
0095 static generator::symbolic_vector <1, T2> sym_v2;
0096 static generator::symbolic_vector <2, T3> sym_v3;
0097 static generator::symbolic_vector <3, T4> sym_v4;
0098 static generator::cpu_symbolic_scalar<4, Fac1> sym_a1;
0099 static generator::cpu_symbolic_scalar<5, Fac2> sym_a2;
0100 static generator::cpu_symbolic_scalar<6, Fac3> sym_a3;
0101
0102 static generator::custom_operation op(
0103 sym_v1 = sym_a1 * sym_v2
0104 + sym_a2 * sym_v3
0105 + sym_a3 * sym_v4,
0106 "scale_sum3"
0107 );
0108
0109 ocl::enqueue( op(v1, v2, v3, v4, m_alpha1, m_alpha2, m_alpha3) );
0110 }
0111
0112 typedef void result_type;
0113 };
0114
0115
0116 template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 >
0117 struct scale_sum4
0118 {
0119 const Fac1 m_alpha1;
0120 const Fac2 m_alpha2;
0121 const Fac3 m_alpha3;
0122 const Fac4 m_alpha4;
0123
0124 scale_sum4( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 )
0125 : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) { }
0126
0127 template< class T1 , class T2 , class T3 , class T4 , class T5 >
0128 void operator()( viennacl::vector<T1> &v1 ,
0129 const viennacl::vector<T2> &v2 ,
0130 const viennacl::vector<T3> &v3 ,
0131 const viennacl::vector<T4> &v4 ,
0132 const viennacl::vector<T5> &v5
0133 ) const
0134 {
0135 using namespace viennacl;
0136
0137 static generator::symbolic_vector <0, T1> sym_v1;
0138 static generator::symbolic_vector <1, T2> sym_v2;
0139 static generator::symbolic_vector <2, T3> sym_v3;
0140 static generator::symbolic_vector <3, T4> sym_v4;
0141 static generator::symbolic_vector <4, T5> sym_v5;
0142 static generator::cpu_symbolic_scalar<5, Fac1> sym_a1;
0143 static generator::cpu_symbolic_scalar<6, Fac2> sym_a2;
0144 static generator::cpu_symbolic_scalar<7, Fac3> sym_a3;
0145 static generator::cpu_symbolic_scalar<8, Fac4> sym_a4;
0146
0147 static generator::custom_operation op(
0148 sym_v1 = sym_a1 * sym_v2
0149 + sym_a2 * sym_v3
0150 + sym_a3 * sym_v4
0151 + sym_a4 * sym_v5,
0152 "scale_sum4"
0153 );
0154
0155 ocl::enqueue( op(v1, v2, v3, v4, v5,
0156 m_alpha1, m_alpha2, m_alpha3, m_alpha4) );
0157 }
0158
0159 typedef void result_type;
0160 };
0161
0162
0163 template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 >
0164 struct scale_sum5
0165 {
0166 const Fac1 m_alpha1;
0167 const Fac2 m_alpha2;
0168 const Fac3 m_alpha3;
0169 const Fac4 m_alpha4;
0170 const Fac5 m_alpha5;
0171
0172 scale_sum5( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , Fac5 alpha5 )
0173 : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) { }
0174
0175 template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 >
0176 void operator()( viennacl::vector<T1> &v1 ,
0177 const viennacl::vector<T2> &v2 ,
0178 const viennacl::vector<T3> &v3 ,
0179 const viennacl::vector<T4> &v4 ,
0180 const viennacl::vector<T5> &v5 ,
0181 const viennacl::vector<T6> &v6
0182 ) const
0183 {
0184 using namespace viennacl;
0185
0186 static generator::symbolic_vector < 0, T1> sym_v1;
0187 static generator::symbolic_vector < 1, T2> sym_v2;
0188 static generator::symbolic_vector < 2, T3> sym_v3;
0189 static generator::symbolic_vector < 3, T4> sym_v4;
0190 static generator::symbolic_vector < 4, T5> sym_v5;
0191 static generator::symbolic_vector < 5, T6> sym_v6;
0192 static generator::cpu_symbolic_scalar< 6, Fac1> sym_a1;
0193 static generator::cpu_symbolic_scalar< 7, Fac2> sym_a2;
0194 static generator::cpu_symbolic_scalar< 8, Fac3> sym_a3;
0195 static generator::cpu_symbolic_scalar< 9, Fac4> sym_a4;
0196 static generator::cpu_symbolic_scalar<10, Fac5> sym_a5;
0197
0198 static generator::custom_operation op(
0199 sym_v1 = sym_a1 * sym_v2
0200 + sym_a2 * sym_v3
0201 + sym_a3 * sym_v4
0202 + sym_a4 * sym_v5
0203 + sym_a5 * sym_v6,
0204 "scale_sum5"
0205 );
0206
0207 ocl::enqueue( op(v1, v2, v3, v4, v5, v6,
0208 m_alpha1, m_alpha2, m_alpha3, m_alpha4, m_alpha5) );
0209 }
0210
0211 typedef void result_type;
0212 };
0213
0214
0215 };
0216 #else
0217 struct viennacl_operations : public default_operations {};
0218 #endif
0219
0220
0221 }
0222 }
0223 }
0224
0225
0226 #endif