OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
SparseGrid_chunk_copy.hpp
1/*
2 * SparseGrid_chunk_copy.hpp
3 *
4 * Created on: Mar 18, 2020
5 * Author: i-bird
6 */
7
8#ifndef SPARSEGRID_CHUNK_COPY_HPP_
9#define SPARSEGRID_CHUNK_COPY_HPP_
10
11#if !defined(__NVCC__) || defined(CUDA_ON_CPU) || defined(__HIP__)
12// Nvcc does not like VC ... for some reason
13#include <Vc/Vc>
14#endif
15
16#include "util/mathutil.hpp"
17
18
27template<typename headerType>
28inline bool exist_sub(headerType & h, int sub_id)
29{
30 return h.mask[sub_id];
31}
32
33template<unsigned int v>
35{
36 typedef unsigned char type;
37
38 template<typename headerType>
39 static inline void exist(headerType & h, int sub_id, unsigned char * pmask)
40 {
41 pmask[0] = h.mask[sub_id];
42 }
43};
44
45template<>
47{
48 typedef unsigned short type;
49
50 template<typename headerType>
51 static inline void exist(headerType & h, int sub_id, unsigned char * pmask)
52 {
53 pmask[0] = h.mask[sub_id];
54 pmask[1] = h.mask[sub_id+1];
55 }
56};
57
58template<>
60{
61 typedef unsigned int type;
62
63 template<typename headerType>
64 static inline void exist(headerType & h, int sub_id, unsigned char * pmask)
65 {
66 pmask[0] = h.mask[sub_id];
67 pmask[1] = h.mask[sub_id+1];
68 pmask[2] = h.mask[sub_id+2];
69 pmask[3] = h.mask[sub_id+3];
70 }
71};
72
73template<>
75{
76 typedef unsigned long int type;
77
78 template<typename headerType>
79 static inline void exist(headerType & h, int sub_id, unsigned char * pmask)
80 {
81 pmask[0] = h.mask[sub_id];
82 pmask[1] = h.mask[sub_id+1];
83 pmask[2] = h.mask[sub_id+2];
84 pmask[3] = h.mask[sub_id+3];
85 pmask[4] = h.mask[sub_id+4];
86 pmask[5] = h.mask[sub_id+5];
87 pmask[6] = h.mask[sub_id+6];
88 pmask[7] = h.mask[sub_id+7];
89 }
90};
91
100template<unsigned int v, typename headerType>
101inline void exist_sub_v(headerType & h, int sub_id, unsigned char * pmask)
102{
103 exist_sub_v_impl<v>::exist(h,sub_id,pmask);
104}
105
106
108template<int layout_type, int prop, int stencil_size ,typename chunking,bool is_cross>
110{
111 template<unsigned int N1, typename T, typename headerType, typename chunkType>
112 inline static void copy(T ptr[N1], unsigned char mask[N1], headerType & h , const chunkType & chunk)
113 {
114 int s = stencil_size + stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
115 stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
116
117 int s2 = 0;
118
119 for (int v = 0 ; v < boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value ; v++)
120 {
121 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
122 {
123 for (int k = 0 ; k < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; k++)
124 {
125 ptr[s] = chunk[s2];
126 mask[s] = exist_sub(h,s2);
127
128 s++;
129 s2++;
130 }
131 s += 2*stencil_size;
132 }
133 s+= 2*stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size);
134 }
135 }
136
137 template<unsigned int N1, typename T, typename chunkType>
138 inline static void store(T ptr[N1] , chunkType & chunk)
139 {
140 int s2 = 0;
141
142 for (int v = 0 ; v < boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value ; v++)
143 {
144 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
145 {
146 for (int k = 0 ; k < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; k++)
147 {
148 chunk[s2] = ptr[s2];
149
150 s2++;
151 }
152 }
153 }
154 }
155};
156
157template<unsigned int i>
159{};
160
161template<>
162struct multi_mask<1>
163{
164 typedef unsigned char type;
165};
166
167template<>
168struct multi_mask<2>
169{
170 typedef unsigned short int type;
171};
172
173template<>
174struct multi_mask<4>
175{
176 typedef unsigned int type;
177};
178
179template<>
180struct multi_mask<8>
181{
182 typedef unsigned long int type;
183};
184
185template<>
186struct multi_mask<16>
187{
188 typedef unsigned long int type;
189};
190
191#ifndef __NVCC__
192
194template<int prop, int stencil_size ,typename chunking,bool is_cross>
195struct copy_xyz<1,prop,stencil_size,chunking,is_cross>
196{
197 template<unsigned int N1, typename T, typename headerType, typename chunkType>
198 inline static void copy(T ptr[N1], unsigned char mask[N1], headerType & h , const chunkType & chunk)
199 {
200 int s = stencil_size + stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
201 stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
202
203 typedef boost::mpl::int_<boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value * sizeof(chunk[0]) /
204 Vc::float_v::Size / sizeof(float)> n_it_lead;
205
206 int s2 = 0;
207
208 for (int v = 0 ; v < boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value ; v++)
209 {
210 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
211 {
212 for (int k = 0 ; k < n_it_lead::value ; k+=4)
213 {
214 exist_sub_v<Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))>(h,s2,&mask[s]);
215 exist_sub_v<Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))>(h,s2+Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float)),&mask[s+Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))]);
216 exist_sub_v<Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))>(h,s2+2*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float)),&mask[s+2*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))]);
217 exist_sub_v<Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))>(h,s2+3*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float)),&mask[s+3*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))]);
218
219 Vc::float_v tmp = Vc::float_v((float *)&chunk[s2],Vc::Aligned);
220 Vc::float_v tmp2 = Vc::float_v((float *)&chunk[s2+Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Aligned);
221 Vc::float_v tmp3 = Vc::float_v((float *)&chunk[s2+2*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Aligned);
222 Vc::float_v tmp4 = Vc::float_v((float *)&chunk[s2+3*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Aligned);
223 tmp.store((float *)&ptr[s],Vc::Unaligned);
224 tmp2.store((float *)&ptr[s+Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Unaligned);
225 tmp3.store((float *)&ptr[s+2*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Unaligned);
226 tmp4.store((float *)&ptr[s+3*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Unaligned);
227
228 s += 4*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float));
229 s2 += 4*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float));
230 }
231 s += 2*stencil_size ;
232 }
233 s+= 2*stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size);
234 }
235 }
236
237 template<unsigned int N1, typename T, typename chunkType>
238 inline static void store(T ptr[N1] , chunkType & chunk)
239 {
240 typedef boost::mpl::int_<boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value * sizeof(chunk[0]) /
241 Vc::float_v::Size / sizeof(float)> n_it_lead;
242
243 int s2 = 0;
244
245 for (int v = 0 ; v < boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value ; v++)
246 {
247 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
248 {
249 for (int k = 0 ; k < n_it_lead::value ; k += 4)
250 {
251 Vc::float_v tmp = Vc::float_v((float *)&ptr[s2],Vc::Aligned);
252 Vc::float_v tmp1 = Vc::float_v((float *)&ptr[s2+1*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Aligned);
253 Vc::float_v tmp2 = Vc::float_v((float *)&ptr[s2+2*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Aligned);
254 Vc::float_v tmp3 = Vc::float_v((float *)&ptr[s2+3*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Aligned);
255
256 tmp.store((float *)&chunk[s2],Vc::Aligned);
257 tmp1.store((float *)&chunk[s2+1*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Aligned);
258 tmp2.store((float *)&chunk[s2+2*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Aligned);
259 tmp3.store((float *)&chunk[s2+3*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float))],Vc::Aligned);
260
261 s2 += 4*Vc::float_v::Size / (sizeof(chunk[0])/sizeof(float));
262 }
263 }
264 }
265 }
266};
267
268#endif
269
271template<int layout_type, int prop,int stencil_size, typename chunking,bool is_cross>
273{
274 template<unsigned int i_src, unsigned int i_dest, unsigned int N1, typename T, typename headerType, typename chunkType>
275 inline static void copy(T ptr[N1], unsigned char mask[N1], headerType & h , const chunkType & chunk)
276 {
277 int s = stencil_size + stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
278 i_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
279
280 for (int v = 0 ; v < stencil_size ; v++)
281 {
282 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
283 {
284 for (int k = 0 ; k < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; k++)
285 {
286 const int id = Lin_vmpl<typename chunking::type>(k,j,i_src+v);
287
288 ptr[s] = chunk.template get<prop>()[id];
289 mask[s] = exist_sub(h,id);
290
291 s++;
292 }
293 s += 2*stencil_size;
294 }
295
296 s+= 2*stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size);
297 }
298 }
299
300 template<unsigned int i_dest, unsigned int N1>
301 inline static void mask_null(unsigned char mask[N1])
302 {
303 int s = stencil_size + stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
304 i_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
305
306 for (int v = 0 ; v < stencil_size ; v++)
307 {
308 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
309 {
310 for (int k = 0 ; k < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; k++)
311 {
312 mask[s] = 0;
313
314 s++;
315 }
316 s += 2*stencil_size;
317 }
318
319 s+= 2*stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size);
320 }
321 }
322};
323
324#ifndef __NVCC__
325
327template<int prop,int stencil_size, typename chunking,bool is_cross>
328struct copy_xy_3<1,prop,stencil_size,chunking,is_cross>
329{
330 template<unsigned int i_src, unsigned int i_dest, unsigned int N1, typename T, typename headerType, typename chunkType>
331 inline static void copy(T ptr[N1], unsigned char mask[N1], headerType & h , const chunkType & chunk)
332 {
333 int s = stencil_size + stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
334 i_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
335
336 int s2 = i_src*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value);
337
338 typedef boost::mpl::int_<boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value * sizeof(chunk.template get<prop>()[0]) /
339 Vc::float_v::Size / sizeof(float)> n_it_lead;
340
341 for (int v = 0 ; v < stencil_size ; v++)
342 {
343 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
344 {
345 for (int k = 0 ; k < n_it_lead::value ; k+=4)
346 {
347 exist_sub_v<Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))>(h,s2,&mask[s]);
348 exist_sub_v<Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))>(h,s2+1*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float)),&mask[s+1*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))]);
349 exist_sub_v<Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))>(h,s2+2*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float)),&mask[s+2*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))]);
350 exist_sub_v<Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))>(h,s2+3*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float)),&mask[s+3*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))]);
351
352
353 Vc::float_v tmp = Vc::float_v((float *)&chunk.template get<prop>()[s2],Vc::Unaligned);
354 Vc::float_v tmp1 = Vc::float_v((float *)&chunk.template get<prop>()[s2+1*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))],Vc::Unaligned);
355 Vc::float_v tmp2 = Vc::float_v((float *)&chunk.template get<prop>()[s2+2*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))],Vc::Unaligned);
356 Vc::float_v tmp3 = Vc::float_v((float *)&chunk.template get<prop>()[s2+3*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))],Vc::Unaligned);
357 tmp.store((float *)&ptr[s],Vc::Unaligned);
358 tmp1.store((float *)&ptr[s+1*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))],Vc::Unaligned);
359 tmp2.store((float *)&ptr[s+2*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))],Vc::Unaligned);
360 tmp3.store((float *)&ptr[s+3*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float))],Vc::Unaligned);
361
362 s += 4*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float));
363 s2 += 4*Vc::float_v::Size / (sizeof(chunk.template get<prop>()[0])/sizeof(float));
364 }
365 s += 2*stencil_size;
366
367 }
368
369 s+= 2*stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size);
370 }
371 }
372
373 template<unsigned int i_dest, unsigned int N1>
374 inline static void mask_null(unsigned char mask[N1])
375 {
376 int s = stencil_size + stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
377 i_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
378
379 for (int v = 0 ; v < stencil_size ; v++)
380 {
381 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
382 {
383 for (int k = 0 ; k < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; k++)
384 {
385 mask[s] = 0;
386
387 s++;
388 }
389 s += 2*stencil_size;
390 }
391
392 s+= 2*stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size);
393 }
394 }
395};
396
397#endif
398
400template<int layout_type, int prop, int stencil_size, typename chunking,bool is_cross>
402{
403 template<unsigned int j_src, unsigned int j_dest, unsigned int N1, typename T, typename headerType , typename chunkType>
404 inline static void copy(T ptr[N1], unsigned char mask[N1], headerType & h , const chunkType & chunk)
405 {
406 int s = stencil_size + j_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
407 stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
408
409 for (int v = 0 ; v < stencil_size ; v++)
410 {
411 for (int i = 0 ; i < boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value ; i++)
412 {
413 for (int k = 0 ; k < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; k++)
414 {
415 const int id = Lin_vmpl<typename chunking::type>(k,j_src+v,i);
416
417 ptr[s] = chunk.template get<prop>()[id];
418 mask[s] = exist_sub(h,id);
419
420 s++;
421 }
422
423 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value + 2*stencil_size) - boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value;
424 }
425
426 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value + 2*stencil_size) - boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
427 }
428 }
429};
430
432template<int layout_type, int prop, typename chunking,bool is_cross>
433struct copy_xz_3<layout_type,prop,1,chunking,is_cross>
434{
435 template<unsigned int j_src, unsigned int j_dest, unsigned int N1, typename T, typename headerType , typename chunkType>
436 inline static void copy(T ptr[N1], unsigned char mask[N1], headerType & h , const chunkType & chunk)
437 {
438 int s = 1 + j_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1) +
439 1*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*1);
440
441 for (int i = 0 ; i < boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value ; i++)
442 {
443 for (int k = 0 ; k < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; k++)
444 {
445 const int id = Lin_vmpl<typename chunking::type>(k,j_src,i);
446
447 ptr[s] = chunk.template get<prop>()[id];
448 mask[s] = exist_sub(h,id);
449
450 s++;
451 }
452
453 s += 1 * (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value + 2*1) - boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value;
454 }
455 }
456
457 template<unsigned int j_dest, unsigned int N1>
458 inline static void mask_null(unsigned char mask[N1])
459 {
460 int s = 1 + j_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1) +
461 1*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*1);
462
463 for (int i = 0 ; i < boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value ; i++)
464 {
465 for (int k = 0 ; k < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; k++)
466 {
467 mask[s] = 0;
468
469 s++;
470 }
471
472 s += 1 * (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value + 2*1) - boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value;
473 }
474 }
475};
476
478template<int layout_type, int prop, int stencil_size, typename chunking,bool is_cross>
480{
481 template<unsigned int k_src, unsigned int k_dest, unsigned int N1, typename T, typename headerType , typename chunkType>
482 inline static void copy(T ptr[N1], unsigned char mask[N1], headerType & h , const chunkType & chunk)
483 {
484 int s = k_dest + stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
485 stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
486
487 for (int v = 0 ; v < stencil_size ; v++)
488 {
489 for (int i = 0 ; i < boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value ; i++)
490 {
491 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
492 {
493 const int id = Lin_vmpl<typename chunking::type>(k_src+v,j,i);
494
495 ptr[s] = chunk.template get<prop>()[id];
496 mask[s] = exist_sub(h,id);
497
498 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size);
499 }
500
501 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value + 2*stencil_size) - boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size);
502 }
503
504 s += 1 - boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
505
506 }
507 }
508};
509
511template<int layout_type, int prop, typename chunking,bool is_cross>
512struct copy_yz_3<layout_type,prop,1,chunking,is_cross>
513{
514 template<unsigned int k_src, unsigned int k_dest, unsigned int N1, typename T, typename headerType, typename chunkType>
515 inline static void copy(T ptr[N1], unsigned char mask[N1], headerType & h , const chunkType & chunk)
516 {
517 int s = k_dest + 1*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1) +
518 1*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*1);
519
520 for (int i = 0 ; i < boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value ; i++)
521 {
522 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
523 {
524 const int id = Lin_vmpl<typename chunking::type>(k_src,j,i);
525
526 ptr[s] = chunk.template get<prop>()[id];
527 mask[s] = exist_sub(h,id);
528
529 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1);
530 }
531
532 s += 1 * (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value + 2*1) - boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1);
533 }
534 }
535
536 template<unsigned int k_dest, unsigned int N1>
537 inline static void mask_null(unsigned char mask[N1])
538 {
539 int s = k_dest + 1*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1) +
540 1*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*1);
541
542 for (int i = 0 ; i < boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value ; i++)
543 {
544 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
545 {
546 mask[s] = 0;
547
548 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1);
549 }
550
551 s += 1 * (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value + 2*1) - boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1);
552 }
553 }
554};
555
557template<int layout_type, int prop, int stencil_size, typename chunking,bool is_cross>
559{
560 template<unsigned int i_src, unsigned int i_dest,unsigned int j_src, unsigned int j_dest , unsigned int N1, typename T, typename chunkType>
561 inline static void copy(T ptr[N1], const chunkType & chunk)
562 {
563 int s = stencil_size + j_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
564 i_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
565
566 for (int v1 = 0 ; v1 < stencil_size ; v1++)
567 {
568 for (int v2 = 0 ; v2 < stencil_size ; v2++)
569 {
570 for (int k = 0 ; k < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; k++)
571 {
572 ptr[s] = chunk.template get<prop>()[Lin_vmpl<typename chunking::type>(k,j_src+v2,i_src+v1)];
573
574 s++;
575 }
576
577 s+= 2*stencil_size;
578 }
579
580 s+= (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size) - stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size);
581 }
582 }
583};
584
586template<int layout_type, int prop, typename chunking,bool is_cross>
587struct copy_x_3<layout_type,prop,1,chunking,is_cross>
588{
589 template<unsigned int i_src, unsigned int i_dest,unsigned int j_src, unsigned int j_dest , unsigned int N1, typename T, typename chunkType>
590 inline static void copy(T ptr[N1], const chunkType & chunk)
591 {
592 int s = 1 + j_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1) +
593 i_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*1);
594
595
596 for (int k = 0 ; k < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; k++)
597 {
598 ptr[s] = chunk.template get<prop>()[Lin_vmpl<typename chunking::type>(k,j_src,i_src)];
599
600 s++;
601 }
602 }
603};
604
606template<int layout_type, int prop, int stencil_size, typename chunking>
607struct copy_x_3<layout_type,prop,stencil_size,chunking,true>
608{
609 template<unsigned int i_src, unsigned int i_dest,unsigned int j_src, unsigned int j_dest , unsigned int N1, typename T, typename chunkType>
610 inline static void copy(T ptr[N1], const chunkType & chunk)
611 {}
612};
613
615template<int layout_type, int prop, int stencil_size, typename chunking,bool is_cross>
617{
618 template<unsigned int i_src, unsigned int i_dest,unsigned int k_src, unsigned int k_dest , unsigned int N1, typename T, typename chunkType>
619 inline static void copy(T ptr[N1], const chunkType & chunk)
620 {
621 int s = k_dest + stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
622 i_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
623
624 for (int v1 = 0 ; v1 < stencil_size ; v1++)
625 {
626 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value ; j++)
627 {
628 for (int v2 = 0 ; v2 < stencil_size ; v2++)
629 {
630 ptr[s] = chunk.template get<prop>()[Lin_vmpl<typename chunking::type>(k_src+v2,j,i_src+v1)];
631 s+= 1;
632 }
633
634 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) - stencil_size;
635 }
636
637 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size) - boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size);
638 }
639 }
640};
641
643template<int layout_type, int prop, typename chunking,bool is_cross>
644struct copy_y_3<layout_type,prop,1,chunking,is_cross>
645{
646 template<unsigned int i_src, unsigned int i_dest,unsigned int k_src, unsigned int k_dest , unsigned int N1, typename T, typename chunkType>
647 inline static void copy(T ptr[N1], const chunkType & chunk)
648 {
649 int s = k_dest + 1*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1) +
650 i_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*1);
651
652
653 for (int j = 0 ; j < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; j++)
654 {
655 ptr[s] = chunk.template get<prop>()[Lin_vmpl<typename chunking::type>(k_src,j,i_src)];
656
657 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1);
658 }
659 }
660};
661
663template<int layout_type, int prop, int stencil_size, typename chunking>
664struct copy_y_3<layout_type,prop,stencil_size,chunking,true>
665{
666 template<unsigned int i_src, unsigned int i_dest,unsigned int k_src, unsigned int k_dest , unsigned int N1, typename T, typename chunkType>
667 inline static void copy(T ptr[N1], const chunkType & chunk)
668 {}
669};
670
671
673template<int layout_type, int prop, int stencil_size, typename chunking,bool is_cross>
675{
676 template<unsigned int j_src, unsigned int j_dest,unsigned int k_src, unsigned int k_dest , unsigned int N1, typename T, typename chunkType>
677 inline static void copy(T ptr[N1], const chunkType & chunk)
678 {
679 int s = k_dest + j_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
680 stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
681
682
683 for (int i = 0 ; i < boost::mpl::at<typename chunking::type,boost::mpl::int_<2>>::type::value ; i++)
684 {
685 for (int v1 = 0 ; v1 < stencil_size ; v1++)
686 {
687 for (int v2 = 0 ; v2 < stencil_size ; v2++)
688 {
689 ptr[s] = chunk.template get<prop>()[Lin_vmpl<typename chunking::type>(k_src+v2,j_src+v1,i)];
690
691 s++;
692 }
693
694 s+= 2*stencil_size;
695 }
696
697 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
698 }
699 }
700};
701
703template<int layout_type, int prop, typename chunking,bool is_cross>
704struct copy_z_3<layout_type,prop,1,chunking,is_cross>
705{
706 template<unsigned int j_src, unsigned int j_dest,unsigned int k_src, unsigned int k_dest , unsigned int N1, typename T, typename chunkType>
707 inline static void copy(T ptr[N1], const chunkType & chunk)
708 {
709 int s = k_dest + j_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1) +
710 1*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*1);
711
712
713 for (int i = 0 ; i < boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value ; i++)
714 {
715 ptr[s] = chunk.template get<prop>()[Lin_vmpl<typename chunking::type>(k_src,j_src,i)];
716
717 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*1);
718 }
719 }
720};
721
723template<int layout_type, int prop, int stencil_size, typename chunking>
724struct copy_z_3<layout_type,prop,stencil_size,chunking,true>
725{
726 template<unsigned int j_src, unsigned int j_dest,unsigned int k_src, unsigned int k_dest , unsigned int N1, typename T, typename chunkType>
727 inline static void copy(T ptr[N1], const chunkType & chunk)
728 {}
729};
730
732template<int layout_type, int prop, int stencil_size, typename chunking,bool is_cross>
734{
735 template<unsigned int i_src, unsigned int i_dest,unsigned int j_src, unsigned int j_dest,unsigned int k_src, unsigned int k_dest , unsigned int N1, typename T, typename chunkType>
736 inline static void copy(T ptr[N1], const chunkType & chunk)
737 {
738 int s = k_dest + j_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) +
739 i_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size);
740
741
742 for (int i = 0 ; i < stencil_size ; i++)
743 {
744 for (int j = 0 ; j < stencil_size ; j++)
745 {
746 for (int k = 0 ; k < stencil_size ; k++)
747 {
748 ptr[s] = chunk.template get<prop>()[Lin_vmpl<typename chunking::type>(k_src+k,j_src+j,i_src+i)];
749
750 s++;
751 }
752
753 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size) - stencil_size;
754 }
755
756 s += (boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*stencil_size) - stencil_size*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*stencil_size);
757 }
758 }
759};
760
762template<int layout_type, int prop, typename chunking,bool is_cross>
763struct copy_corner_3<layout_type,prop,1,chunking,is_cross>
764{
765 template<unsigned int i_src, unsigned int i_dest,unsigned int j_src, unsigned int j_dest,unsigned int k_src, unsigned int k_dest , unsigned int N1, typename T, typename chunkType>
766 inline static void copy(T ptr[N1], const chunkType & chunk)
767 {
768 int s = k_dest + j_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1) +
769 i_dest*(boost::mpl::at<typename chunking::type,boost::mpl::int_<0>>::type::value+2*1)*(boost::mpl::at<typename chunking::type,boost::mpl::int_<1>>::type::value+2*1);
770
771
772 ptr[s] = chunk.template get<prop>()[Lin_vmpl<typename chunking::type>(k_src,j_src,i_src)];
773 }
774};
775
777template<int layout_type, int prop, int stencil_size, typename chunking>
778struct copy_corner_3<layout_type,prop,stencil_size,chunking,true>
779{
780 template<unsigned int i_src, unsigned int i_dest,unsigned int j_src, unsigned int j_dest,unsigned int k_src, unsigned int k_dest , unsigned int N1, typename T, typename chunkType>
781 inline static void copy(T ptr[N1], const chunkType & chunk)
782 {}
783};
784
786
787template<unsigned int dim>
789{
790 unsigned char i;
792};
793
819template<unsigned int dim, unsigned int N, typename chunking>
820void construct_chunk_missalign_map(unsigned char miss_al_map[N],
821 short int mp_off[N],
822 const Box<dim,long int> & b_src,
823 const Box<dim,long int> & b_dst,
825{
826 typedef typename vmpl_create_constant<dim,1>::type one_vmpl;
827
829 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,dim> >(gbs);
830
831 grid_key_dx<dim> k_src = b_src.getKP1();
832 grid_key_dx<dim> k_dst = b_dst.getKP1();
833
836
837 // shift the key
839
840 // shift the key
842
844
845 for (int i = 0 ; i < dim ; i++)
846 {
847 key_sub.set_d(i,kl2.get(i) - kl1.get(i) );
848 }
849
850 int c_id[openfpm::math::pow(2,dim)];
851 size_t sz[dim];
852
853 for (int i = 0 ; i < dim ; i++)
854 {sz[i] = 3;}
855
856 grid_sm<dim,void> gcnk(gbs.sz_block);
858 while (it.isNext())
859 {
860 auto k = it.get();
861
862 int off = 0;
863 int bid = 0;
864 int stride = 1;
865 int stride_off = 1;
866 for (int i = 0 ; i < dim ; i++)
867 {
868 if ((long int)k.get(i) + key_sub.get(i) >= (long int)gbs.sz_block[i])
869 {
870 bid += 2*stride;
871
872 }
873 else if ((long int)k.get(i) + key_sub.get(i) < 0)
874 {
875 bid += 0*stride;
876
877 }
878 else
879 {
880 bid += 1*stride;
881 }
882 off += (openfpm::math::positive_modulo(key_sub.get(i) + k.get(i),gbs.sz_block[i]))*stride_off;
883 stride *= 3;
884 stride_off *= gbs.sz_block[i];
885 }
886
887 miss_al_map[gcnk.LinId(k)] = bid;
888 mp_off[gcnk.LinId(k)] = off;
889
890 ++it;
891 }
892
893 // Filtering: sometime in particular for ghost copy we have a slice to copy, in this case some of the index in the map
894 // are never touched so we can eliminate elements in the vk
895
896 Box<dim,long int> slice;
897
898 // calculate slice
899 for (int i = 0 ; i < dim ; i++)
900 {
901 if (kl1.get(i) + (b_src.getHigh(i) - b_src.getLow(i) + 1) > gbs.sz_block[i])
902 {
903 slice.setLow(i,0);
904 slice.setHigh(i,gbs.sz_block[i]-1);
905 }
906 else
907 {
908 slice.setLow(i,kl1.get(i));
909 slice.setHigh(i,kl1.get(i) + (b_src.getHigh(i) - b_src.getLow(i) + 1));
910 }
911 }
912
913 key_int<dim> l;
914 l.i = 0;
915 l.k.zero();
916 vk.add(l);
917
918 for (int i = 0 ; i < dim ; i++)
919 {
920 if (key_sub.get(i) >= 0)
921 {
922 size_t bord = gbs.sz_block[i] - key_sub.get(i);
923
924 if (slice.getLow(i) < bord)
925 {
926 // set the component
927 for (int j = 0 ; j < vk.size() ; j++)
928 {
929 vk.get(j).k.set_d(i,0);
930 }
931 if (bord <= slice.getHigh(i) )
932 {
933 int n_dup = vk.size();
934
935 // add the other parts with zero
936 for (int j = 0 ; j < n_dup ; j++)
937 {
938 key_int<dim> tmp;
939 tmp.k = vk.get(j).k;
940
941 tmp.k.set_d(i,1);
942
943 vk.add(tmp);
944 }
945 }
946 }
947 else
948 {
949 // set the component
950 for (int j = 0 ; j < vk.size() ; j++)
951 {
952 vk.get(j).k.set_d(i,0);
953 }
954 }
955 }
956 else
957 {
958 size_t bord = -key_sub.get(i);
959
960 if (slice.getLow(i) < bord)
961 {
962 // set the component
963 for (int j = 0 ; j < vk.size() ; j++)
964 {
965 vk.get(j).k.set_d(i,-1);
966 }
967 if (bord <= slice.getHigh(i) )
968 {
969 int n_dup = vk.size();
970
971 // add the other parts with zero
972 for (int j = 0 ; j < n_dup ; j++)
973 {
974 key_int<dim> tmp;
975 tmp.k = vk.get(j).k;
976
977 tmp.k.set_d(i,0);
978
979 vk.add(tmp);
980 }
981 }
982 }
983 else
984 {
985 // set the component
986 for (int j = 0 ; j < vk.size() ; j++)
987 {
988 vk.get(j).k.set_d(i,0);
989 }
990 }
991 }
992
993/* size_t bord = (gbs.sz_block[i] - key_sub.get(i));
994
995 if (slice.getLow(i) < (gbs.sz_block[i] - key_sub.get(i)))
996 {
997 // set the component
998 for (int j = 0 ; j < vk.size() ; j++)
999 {
1000 vk.get(j).k.set_d(i,0);
1001 }
1002 if ((gbs.sz_block[i] - key_sub.get(i)) <= slice.getHigh(i) )
1003 {
1004 int n_dup = vk.size();
1005
1006 // add the other parts with zero
1007 for (int j = 0 ; j < n_dup ; j++)
1008 {
1009 key_int<dim> tmp;
1010 tmp.k = vk.get(j).k;
1011
1012 tmp.k.set_d(i,0);
1013
1014 vk.add(tmp);
1015 }
1016 }
1017 }
1018 else
1019 {
1020 // set the component
1021 for (int j = 0 ; j < vk.size() ; j++)
1022 {
1023 vk.get(j).k.set_d(i,0);
1024 }
1025 }*/
1026 }
1027}
1028
1029
1030template<typename SparseGridType>
1031void copy_remove_to_impl(const SparseGridType & grid_src,
1032 SparseGridType & grid_dst,
1035{
1037
1039 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,SparseGridType::dims> >(gbs);
1040
1041 typedef typename vmpl_reduce_prod<typename SparseGridType::chunking_type::type>::type sizeBlock;
1042
1043 unsigned char miss_al_map[sizeBlock::value];
1044 short int mp_off[sizeBlock::value];
1045
1047
1048 construct_chunk_missalign_map<SparseGridType::dims,
1049 sizeBlock::value,
1050 typename SparseGridType::chunking_type>
1051 (miss_al_map,mp_off,
1052 b_src,b_dst,vk);
1053
1054 // Now we intersect every chunk source
1055
1058
1059 auto & data_src = grid_src.private_get_data();
1060 auto & header_src = grid_src.private_get_header();
1061
1062 auto & data_dst = grid_src.private_get_data();
1063 auto & header_dst = grid_src.private_get_header();
1064
1066
1067 int chunk_pos[openfpm::math::pow(2,SparseGridType::dims)];
1068
1069 for (int i = 0 ; i < header_src.size() ; i++)
1070 {
1071 for (int j = 0 ; j < SparseGridType::dims ; j++)
1072 {
1073 b_c.setLow(j,header_src.get(i).pos.get(j));
1074 b_c.setHigh(j,header_src.get(i).pos.get(j) + gbs.sz_block[j] - 1);
1075 }
1076
1077 bool inte = b_src.Intersect(b_c,b_inte);
1078
1079 if (inte == true)
1080 {
1081 // Prepare destination chunks
1082
1083 for (int s = 0 ; s < vk.size() ; s++)
1084 {
1085 chunk_pos[vk.get(s).i] = grid_dst.getChunkCreate();
1086 }
1087
1088 grid_key_dx_iterator_sub<SparseGridType::dims> it(gb,b_inte.getKP1(),b_inte.getKP2());
1089
1090 auto & block_src = data_src.get(i);
1091
1092 while (it.isNext())
1093 {
1094 auto id = gb.LinId(it.get());
1095
1096 int dest_bid = chunk_pos[miss_al_map[id]];
1097
1098 data_dst.get(dest_bid)[mp_off[id]] = block_src[i];
1099
1100 ++it;
1101 }
1102 }
1103 }
1104}
1105
1106#endif /* SPARSEGRID_CHUNK_COPY_HPP_ */
This class represent an N-dimensional box.
Definition Box.hpp:61
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
Definition Box.hpp:556
__device__ __host__ bool Intersect(const Box< dim, T > &b, Box< dim, T > &b_out) const
Intersect.
Definition Box.hpp:95
__device__ __host__ T getHigh(int i) const
get the high interval of the box
Definition Box.hpp:567
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
Definition Box.hpp:544
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
Definition Box.hpp:533
grid_key_dx< dim > getKP1() const
Get the point p1 as grid_key_dx.
Definition Box.hpp:656
Declaration grid_key_dx_iterator_sub.
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
void zero()
Set to zero the key.
Definition grid_key.hpp:170
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
Definition grid_key.hpp:516
__device__ __host__ index_type get(index_type i) const
Get the i index.
Definition grid_key.hpp:503
Declaration grid_sm.
Definition grid_sm.hpp:167
mem_id LinId(const grid_key_dx< N, ids_type > &gk, const signed char sum_id[N]) const
Linearization of the grid_key_dx with a specified shift.
Definition grid_sm.hpp:454
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Copy point in 3D.
Copy x edge in 3D.
Copy XY surface in 3D.
Copy block in 3D.
Copy XZ surface in 3D.
Copy y edge in 3D.
Copy YZ surface in 3D.
Copy z edge in 3D.
this class is a functor for "for_each" algorithm
size_t sz_block[dim]
sizes
to_variadic_const_impl< 1, N, M, exit_::value, M >::type type
generate the boost::fusion::vector apply H on each term