OpenFPM  5.2.0
Project that contain the implementation of distributed structures
vector_algebra_ofp_gpu.hpp
1 //
2 // Created by Abhinav Singh on 1.03.23.
3 //
4 
5 #ifndef OPENFPM_PDATA_VECTOR_ALGEBRA_OFP_GPU_HPP
6 #define OPENFPM_PDATA_VECTOR_ALGEBRA_OFP_GPU_HPP
7 
8 namespace boost {
9  namespace numeric {
10  namespace odeint {
11 
12  template<typename S1, typename Op>
13  __global__ void for_each1_ker(S1 s1, Op op)
14  {
15  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
16 
17  if (p >= s1.data.size()) {return;}
18 
19  for_each_prop1<S1,size_t,Op> cp(s1,p,op);
20  //creating an iterator on v_ids[0] [1] [2]
21  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
22  }
23 
24  template<typename S1,typename S2, typename Op>
25  __global__ void for_each2_ker(S1 s1,S2 s2, Op op)
26  {
27  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
28 
29  if (p >= s1.data.template get<0>().size()) {return;}
30  //printf("%f \n",s2.data.template get<0>().getVector().template get<0>(p));
31  //converting to boost vector ids.
32  for_each_prop2<S1,S2,unsigned int,Op> cp(s1,s2,p,op);
33  //s1.data.template get<0>().getVector().template get<0>(p)=1.0*s2.data.template get<0>().getVector().template get<0>(p)+0.05*s3.data.template get<0>().getVector().template get<0>(p);
34  //creating an iterator on v_ids[0] [1] [2]
35  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
36  }
37 
38  template<typename S1,typename S2,typename S3, typename Op>
39  __global__ void for_each3_ker(S1 s1,S2 s2,S3 s3, Op op)
40  {
41  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
42 
43  if (p >= s1.data.template get<0>().size()) {return;}
44  //printf("%f \n",s2.data.template get<0>().getVector().template get<0>(p));
45  //converting to boost vector ids.
46  for_each_prop3<S1,S2,S3,unsigned int,Op> cp(s1,s2,s3,p,op);
47  //s1.data.template get<0>().getVector().template get<0>(p)=1.0*s2.data.template get<0>().getVector().template get<0>(p)+0.05*s3.data.template get<0>().getVector().template get<0>(p);
48  //creating an iterator on v_ids[0] [1] [2]
49  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
50  }
51 
52  template<typename S1,typename S2,typename S3,typename S4, typename Op>
53  __global__ void for_each4_ker(S1 s1,S2 s2,S3 s3,S4 s4, Op op)
54  {
55  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
56 
57  if (p >= s1.data.template get<0>().size()) {return;}
58  //printf("%f \n",s2.data.template get<0>().getVector().template get<0>(p));
59  //converting to boost vector ids.
60  for_each_prop4<S1,S2,S3,S4,unsigned int,Op> cp(s1,s2,s3,s4,p,op);
61  //s1.data.template get<0>().getVector().template get<0>(p)=1.0*s2.data.template get<0>().getVector().template get<0>(p)+0.05*s3.data.template get<0>().getVector().template get<0>(p);
62  //creating an iterator on v_ids[0] [1] [2]
63  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
64  }
65 
66  template<typename S1,typename S2,typename S3,typename S4,typename S5, typename Op>
67  __global__ void for_each5_ker(S1 s1,S2 s2,S3 s3,S4 s4,S5 s5, Op op)
68  {
69  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
70 
71  if (p >= s1.data.template get<0>().size()) {return;}
72  //printf("%f \n",s2.data.template get<0>().getVector().template get<0>(p));
73  //converting to boost vector ids.
74  for_each_prop5<S1,S2,S3,S4,S5,unsigned int,Op> cp(s1,s2,s3,s4,s5,p,op);
75  //s1.data.template get<0>().getVector().template get<0>(p)=1.0*s2.data.template get<0>().getVector().template get<0>(p)+0.05*s3.data.template get<0>().getVector().template get<0>(p);
76  //creating an iterator on v_ids[0] [1] [2]
77  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
78  }
79 
80  template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6, typename Op>
81  __global__ void for_each6_ker(S1 s1,S2 s2,S3 s3,S4 s4,S5 s5,S6 s6, Op op)
82  {
83  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
84 
85  if (p >= s1.data.template get<0>().size()) {return;}
86  //converting to boost vector ids.
87  for_each_prop6<S1,S2,S3,S4,S5,S6,unsigned int,Op> cp(s1,s2,s3,s4,s5,s6,p,op);
88  //creating an iterator on v_ids[0] [1] [2]
89  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
90  }
91  template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7, typename Op>
92  __global__ void for_each7_ker(S1 s1,S2 s2,S3 s3,S4 s4,S5 s5,S6 s6,S7 s7, Op op)
93  {
94  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
95 
96  if (p >= s1.data.template get<0>().size()) {return;}
97  //converting to boost vector ids.
98  for_each_prop7<S1,S2,S3,S4,S5,S6,S7,unsigned int,Op> cp(s1,s2,s3,s4,s5,s6,s7,p,op);
99  //creating an iterator on v_ids[0] [1] [2]
100  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
101  }
102  template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8, typename Op>
103  __global__ void for_each8_ker(S1 s1,S2 s2,S3 s3,S4 s4,S5 s5,S6 s6,S7 s7,S8 s8, Op op)
104  {
105  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
106 
107  if (p >= s1.data.template get<0>().size()) {return;}
108  //converting to boost vector ids.
109  for_each_prop8<S1,S2,S3,S4,S5,S6,S7,S8,unsigned int,Op> cp(s1,s2,s3,s4,s5,s6,s7,s8,p,op);
110  //creating an iterator on v_ids[0] [1] [2]
111  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
112  }
113  template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8,typename S9, typename Op>
114  __global__ void for_each9_ker(S1 s1,S2 s2,S3 s3,S4 s4,S5 s5,S6 s6,S7 s7,S8 s8,S9 s9, Op op)
115  {
116  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
117 
118  if (p >= s1.data.template get<0>().size()) {return;}
119  //converting to boost vector ids.
120  for_each_prop9<S1,S2,S3,S4,S5,S6,S7,S8,S9,unsigned int,Op> cp(s1,s2,s3,s4,s5,s6,s7,s8,s9,p,op);
121  //creating an iterator on v_ids[0] [1] [2]
122  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
123  }
124  template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8,typename S9,typename S10, typename Op>
125  __global__ void for_each10_ker(S1 s1,S2 s2,S3 s3,S4 s4,S5 s5,S6 s6,S7 s7,S8 s8,S9 s9,S10 s10, Op op)
126  {
127  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
128 
129  if (p >= s1.data.template get<0>().size()) {return;}
130  //converting to boost vector ids.
131  for_each_prop10<S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,unsigned int,Op> cp(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,p,op);
132  //creating an iterator on v_ids[0] [1] [2]
133  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
134  }
135  template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8,typename S9,typename S10,typename S11, typename Op>
136  __global__ void for_each11_ker(S1 s1,S2 s2,S3 s3,S4 s4,S5 s5,S6 s6,S7 s7,S8 s8,S9 s9,S10 s10,S11 s11, Op op)
137  {
138  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
139 
140  if (p >= s1.data.template get<0>().size()) {return;}
141  //converting to boost vector ids.
142  for_each_prop11<S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,unsigned int,Op> cp(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,p,op);
143  //creating an iterator on v_ids[0] [1] [2]
144  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
145  }
146  template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8,typename S9,typename S10,typename S11,typename S12, typename Op>
147  __global__ void for_each12_ker(S1 s1,S2 s2,S3 s3,S4 s4,S5 s5,S6 s6,S7 s7,S8 s8,S9 s9,S10 s10,S11 s11,S12 s12, Op op)
148  {
149  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
150 
151  if (p >= s1.data.template get<0>().size()) {return;}
152  //converting to boost vector ids.
153  for_each_prop12<S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,unsigned int,Op> cp(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,p,op);
154  //creating an iterator on v_ids[0] [1] [2]
155  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
156  }
157  template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8,typename S9,typename S10,typename S11,typename S12,typename S13, typename Op>
158  __global__ void for_each13_ker(S1 s1,S2 s2,S3 s3,S4 s4,S5 s5,S6 s6,S7 s7,S8 s8,S9 s9,S10 s10,S11 s11,S12 s12,S13 s13, Op op)
159  {
160  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
161 
162  if (p >= s1.data.template get<0>().size()) {return;}
163  //converting to boost vector ids.
164  for_each_prop13<S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,unsigned int,Op> cp(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,p,op);
165  //creating an iterator on v_ids[0] [1] [2]
166  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
167  }
168  template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8,typename S9,typename S10,typename S11,typename S12,typename S13,typename S14, typename Op>
169  __global__ void for_each14_ker(S1 s1,S2 s2,S3 s3,S4 s4,S5 s5,S6 s6,S7 s7,S8 s8,S9 s9,S10 s10,S11 s11,S12 s12,S13 s13,S14 s14, Op op)
170  {
171  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
172 
173  if (p >= s1.data.template get<0>().size()) {return;}
174  //converting to boost vector ids.
175  for_each_prop14<S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,unsigned int,Op> cp(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,p,op);
176  //creating an iterator on v_ids[0] [1] [2]
177  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
178  }
179 
180 
181  template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8,typename S9,typename S10,typename S11,typename S12,typename S13,typename S14,typename S15, typename Op>
182  __global__ void for_each15_ker(S1 s1,S2 s2,S3 s3,S4 s4,S5 s5,S6 s6,S7 s7,S8 s8,S9 s9,S10 s10,S11 s11,S12 s12,S13 s13,S14 s14,S15 s15, Op op)
183  {
184  unsigned int p = threadIdx.x + blockIdx.x * blockDim.x;
185 
186  if (p >= s1.data.template get<0>().size()) {return;}
187  //converting to boost vector ids.
188  for_each_prop15<S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,S15,unsigned int,Op> cp(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,p,op);
189  //creating an iterator on v_ids[0] [1] [2]
190  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
191  }
192 
194  {
195 
196  template< class S1 , class Op >
197  static void for_each1( S1 &s1 , Op op )
198  {
199  // ToDo : build checks, that the +-*/ operators are well defined
200  auto it=s1.data.template get<0>().getVector().getDomainIteratorGPU();
201  CUDA_LAUNCH((for_each1_ker),it,s1,op);
202  }
203  template< class S1 , class S2 , class Op >
204  static void for_each2( S1 &s1 , S2 &s2 , Op op )
205  {
206  for_each_prop_resize<S1,S2> the_resize(s1,s2);
207  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
208  //s1.data.template get<0>().getVector().resize(s2.data.template get<0>().getVector().size());
209  // ToDo : build checks, that the +-*/ operators are well defined
210  auto it=s1.data.template get<0>().getVector().getGPUIterator();
211 
212  CUDA_LAUNCH((for_each2_ker),it,s1.toKernel(),s2.toKernel(),op);
213  }
214 
215  template< class S1 , class S2 , class S3 , class Op >
216  static void for_each3( S1 &s1 , S2 &s2 , S3 &s3 , Op op )
217  {
218  for_each_prop_resize<S1,S2> the_resize(s1,s2);
219  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(the_resize);
220  // ToDo : build checks, that the +-*/ operators are well defined
221  auto it=s1.data.template get<0>().getVector().getGPUIterator();
222 
223  CUDA_LAUNCH((for_each3_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),op);
224 
225  }
226 
227  template< class S1 , class S2 , class S3 , class S4 , class Op >
228  static void for_each4( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , Op op )
229  {
230  for_each_prop_resize<S1,S2> the_resize(s1,s2);
231  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
232  // ToDo : build checks, that the +-*/ operators are well defined
233  auto it=s1.data.template get<0>().getVector().getGPUIterator();
234 
235  CUDA_LAUNCH((for_each4_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),op);
236  }
237 
238 
239  template< class S1 , class S2 , class S3 , class S4,class S5 , class Op >
240  static void for_each5( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5 , Op op )
241  {
242  for_each_prop_resize<S1,S2> the_resize(s1,s2);
243  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
244  // ToDo : build checks, that the +-*/ operators are well defined
245  auto it=s1.data.template get<0>().getVector().getGPUIterator();
246 
247  CUDA_LAUNCH((for_each5_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),s5.toKernel(),op);
248  }
249 
250  template< class S1 , class S2 , class S3 , class S4,class S5,class S6 , class Op >
251  static void for_each6( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6 , Op op )
252  {
253  for_each_prop_resize<S1,S2> the_resize(s1,s2);
254  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
255  // ToDo : build checks, that the +-*/ operators are well defined
256  auto it=s1.data.template get<0>().getVector().getGPUIterator();
257 
258  CUDA_LAUNCH((for_each6_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),s5.toKernel(),s6.toKernel(),op);
259  }
260 
261 
262  template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7, class Op >
263  static void for_each7( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7 , Op op )
264  {
265  for_each_prop_resize<S1,S2> the_resize(s1,s2);
266  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
267  // ToDo : build checks, that the +-*/ operators are well defined
268  auto it=s1.data.template get<0>().getVector().getGPUIterator();
269 
270  CUDA_LAUNCH((for_each7_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),s5.toKernel(),s6.toKernel(),s7.toKernel(),op);
271  }
272 
273  template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class Op >
274  static void for_each8( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8 , Op op )
275  {
276  for_each_prop_resize<S1,S2> the_resize(s1,s2);
277  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
278  // ToDo : build checks, that the +-*/ operators are well defined
279  auto it=s1.data.template get<0>().getVector().getGPUIterator();
280 
281  CUDA_LAUNCH((for_each8_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),s5.toKernel(),s6.toKernel(),s7.toKernel(),s8.toKernel(),op);
282  }
283 
284  template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class Op >
285  static void for_each9( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9 , Op op )
286  {
287  for_each_prop_resize<S1,S2> the_resize(s1,s2);
288  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
289  // ToDo : build checks, that the +-*/ operators are well defined
290  auto it=s1.data.template get<0>().getVector().getGPUIterator();
291 
292  CUDA_LAUNCH((for_each9_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),s5.toKernel(),s6.toKernel(),s7.toKernel(),s8.toKernel(),s9.toKernel(),op);
293  }
294 
295 
296  template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class Op >
297  static void for_each10( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9 , S10 &s10, Op op )
298  {
299  for_each_prop_resize<S1,S2> the_resize(s1,s2);
300  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
301  // ToDo : build checks, that the +-*/ operators are well defined
302  auto it=s1.data.template get<0>().getVector().getGPUIterator();
303 
304  CUDA_LAUNCH((for_each10_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),s5.toKernel(),s6.toKernel(),s7.toKernel(),s8.toKernel(),s9.toKernel(),s10.toKernel(),op);
305 
306  }
307 
308 
309  template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class S11, class Op >
310  static void for_each11( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9 , S10 &s10,S11 &s11, Op op )
311  {
312  for_each_prop_resize<S1,S2> the_resize(s1,s2);
313  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
314  // ToDo : build checks, that the +-*/ operators are well defined
315  auto it=s1.data.template get<0>().getVector().getGPUIterator();
316 
317  CUDA_LAUNCH((for_each11_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),op);
318  }
319 
320 
321  template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class S11, class S12, class Op >
322  static void for_each12( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9 , S10 &s10,S11 &s11,S12 &s12, Op op )
323  {
324  for_each_prop_resize<S1,S2> the_resize(s1,s2);
325  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
326  // ToDo : build checks, that the +-*/ operators are well defined
327  auto it=s1.data.template get<0>().getVector().getGPUIterator();
328 
329  CUDA_LAUNCH((for_each12_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),s5.toKernel(),s6.toKernel(),s7.toKernel(),s8.toKernel(),s9.toKernel(),s10.toKernel(),s11.toKernel(),s12.toKernel(),op);
330  }
331 
332 
333  template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class S11, class S12, class S13, class Op >
334  static void for_each13( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9 , S10 &s10,S11 &s11,S12 &s12,S13 &s13, Op op )
335  {
336  for_each_prop_resize<S1,S2> the_resize(s1,s2);
337  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
338  // ToDo : build checks, that the +-*/ operators are well defined
339  auto it=s1.data.template get<0>().getVector().getGPUIterator();
340 
341  CUDA_LAUNCH((for_each13_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),s5.toKernel(),s6.toKernel(),s7.toKernel(),s8.toKernel(),s9.toKernel(),s10.toKernel(),s11.toKernel(),s12.toKernel(),s13.toKernel(),op);
342  }
343 
344  template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class S11, class S12, class S13, class S14, class Op >
345  static void for_each14( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9, S10 &s10,S11 &s11,S12 &s12,S13 &s13,S14 &s14, Op op )
346  {
347  for_each_prop_resize<S1,S2> the_resize(s1,s2);
348  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
349  // ToDo : build checks, that the +-*/ operators are well defined
350  auto it=s1.data.template get<0>().getVector().getGPUIterator();
351 
352  CUDA_LAUNCH((for_each14_ker),it,it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),s5.toKernel(),s6.toKernel(),s7.toKernel(),s8.toKernel(),s9.toKernel(),s10.toKernel(),s11.toKernel(),s12.toKernel(),s13.toKernel(),s14.toKernel(),op);
353  }
354 
355  template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class S11, class S12, class S13, class S14, class S15, class Op >
356  static void for_each15( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9, S10 &s10,S11 &s11,S12 &s12,S13 &s13,S14 &s14,S15 &s15, Op op )
357  {
358  for_each_prop_resize<S1,S2> the_resize(s1,s2);
359  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
360  auto it=s1.data.template get<0>().getVector().getGPUIterator();
361 
362  CUDA_LAUNCH((for_each15_ker),it,s1.toKernel(),s2.toKernel(),s3.toKernel(),s4.toKernel(),s5.toKernel(),s6.toKernel(),s7.toKernel(),s8.toKernel(),s9.toKernel(),s10.toKernel(),s11.toKernel(),s12.toKernel(),s13.toKernel(),s14.toKernel(),s15.toKernel(),op);
363  }
364 
365 
366 
367 
368 
369 
370  template<typename vector_type,typename index_type,typename norm_result_type>
372  {
373  const vector_type &v;
374  index_type &p;
375  norm_result_type &n;
383  inline for_each_norm(const vector_type &v,index_type &p,norm_result_type &n)
384  :v(v),p(p),n(n)
385  {};
387  template<typename T>
388  inline void operator()(T& t) const
389  {
390  if(fabs(v.data.template get<T::value>().getVector().template get<0>(p)) > n)
391  {
392  n=fabs(v.data.template get<T::value>().getVector().template get<0>(p));
393  }
394 
395  }
396  };
397 
398  template< class S >
399  static typename boost::numeric::odeint::vector_space_norm_inf< S >::result_type norm_inf( const S &s )
400  {
401  typename boost::numeric::odeint::vector_space_norm_inf< S >::result_type n=0;
402  auto it=s.data.template get<0>().getVector().getIterator();
403  while(it.isNext()){
404  auto p=it.get();
405  //converting to boost vector ids.
406  for_each_norm<S,size_t,typename boost::numeric::odeint::vector_space_norm_inf< S >::result_type> cp(s,p,n);
407  //creating an iterator on v_ids[0] [1] [2]
408  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s.data)::max_prop>>(cp);
409 
410  ++it;
411  }
412  auto &v_cl = create_vcluster();
413  v_cl.max(n);
414  v_cl.execute();
415  //std::max();
416  //std::cout<<n<<std::endl;
417  return n;
418  }
419  };
420 
421 
422 #include <algorithm>
423 
424 #include <boost/config.hpp>
425 #include <boost/array.hpp>
426 #include <boost/numeric/odeint/util/unit_helper.hpp>
427 
428 
429 
430 
431 
432 /*
433  * Notes:
434  *
435  * * the results structs are needed in order to work with fusion_algebra
436  */
438 {
439 
440  template< class Fac1 = double >
441  struct scale
442  {
443  const Fac1 m_alpha1;
444 
445  scale( Fac1 alpha1 ) : m_alpha1( alpha1 ) { }
446 
447  template< class T1 >
448  __device__ __host__ void operator()( T1 &t1 ) const
449  {
450  t1 *= m_alpha1;
451  }
452 
453  typedef void result_type;
454  };
455 
456  template< class Fac1 = double >
457  struct scale_sum1
458  {
459  const Fac1 m_alpha1;
460 
461  scale_sum1( Fac1 alpha1 ) : m_alpha1( alpha1 ) { }
462 
463  template< class T1 , class T2 >
464  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 ) const
465  {
466  t1 = m_alpha1 * t2;
467  }
468 
469  typedef void result_type;
470  };
471 
472 
473  template< class Fac1 = double , class Fac2 = Fac1 >
474  struct scale_sum2
475  {
476  const Fac1 m_alpha1;
477  const Fac2 m_alpha2;
478 
479  scale_sum2( Fac1 alpha1 , Fac2 alpha2 ) : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { }
480 
481  template< class T1 , class T2 , class T3 >
482  BOOST_FUSION_GPU_ENABLED
483  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3) const
484  {
485  t1 = m_alpha1 * t2 + m_alpha2 * t3;
486  }
487 
488  typedef void result_type;
489  };
490 
491 
492  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 >
493  struct scale_sum3
494  {
495  const Fac1 m_alpha1;
496  const Fac2 m_alpha2;
497  const Fac3 m_alpha3;
498 
499  scale_sum3( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 )
500  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) { }
501 
502  template< class T1 , class T2 , class T3 , class T4 >
503  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 ) const
504  {
505  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4;
506  }
507 
508  typedef void result_type;
509  };
510 
511 
512  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 >
513  struct scale_sum4
514  {
515  const Fac1 m_alpha1;
516  const Fac2 m_alpha2;
517  const Fac3 m_alpha3;
518  const Fac4 m_alpha4;
519 
520  scale_sum4( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 )
521  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) { }
522 
523  template< class T1 , class T2 , class T3 , class T4 , class T5 >
524  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5) const
525  {
526  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5;
527  }
528 
529  typedef void result_type;
530  };
531 
532 
533  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 >
534  struct scale_sum5
535  {
536  const Fac1 m_alpha1;
537  const Fac2 m_alpha2;
538  const Fac3 m_alpha3;
539  const Fac4 m_alpha4;
540  const Fac5 m_alpha5;
541 
542  scale_sum5( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , Fac5 alpha5 )
543  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) { }
544 
545  template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 >
546  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6) const
547  {
548  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6;
549  }
550 
551  typedef void result_type;
552  };
553 
554 
555  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 >
556  struct scale_sum6
557  {
558  const Fac1 m_alpha1;
559  const Fac2 m_alpha2;
560  const Fac3 m_alpha3;
561  const Fac4 m_alpha4;
562  const Fac5 m_alpha5;
563  const Fac6 m_alpha6;
564 
565  scale_sum6( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 , Fac5 alpha5 , Fac6 alpha6 )
566  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ){ }
567 
568  template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 >
569  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 ,const T7 &t7) const
570  {
571  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7;
572  }
573 
574  typedef void result_type;
575  };
576 
577 
578  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 >
579  struct scale_sum7
580  {
581  const Fac1 m_alpha1;
582  const Fac2 m_alpha2;
583  const Fac3 m_alpha3;
584  const Fac4 m_alpha4;
585  const Fac5 m_alpha5;
586  const Fac6 m_alpha6;
587  const Fac7 m_alpha7;
588 
589  scale_sum7( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
590  Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 )
591  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) { }
592 
593  template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 >
594  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 ) const
595  {
596  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8;
597  }
598 
599  typedef void result_type;
600  };
601 
602 
603  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 >
604  struct scale_sum8
605  {
606  const Fac1 m_alpha1;
607  const Fac2 m_alpha2;
608  const Fac3 m_alpha3;
609  const Fac4 m_alpha4;
610  const Fac5 m_alpha5;
611  const Fac6 m_alpha6;
612  const Fac7 m_alpha7;
613  const Fac8 m_alpha8;
614 
615  scale_sum8( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
616  Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 )
617  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) { }
618 
619  template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 >
620  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 ) const
621  {
622  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9;
623  }
624 
625  typedef void result_type;
626  };
627 
628  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 >
629  struct scale_sum9
630  {
631  const Fac1 m_alpha1;
632  const Fac2 m_alpha2;
633  const Fac3 m_alpha3;
634  const Fac4 m_alpha4;
635  const Fac5 m_alpha5;
636  const Fac6 m_alpha6;
637  const Fac7 m_alpha7;
638  const Fac8 m_alpha8;
639  const Fac9 m_alpha9;
640 
641  scale_sum9( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
642  Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 )
643  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) { }
644 
645  template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 >
646  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 ) const
647  {
648  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10;
649  }
650 
651  typedef void result_type;
652  };
653 
654  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 >
655  struct scale_sum10
656  {
657  const Fac1 m_alpha1;
658  const Fac2 m_alpha2;
659  const Fac3 m_alpha3;
660  const Fac4 m_alpha4;
661  const Fac5 m_alpha5;
662  const Fac6 m_alpha6;
663  const Fac7 m_alpha7;
664  const Fac8 m_alpha8;
665  const Fac9 m_alpha9;
666  const Fac10 m_alpha10;
667 
668  scale_sum10( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
669  Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 , Fac10 alpha10 )
670  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) { }
671 
672  template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 >
673  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 ) const
674  {
675  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11;
676  }
677 
678  typedef void result_type;
679  };
680 
681 
682  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 >
683  struct scale_sum11
684  {
685  const Fac1 m_alpha1;
686  const Fac2 m_alpha2;
687  const Fac3 m_alpha3;
688  const Fac4 m_alpha4;
689  const Fac5 m_alpha5;
690  const Fac6 m_alpha6;
691  const Fac7 m_alpha7;
692  const Fac8 m_alpha8;
693  const Fac9 m_alpha9;
694  const Fac10 m_alpha10;
695  const Fac11 m_alpha11;
696 
697  scale_sum11( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
698  Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 ,
699  Fac10 alpha10 , Fac11 alpha11 )
700  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) { }
701 
702  template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 >
703  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 ) const
704  {
705  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12;
706  }
707 
708  typedef void result_type;
709  };
710 
711  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 , class Fac12 = Fac11 >
712  struct scale_sum12
713  {
714  const Fac1 m_alpha1;
715  const Fac2 m_alpha2;
716  const Fac3 m_alpha3;
717  const Fac4 m_alpha4;
718  const Fac5 m_alpha5;
719  const Fac6 m_alpha6;
720  const Fac7 m_alpha7;
721  const Fac8 m_alpha8;
722  const Fac9 m_alpha9;
723  const Fac10 m_alpha10;
724  const Fac11 m_alpha11;
725  const Fac12 m_alpha12;
726 
727  scale_sum12( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
728  Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 ,
729  Fac10 alpha10 , Fac11 alpha11 , Fac12 alpha12 )
730  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) , m_alpha12( alpha12 ) { }
731 
732  template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 , class T13 >
733  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 , const T13 &t13 ) const
734  {
735  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12 + m_alpha12 * t13;
736  }
737 
738  typedef void result_type;
739  };
740 
741  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 , class Fac12 = Fac11 , class Fac13 = Fac12 >
742  struct scale_sum13
743  {
744  const Fac1 m_alpha1;
745  const Fac2 m_alpha2;
746  const Fac3 m_alpha3;
747  const Fac4 m_alpha4;
748  const Fac5 m_alpha5;
749  const Fac6 m_alpha6;
750  const Fac7 m_alpha7;
751  const Fac8 m_alpha8;
752  const Fac9 m_alpha9;
753  const Fac10 m_alpha10;
754  const Fac11 m_alpha11;
755  const Fac12 m_alpha12;
756  const Fac13 m_alpha13;
757 
758  scale_sum13( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
759  Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 ,
760  Fac10 alpha10 , Fac11 alpha11 , Fac12 alpha12 , Fac13 alpha13 )
761  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) , m_alpha12( alpha12 ) , m_alpha13( alpha13 ) { }
762 
763  template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 , class T13 , class T14 >
764  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 , const T13 &t13 , const T14 &t14 ) const
765  {
766  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12 + m_alpha12 * t13 + m_alpha13 * t14;
767  }
768 
769  typedef void result_type;
770  };
771 
772  template< class Fac1 = double , class Fac2 = Fac1 , class Fac3 = Fac2 , class Fac4 = Fac3 , class Fac5 = Fac4 , class Fac6 = Fac5 , class Fac7 = Fac6 , class Fac8 = Fac7 , class Fac9 = Fac8 , class Fac10 = Fac9 , class Fac11 = Fac10 , class Fac12 = Fac11 , class Fac13 = Fac12 , class Fac14 = Fac13 >
773  struct scale_sum14
774  {
775  const Fac1 m_alpha1;
776  const Fac2 m_alpha2;
777  const Fac3 m_alpha3;
778  const Fac4 m_alpha4;
779  const Fac5 m_alpha5;
780  const Fac6 m_alpha6;
781  const Fac7 m_alpha7;
782  const Fac8 m_alpha8;
783  const Fac9 m_alpha9;
784  const Fac10 m_alpha10;
785  const Fac11 m_alpha11;
786  const Fac12 m_alpha12;
787  const Fac13 m_alpha13;
788  const Fac14 m_alpha14;
789 
790  scale_sum14( Fac1 alpha1 , Fac2 alpha2 , Fac3 alpha3 , Fac4 alpha4 ,
791  Fac5 alpha5 , Fac6 alpha6 , Fac7 alpha7 , Fac8 alpha8 , Fac9 alpha9 ,
792  Fac10 alpha10 , Fac11 alpha11 , Fac12 alpha12 , Fac13 alpha13 , Fac14 alpha14 )
793  : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) , m_alpha3( alpha3 ) , m_alpha4( alpha4 ) , m_alpha5( alpha5 ) , m_alpha6( alpha6 ) , m_alpha7( alpha7 ) , m_alpha8( alpha8 ) , m_alpha9( alpha9 ) , m_alpha10( alpha10 ) , m_alpha11( alpha11 ) , m_alpha12( alpha12 ) , m_alpha13( alpha13 ) , m_alpha14( alpha14 ) { }
794 
795  template< class T1 , class T2 , class T3 , class T4 , class T5 , class T6 , class T7 , class T8 , class T9 , class T10 , class T11 , class T12 , class T13 , class T14 , class T15 >
796  __device__ __host__ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3 , const T4 &t4 , const T5 &t5 , const T6 &t6 , const T7 &t7 , const T8 &t8 , const T9 &t9 , const T10 &t10 , const T11 &t11 , const T12 &t12 , const T13 &t13 , const T14 &t14 , const T15 &t15 ) const
797  {
798  t1 = m_alpha1 * t2 + m_alpha2 * t3 + m_alpha3 * t4 + m_alpha4 * t5 + m_alpha5 * t6 + m_alpha6 * t7 + m_alpha7 * t8 + m_alpha8 * t9 + m_alpha9 * t10 + m_alpha10 * t11 + m_alpha11 * t12 + m_alpha12 * t13 + m_alpha13 * t14 + m_alpha14 * t15;
799  }
800 
801  typedef void result_type;
802  };
803 
804  template< class Fac1 = double , class Fac2 = Fac1 >
806  {
807  const Fac1 m_alpha1;
808  const Fac2 m_alpha2;
809 
810  scale_sum_swap2( Fac1 alpha1 , Fac2 alpha2 ) : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { }
811 
812  template< class T1 , class T2 , class T3 >
813  __device__ __host__ void operator()( T1 &t1 , T2 &t2 , const T3 &t3) const
814  {
815  const T1 tmp( t1 );
816  t1 = m_alpha1 * t2 + m_alpha2 * t3;
817  t2 = tmp;
818  }
819 
820  typedef void result_type;
821  };
822 
823  /*
824  * for usage in for_each2
825  *
826  * Works with boost::units by eliminating the unit
827  */
828  template< class Fac1 = double >
829  struct rel_error
830  {
831  const Fac1 m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt;
832 
833  rel_error( Fac1 eps_abs , Fac1 eps_rel , Fac1 a_x , Fac1 a_dxdt )
834  : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) , m_a_x( a_x ) , m_a_dxdt( a_dxdt ) { }
835 
836 
837  template< class T1 , class T2 , class T3 >
838  __device__ __host__ void operator()( T3 &t3 , const T1 &t1 , const T2 &t2 ) const
839  {
840  using std::abs;
841  set_unit_value( t3 , abs( get_unit_value( t3 ) ) / ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_unit_value( t1 ) ) + m_a_dxdt * abs( get_unit_value( t2 ) ) ) ) );
842  }
843 
844  typedef void result_type;
845  };
846 
847 
848  /*
849  * for usage in for_each3
850  *
851  * used in the controller for the rosenbrock4 method
852  *
853  * Works with boost::units by eliminating the unit
854  */
855  template< class Fac1 = double >
857  {
858  const Fac1 m_eps_abs , m_eps_rel ;
859 
860  default_rel_error( Fac1 eps_abs , Fac1 eps_rel )
861  : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) { }
862 
863 
864  /*
865  * xerr = xerr / ( eps_abs + eps_rel * max( x , x_old ) )
866  */
867  template< class T1 , class T2 , class T3 >
868  __device__ __host__ void operator()( T3 &t3 , const T1 &t1 , const T2 &t2 ) const
869  {
870  BOOST_USING_STD_MAX();
871  using std::abs;
872  Fac1 x1 = abs( get_unit_value( t1 ) ) , x2 = abs( get_unit_value( t2 ) );
873  set_unit_value( t3 , abs( get_unit_value( t3 ) ) / ( m_eps_abs + m_eps_rel * max BOOST_PREVENT_MACRO_SUBSTITUTION ( x1 , x2 ) ) );
874  }
875 
876  typedef void result_type;
877  };
878 
879 
880 
881  /*
882  * for usage in reduce
883  */
884 
885  template< class Value >
886  struct maximum
887  {
888  template< class Fac1 , class Fac2 >
889  __device__ __host__ Value operator()( Fac1 t1 , const Fac2 t2 ) const
890  {
891  using std::abs;
892  Value a1 = abs( get_unit_value( t1 ) ) , a2 = abs( get_unit_value( t2 ) );
893  return ( a1 < a2 ) ? a2 : a1 ;
894  }
895 
896  typedef Value result_type;
897  };
898 
899 
900  template< class Fac1 = double >
902  {
903  const Fac1 m_eps_abs , m_eps_rel;
904 
905  rel_error_max( Fac1 eps_abs , Fac1 eps_rel )
906  : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel )
907  { }
908 
909  template< class Res , class T1 , class T2 , class T3 >
910 __device__ __host__ Res operator()( Res r , const T1 &x_old , const T2 &x , const T3 &x_err )
911  {
912  BOOST_USING_STD_MAX();
913  using std::abs;
914  Res tmp = abs( get_unit_value( x_err ) ) / ( m_eps_abs + m_eps_rel * max BOOST_PREVENT_MACRO_SUBSTITUTION ( abs( x_old ) , abs( x ) ) );
915  return max BOOST_PREVENT_MACRO_SUBSTITUTION ( r , tmp );
916  }
917  };
918 
919 
920  template< class Fac1 = double >
922  {
923  const Fac1 m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt;
924 
925  rel_error_max2( Fac1 eps_abs , Fac1 eps_rel , Fac1 a_x , Fac1 a_dxdt )
926  : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) , m_a_x( a_x ) , m_a_dxdt( a_dxdt )
927  { }
928 
929  template< class Res , class T1 , class T2 , class T3 , class T4 >
930 __device__ __host__ Res operator()( Res r , const T1 &x_old , const T2 &/*x*/ , const T3 &dxdt_old , const T4 &x_err )
931  {
932  BOOST_USING_STD_MAX();
933  using std::abs;
934  Res tmp = abs( get_unit_value( x_err ) ) /
935  ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_unit_value( x_old ) ) + m_a_dxdt * abs( get_unit_value( dxdt_old ) ) ) );
936  return max BOOST_PREVENT_MACRO_SUBSTITUTION ( r , tmp );
937  }
938  };
939 
940 
941 
942 
943  template< class Fac1 = double >
945  {
946  const Fac1 m_eps_abs , m_eps_rel;
947 
948  rel_error_l2( Fac1 eps_abs , Fac1 eps_rel )
949  : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel )
950  { }
951 
952  template< class Res , class T1 , class T2 , class T3 >
953 __device__ __host__ Res operator()( Res r , const T1 &x_old , const T2 &x , const T3 &x_err )
954  {
955  BOOST_USING_STD_MAX();
956  using std::abs;
957  Res tmp = abs( get_unit_value( x_err ) ) / ( m_eps_abs + m_eps_rel * max BOOST_PREVENT_MACRO_SUBSTITUTION ( abs( x_old ) , abs( x ) ) );
958  return r + tmp * tmp;
959  }
960  };
961 
962 
963 
964 
965  template< class Fac1 = double >
967  {
968  const Fac1 m_eps_abs , m_eps_rel , m_a_x , m_a_dxdt;
969 
970  rel_error_l2_2( Fac1 eps_abs , Fac1 eps_rel , Fac1 a_x , Fac1 a_dxdt )
971  : m_eps_abs( eps_abs ) , m_eps_rel( eps_rel ) , m_a_x( a_x ) , m_a_dxdt( a_dxdt )
972  { }
973 
974  template< class Res , class T1 , class T2 , class T3 , class T4 >
975 __device__ __host__ Res operator()( Res r , const T1 &x_old , const T2 &/*x*/ , const T3 &dxdt_old , const T4 &x_err )
976  {
977  using std::abs;
978  Res tmp = abs( get_unit_value( x_err ) ) /
979  ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_unit_value( x_old ) ) + m_a_dxdt * abs( get_unit_value( dxdt_old ) ) ) );
980  return r + tmp * tmp;
981  }
982  };
983 
984 
985 };
986 
987 
988  } // odeint
989 } // numeric
990 } // boost
991 
992 
993 #endif //OPENFPM_PDATA_VECTOR_ALGEBRA_OFP_HPP
Distributed vector.
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data
for_each_norm(const vector_type &v, index_type &p, norm_result_type &n)
constructor
void operator()(T &t) const
It call the copy function for each property.