OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
grid_sm.hpp
1#ifndef GRID_HPP
2#define GRID_HPP
3
4
5#include "config.h"
6#include "util/cuda_launch.hpp"
7#include <boost/shared_array.hpp>
8#include <vector>
9#include <initializer_list>
10#include <array>
11#include "memory/memory.hpp"
12#include "Space/Shape/Box.hpp"
13#include "grid_key.hpp"
14#include <iostream>
15#include "util/mathutil.hpp"
16#include "iterators/stencil_type.hpp"
17
18
19// Box need the definition of grid_key_dx_r
20#define HARDWARE 1
21
22
24{
25 template<typename SparseGrid_type>
26 __device__ __host__ bool check(SparseGrid_type & sggt,unsigned int dataBlockPos, unsigned int offset)
27 {
28 return true;
29 }
30};
31
32template<unsigned int dim, typename T>
34{
35 Box<dim,T> box;
36
37 template<typename T2>
38 explicit Box_check(Box<dim,T2> & box)
39 :box(box)
40 {}
41
42 template<typename SparseGridGpu_type>
43 __device__ __host__ bool check(SparseGridGpu_type & sggt,unsigned int dataBlockId, unsigned int offset)
44 {
45 auto key = sggt.getCoord(dataBlockId,offset);
46
47 return box.isInsideKey(key);
48 }
49};
50
51
59{
60public:
69 static bool valid(size_t v_id, size_t sz)
70 {
71 return true;
72 }
73};
74
82{
83public:
94 static bool valid(size_t v_id, size_t sz)
95 {
96 return v_id < sz;
97 }
98};
99
100template<unsigned int dim>
102{
103#if defined(CUDA_GPU)
104
105 dim3 thr;
106 dim3 wthr;
107
110
111 size_t nblocks() const
112 {
113 return wthr.x * wthr.y * wthr.z;
114 }
115
116 size_t nthrs() const
117 {
118 return thr.x * thr.y * thr.z;
119 }
120
121#endif
122};
123
124template<unsigned int dim>
125bool has_work_gpu(ite_gpu<dim> & ite)
126{
127 size_t tot_work = 1;
128
129 if (dim == 1)
130 {tot_work *= ite.wthr.x * ite.thr.x;}
131 else if(dim == 2)
132 {
133 tot_work *= ite.wthr.x * ite.thr.x;
134 tot_work *= ite.wthr.y * ite.thr.y;
135 }
136 else
137 {
138 tot_work *= ite.wthr.x * ite.thr.x;
139 tot_work *= ite.wthr.y * ite.thr.y;
140 tot_work *= ite.wthr.z * ite.thr.z;
141 }
142
143 return tot_work != 0;
144}
145
147template<unsigned int N, typename T> class grid_sm;
148
149template<unsigned int dim, typename grid_sm_type, typename T>
150ite_gpu<dim> getGPUIterator_impl(const grid_sm_type & g1, const grid_key_dx<dim,T> & key1, const grid_key_dx<dim,T> & key2, size_t n_thr = default_kernel_wg_threads_);
151
153template <unsigned int dim, typename linearizer> class print_warning_on_adjustment;
154
156template<unsigned int dim,typename stencil=no_stencil, typename linearizer = grid_sm<dim,void>, typename warn=print_warning_on_adjustment<dim,linearizer>> class grid_key_dx_iterator_sub;
157
165template<unsigned int N, typename T>
167{
170
172 size_t size_tot;
173
175 size_t sz[N];
176
178 size_t sz_s[N];
179
189 __device__ __host__ inline void Initialize(const size_t sz)
190 {
192 sz_s[0] = sz;
193 this->sz[0] = sz;
194
195 // set the box
196 box.setHigh(0,sz);
197 box.setLow(0,0);
198
199 for (size_t i = 1 ; i < N ; i++)
200 {
201 /* coverity[dead_error_begin] */
202 sz_s[i] = sz*sz_s[i-1];
203 this->sz[i] = sz;
204
205 // set the box
206 box.setHigh(i,sz);
207 box.setLow(i,0);
208 }
209 }
210
220 __device__ __host__ inline void Initialize(const size_t (& sz)[N])
221 {
223 sz_s[0] = sz[0];
224 this->sz[0] = sz[0];
225
226 // set the box
227 box.setHigh(0,sz[0]);
228 box.setLow(0,0);
229
230 for (size_t i = 1 ; i < N ; i++)
231 {
232 /* coverity[dead_error_begin] */
233 sz_s[i] = sz[i]*sz_s[i-1];
234 this->sz[i] = sz[i];
235
236 // set the box
237 box.setHigh(i,sz[i]);
238 box.setLow(i,0);
239 }
240 }
241
248 inline void Initialize()
249 {
251 sz_s[0] = 0;
252 this->sz[0] = 0;
253
254 // set the box
255 box.setHigh(0,0);
256 box.setLow(0,0);
257
258 for (size_t i = 1 ; i < N ; i++)
259 {
260 /* coverity[dead_error_begin] */
261 sz_s[i] = sz[i]*sz_s[i-1];
262
263 // set the box
264 box.setHigh(i,sz[i]);
265 box.setLow(i,0);
266 }
267 }
268
274 template<typename a, typename ...lT>
275 __device__ __host__ inline mem_id Lin_impl(a v,lT...t) const
276 {
277 return v*sz_s[sizeof...(t)-1] + Lin_impl(t...);
278 }
279
281 template<typename a> __device__ __host__ inline mem_id Lin_impl(a v) const
282 {
283 return v;
284 }
285
286public:
287
288
294 inline Box<N,size_t> getBox() const
295 {
296 return box;
297 }
298
308 inline const Box<N,size_t> getBoxKey() const
309 {
310 Box<N,size_t> bx;
311
312 for (size_t i = 0 ; i < N ; i++)
313 {
314 bx.setLow(i,box.getLow(i));
315 bx.setHigh(i,box.getHigh(i) - 1);
316 }
317
318 return bx;
319 }
320
326 inline void setDimensions(const size_t (& dims)[N])
327 {
328 Initialize(dims);
329 size_tot = totalSize(dims);
330 }
331
338 inline grid_sm()
339 :size_tot(0)
340 {
341 // Initialize sz
342 for (size_t i = 0 ; i < N ; i++)
343 {sz[i] = 0;}
344
345 Initialize();
346 }
347
356 template<typename S>
357 __device__ __host__ inline grid_sm(const grid_sm<N,S> & g)
358 {
359 size_tot = g.size_tot;
360
361 for (size_t i = 0 ; i < N ; i++)
362 {
363 sz[i] = g.sz[i];
364 sz_s[i] = g.sz_s[i];
365 }
366 }
367
376 __device__ __host__ inline grid_sm(const grid_sm<N,T> & g)
377 {
378 size_tot = g.size_tot;
379
380 for (size_t i = 0 ; i < N ; i++)
381 {
382 sz[i] = g.sz[i];
383 sz_s[i] = g.sz_s[i];
384 }
385 }
386
387 // Static element to calculate total size
388
389 inline size_t totalSize(const size_t sz)
390 {
391 size_t tSz = 1;
392
393 for (size_t i = 0 ; i < N ; i++)
394 {
395 tSz *= sz;
396 }
397
398 return tSz;
399 }
400
401 // Static element to calculate total size
402
403 __device__ __host__ inline size_t totalSize(const size_t (& sz)[N])
404 {
405 size_t tSz = 1;
406
407 for (size_t i = 0 ; i < N ; i++)
408 {
409 tSz *= sz[i];
410 }
411
412 return tSz;
413 }
414
415
424 inline grid_sm(const size_t & sz)
425 : size_tot(totalSize(sz))
426 {
427 Initialize(sz);
428 }
429
438 __device__ __host__ inline grid_sm(const size_t (& sz)[N])
439 : size_tot(totalSize(sz))
440 {
441 Initialize(sz);
442 }
443
453 template<typename check=NoCheck, typename ids_type>
454 inline mem_id LinId(const grid_key_dx<N,ids_type> & gk, const signed char sum_id[N]) const
455 {
456 mem_id lid;
457
458 // Check the sum produce a valid key
459
460 if (check::valid(gk.get(0) + sum_id[0],sz[0]) == false)
461 return -1;
462
463 lid = gk.get(0) + sum_id[0];
464
465
466 for (mem_id i = 1 ; i < N ; i++)
467 {
468 // Check the sum produce a valid key
469
470 if (check::valid(gk.get(i) + sum_id[i],sz[i]) == false)
471 return -1;
472
473 lid += (gk.get(i) + sum_id[i]) * sz_s[i-1];
474 }
475
476 return lid;
477 }
478
489 template<typename check=NoCheck,typename ids_type>
490 inline mem_id LinId(const grid_key_dx<N,ids_type> & gk, const signed char sum_id[N], const size_t (&bc)[N]) const
491 {
492 mem_id lid;
493
494 // Check the sum produce a valid key
495
496 if (bc[0] == NON_PERIODIC)
497 {
498 if (check::valid(gk.get(0) + sum_id[0],sz[0]) == false)
499 return -1;
500
501 lid = gk.get(0) + sum_id[0];
502 }
503 else
504 {
505 lid = openfpm::math::positive_modulo(gk.get(0) + sum_id[0],sz[0]);
506 }
507
508 for (mem_id i = 1 ; i < N ; i++)
509 {
510 // Check the sum produce a valid key
511
512 /* coverity[dead_error_line] */
513 if (bc[i] == NON_PERIODIC)
514 {
515 if (check::valid(gk.get(i) + sum_id[i],sz[i]) == false)
516 return -1;
517
518 lid += (gk.get(i) + sum_id[i]) * sz_s[i-1];
519 }
520 else
521 {
522 lid += (openfpm::math::positive_modulo(gk.get(i) + sum_id[i],sz[i])) * sz_s[i-1];
523 }
524 }
525
526 return lid;
527 }
528
537 inline mem_id LinIdPtr(size_t * k) const
538 {
539 mem_id lid = k[0];
540 for (mem_id i = 1 ; i < N ; i++)
541 {
542 lid += k[i] * sz_s[i-1];
543 }
544
545 return lid;
546 }
547
557 __device__ __host__ inline mem_id LinId(const size_t (& k)[N]) const
558 {
559 mem_id lid = k[0];
560 for (mem_id i = 1 ; i < N ; i++)
561 {
562 /* coverity[dead_error_line] */
563 lid += k[i] * sz_s[i-1];
564 }
565
566 return lid;
567 }
568
578 template<typename ids_type> __device__ __host__ inline mem_id LinId(const grid_key_dx<N,ids_type> & gk) const
579 {
580 mem_id lid = gk.get(0);
581 for (mem_id i = 1 ; i < N ; i++)
582 {
583 /* coverity[dead_error_line] */
584 lid += gk.get(i) * sz_s[i-1];
585 }
586
587 return lid;
588 }
589
595 template<typename a, typename ...lT, typename enabler = typename std::enable_if<sizeof...(lT) == N-1>::type >
596 __device__ __host__ inline mem_id Lin(a v,lT...t) const
597 {
598 return v*sz_s[sizeof...(t)-1] + Lin_impl(t...);
599 }
600
602
609 __device__ __host__ inline grid_key_dx<N> InvLinId(mem_id id) const
610 {
611 // Inversion of linearize
612
614
615 for (mem_id i = 0 ; i < N ; i++)
616 {
617 gk.set_d(i,id % sz[i]);
618 id /= sz[i];
619 }
620
621 return gk;
622 }
623
624
634 //#pragma openfpm layout(get)
635 inline mem_id LinId(mem_id * id) const
636 {
637 mem_id lid = 0;
638 lid += id[0];
639 for (mem_id i = 1 ; i < N ; i++)
640 {
641 lid += id[i] * sz_s[i-1];
642 }
643
644 return lid;
645 }
646
648 __device__ __host__ ~grid_sm() {};
649
657 __device__ __host__ inline size_t size() const
658 {
659 return size_tot;
660 };
661
668 __device__ __host__ inline grid_sm<N,T> & operator=(const grid_sm<N,T> & g)
669 {
670 size_tot = g.size_tot;
671
672 for (size_t i = 0 ; i < N ; i++)
673 {
674 sz[i] = g.sz[i];
675 sz_s[i] = g.sz_s[i];
676 }
677
678 box = g.box;
679
680 return *this;
681 }
682
691 inline bool operator==(const grid_sm<N,T> & g)
692 {
693 for (size_t i = 0 ; i < N ; i++)
694 {
695 if (sz[i] != g.sz[i])
696 return false;
697 }
698
699#ifdef SE_CLASS1
700
701 if (size_tot != g.size_tot)
702 return false;
703
704 for (size_t i = 0 ; i < N ; i++)
705 {
706 if (sz_s[i] != g.sz_s[i])
707 return false;
708 }
709
710#endif
711 return true;
712 }
713
720 inline bool operator!=(const grid_sm<N,T> & g)
721 {
722 return ! this->operator==(g);
723 }
724
736 __device__ __host__ inline size_t size_s(unsigned int i) const
737 {
738 return sz_s[i];
739 }
740
750 __device__ __host__ inline size_t size(unsigned int i) const
751 {
752 return sz[i];
753 }
754
760 __device__ __host__ inline const size_t (& getSize() const)[N]
761 {
762 return sz;
763 }
764
770 __device__ __host__ inline void getSize(size_t (&size) [N]) const
771 {
772 for (size_t i = 0; i < N; ++i) size[i] = sz[i];
773 }
774
784 {
785 return grid_key_dx_iterator_sub<N>(*this,start,stop);
786 }
787
788#if defined(CUDA_GPU)
789
796 template<typename T2>
797 struct ite_gpu<N> getGPUIterator(const grid_key_dx<N,T2> & key1, const grid_key_dx<N,T2> & key2, size_t n_thr = default_kernel_wg_threads_) const
798 {
799 return getGPUIterator_impl<N>(*this,key1,key2,n_thr);
800 }
801
808 struct ite_gpu<N> getGPUIterator(size_t n_thr = default_kernel_wg_threads_) const
809 {
812
813 for (size_t i = 0 ; i < N ; i++)
814 {
815 k1.set_d(i,0);
816 k2.set_d(i,size(i));
817 }
818
819 return getGPUIterator_impl<N>(*this,k1,k2,n_thr);
820 }
821
822#endif
823
829 inline void swap(grid_sm<N,T> & g)
830 {
831 size_t tmp = size_tot;
832 size_tot = g.size_tot;
833 g.size_tot = tmp;
834
835 for (size_t i = 0 ; i < N ; i++)
836 {
837 tmp = sz[i];
838 sz[i] = g.sz[i];
839 g.sz[i] = tmp;
840
841 tmp = sz_s[i];
842 sz_s[i] = g.sz_s[i];
843 g.sz_s[i] = tmp;
844 }
845 }
846
852 std::string toString() const
853 {
854 std::stringstream str;
855
856 for (size_t i = 0 ; i < N ; i++)
857 str << "sz[" << i << "]=" << size(i) << " ";
858
859 return str.str();
860 }
861
863 template <unsigned int,typename> friend class grid_sm;
864};
865
866
867template<unsigned int dim, typename grid_sm_type, typename T>
868ite_gpu<dim> getGPUIterator_impl(const grid_sm_type & g1, const grid_key_dx<dim,T> & key1, const grid_key_dx<dim,T> & key2, const size_t n_thr)
869{
870 size_t tot_work = 1;
871 for (size_t i = 0 ; i < dim ; i++)
872 {tot_work *= key2.get(i) - key1.get(i) + 1;}
873
874 size_t n = (tot_work <= n_thr)?openfpm::math::round_big_2(tot_work):n_thr;
875
876 // Work to do
877 ite_gpu<dim> ig;
878
879 if (tot_work == 0)
880 {
881 ig.thr.x = 0;
882 ig.thr.y = 0;
883 ig.thr.z = 0;
884
885 ig.wthr.x = 0;
886 ig.wthr.y = 0;
887 ig.wthr.z = 0;
888
889 return ig;
890 }
891
892 ig.thr.x = 1;
893 ig.thr.y = 1;
894 ig.thr.z = 1;
895
896 int dir = 0;
897
898 while (n != 1)
899 {
900 if (dir % 3 == 0)
901 {ig.thr.x = ig.thr.x << 1;}
902 else if (dir % 3 == 1)
903 {ig.thr.y = ig.thr.y << 1;}
904 else if (dir % 3 == 2)
905 {ig.thr.z = ig.thr.z << 1;}
906
907 n = n >> 1;
908
909 dir++;
910 dir %= dim;
911 }
912
913 if (dim >= 1)
914 {ig.wthr.x = (key2.get(0) - key1.get(0) + 1) / ig.thr.x + (((key2.get(0) - key1.get(0) + 1)%ig.thr.x != 0)?1:0);}
915
916 if (dim >= 2)
917 {ig.wthr.y = (key2.get(1) - key1.get(1) + 1) / ig.thr.y + (((key2.get(1) - key1.get(1) + 1)%ig.thr.y != 0)?1:0);}
918 else
919 {ig.wthr.y = 1;}
920
921 if (dim >= 3)
922 {
923 // Roll the other dimensions on z
924 ig.wthr.z = 1;
925 for (size_t i = 2 ; i < dim ; i++)
926 {ig.wthr.z *= (key2.get(i) - key1.get(i) + 1) / ig.thr.z + (((key2.get(i) - key1.get(i) + 1)%ig.thr.z != 0)?1:0);}
927 }
928 else
929 {ig.wthr.z = 1;}
930
931 // crop if wthr == 1
932
933 if (dim >= 1 && ig.wthr.x == 1)
934 {ig.thr.x = (key2.get(0) - key1.get(0) + 1);}
935
936 if (dim >= 2 && ig.wthr.y == 1)
937 {ig.thr.y = key2.get(1) - key1.get(1) + 1;}
938
939 if (dim == 3 && ig.wthr.z == 1)
940 {ig.thr.z = key2.get(2) - key1.get(2) + 1;}
941
942 for (size_t i = 0 ; i < dim ; i++)
943 {
944 ig.start.set_d(i,key1.get(i));
945 ig.stop.set_d(i,key2.get(i));
946 }
947
948 return ig;
949}
950
951
959{
960 size_t dim;
961
962public:
963
970 size_t getDim()
971 {
972 return dim;
973 }
974
981 :dim(key.dim)
982 {
983 // Allocate the key
984 k = new mem_id[dim];
985
986 // Copy the key
987 for(unsigned int i = 0 ; i < dim ; i++)
988 {
989 k[i] = key.k[i];
990 }
991 }
992
1000 grid_key_dx_r(size_t dim)
1001 :dim(dim)
1002 {
1003 // Allocate the key
1004 k = new mem_id[dim];
1005 }
1006
1008 {
1009 delete [] k;
1010 }
1011
1013 template<typename a, typename ...T>void set(a v, T...t)
1014 {
1015 k[dim-1] = v;
1016 invert_assign(t...);
1017 }
1018
1028 mem_id get(size_t i)
1029 {
1030 return k[i];
1031 }
1032
1041 void set_d(size_t i, mem_id id)
1042 {
1043 k[i] = id;
1044 }
1045
1047 mem_id * k;
1048
1049private:
1050
1056 template<typename a, typename ...T>void invert_assign(a v,T...t)
1057 {
1058 k[sizeof...(T)] = v;
1059 invert_assign(t...);
1060 }
1061
1062 template<typename a, typename ...T>void invert_assign(a v)
1063 {
1064 k[0] = v;
1065 }
1066
1067 void invert_assign()
1068 {
1069 }
1070
1071};
1072
1073
1082{
1083 size_t dim;
1084
1086 size_t sz;
1087
1088 // Actual grid_key position
1089 grid_key_dx_r gk;
1090
1091public:
1092
1099 size_t getDim()
1100 {
1101 return dim;
1102 }
1103
1111 Iterator_g_const(size_t n, size_t sz)
1112 :dim(n),sz(sz),gk(n)
1113 {
1114 // fill gk with the first grid element that satisfied the constrain: 0,1,2,3... dim
1115
1116 for (size_t i = 0 ; i < dim ; i++)
1117 {
1118 gk.set_d(i,dim-i-1);
1119 }
1120 }
1121
1131 {
1133
1134 gk.set_d(0,gk.get(0)+1);
1135
1137
1138 unsigned int i = 0;
1139 for ( ; i < dim-1 ; i++)
1140 {
1141 size_t id = gk.get(i);
1142 if (id >= sz)
1143 {
1144 // ! overflow, increment the next index
1145
1146 id = gk.get(i+1);
1147 if (id+i+2 >= sz)
1148 {
1149 // there is no-way to produce a valid key
1150 // there is not need to check the previous index
1151 // overflow i+1
1152
1153 gk.set_d(i+1,sz);
1154 }
1155 else
1156 {
1157
1158 // reinitialize the previous index
1159
1160 for (unsigned int s = 0 ; s <= i+1 ; s++)
1161 {
1162 gk.set_d(i+1-s,id+1+s);
1163 }
1164 }
1165 }
1166 else
1167 {
1168 break;
1169 }
1170 }
1171
1172 return *this;
1173 }
1174
1183 bool isNext()
1184 {
1185 // If dimensionless return immediately
1186 if (dim == 0)
1187 return false;
1188
1189 if (gk.get(dim-1) < static_cast<mem_id>(sz-dim+1))
1190 {
1192
1193 return true;
1194 }
1195
1197 return false;
1198 }
1199
1209 {
1210 return gk;
1211 }
1212};
1213
1214#endif
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__ 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__ bool isInsideKey(const KeyType &k) const
Check if the point is inside the region (Border included)
Definition Box.hpp:1153
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
Definition Box.hpp:533
Class to check if the edge can be created or not.
Definition grid_sm.hpp:82
static bool valid(size_t v_id, size_t sz)
Check if vertex exist.
Definition grid_sm.hpp:94
size_t getDim()
Get the dimensionality of the iterator.
Definition grid_sm.hpp:1099
bool isNext()
Check if there is the next element.
Definition grid_sm.hpp:1183
Iterator_g_const(size_t n, size_t sz)
Constructor.
Definition grid_sm.hpp:1111
grid_key_dx_r & get()
Return the actual key.
Definition grid_sm.hpp:1208
Iterator_g_const & operator++()
Get the next element.
Definition grid_sm.hpp:1130
size_t sz
size of the grid (the grid is assumed a square so equal on each dimension)
Definition grid_sm.hpp:1086
Class to check if the edge can be created or not.
Definition grid_sm.hpp:59
static bool valid(size_t v_id, size_t sz)
No check is performed.
Definition grid_sm.hpp:69
Declaration grid_key_dx_iterator_sub.
Emulate grid_key_dx with runtime dimensionality.
Definition grid_sm.hpp:959
void set_d(size_t i, mem_id id)
Set the i index.
Definition grid_sm.hpp:1041
grid_key_dx_r(size_t dim)
constructor
Definition grid_sm.hpp:1000
mem_id * k
structure that store all the index
Definition grid_sm.hpp:1047
mem_id get(size_t i)
get the i index
Definition grid_sm.hpp:1028
void set(a v, T...t)
set the grid key from a list of numbers
Definition grid_sm.hpp:1013
size_t getDim()
Get the dimensionality of the key.
Definition grid_sm.hpp:970
void invert_assign(a v, T...t)
Recursively invert the assignment.
Definition grid_sm.hpp:1056
grid_key_dx_r(grid_key_dx_r &key)
constructor from another key
Definition grid_sm.hpp:980
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
__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
__device__ __host__ grid_key_dx< N > InvLinId(mem_id id) const
Construct.
Definition grid_sm.hpp:609
void setDimensions(const size_t(&dims)[N])
Reset the dimension of the grid.
Definition grid_sm.hpp:326
__device__ __host__ grid_sm(const size_t(&sz)[N])
Construct a grid of a specified size.
Definition grid_sm.hpp:438
size_t size_tot
total number of the elements in the grid
Definition grid_sm.hpp:172
mem_id LinId(mem_id *id) const
Linearization of an array of mem_id (long int)
Definition grid_sm.hpp:635
__device__ __host__ void Initialize(const size_t sz)
Initialize the basic structure.
Definition grid_sm.hpp:189
grid_sm(const size_t &sz)
Construct a grid of a specified size.
Definition grid_sm.hpp:424
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
__device__ __host__ grid_sm< N, T > & operator=(const grid_sm< N, T > &g)
Copy the grid from another grid.
Definition grid_sm.hpp:668
__device__ __host__ void Initialize(const size_t(&sz)[N])
Initialize the basic structure.
Definition grid_sm.hpp:220
__device__ __host__ const size_t(& getSize() const)[N]
Return the size of the grid as an array.
Definition grid_sm.hpp:760
__device__ __host__ void getSize(size_t(&size)[N]) const
Returns the size of the grid in the passed array.
Definition grid_sm.hpp:770
__device__ __host__ mem_id Lin_impl(a v, lT...t) const
linearize an arbitrary set of index
Definition grid_sm.hpp:275
const Box< N, size_t > getBoxKey() const
Return the box enclosing the grid.
Definition grid_sm.hpp:308
__device__ __host__ size_t size_s(unsigned int i) const
Definition grid_sm.hpp:736
mem_id LinIdPtr(size_t *k) const
Linearization of the set of indexes.
Definition grid_sm.hpp:537
grid_sm()
Default constructor.
Definition grid_sm.hpp:338
Box< N, size_t > box
Box enclosing the grid.
Definition grid_sm.hpp:169
__device__ __host__ ~grid_sm()
Destructor.
Definition grid_sm.hpp:648
bool operator!=(const grid_sm< N, T > &g)
Check if the two grid_sm are the same.
Definition grid_sm.hpp:720
void swap(grid_sm< N, T > &g)
swap the grid_sm informations
Definition grid_sm.hpp:829
grid_key_dx_iterator_sub< N > getSubIterator(const grid_key_dx< N > &start, const grid_key_dx< N > &stop) const
Return a sub-grid iterator.
Definition grid_sm.hpp:783
size_t sz_s[N]
size of the grid on each stride (used for linearization)
Definition grid_sm.hpp:178
void Initialize()
Initialize the basic structure.
Definition grid_sm.hpp:248
__device__ __host__ size_t size() const
Return the size of the grid.
Definition grid_sm.hpp:657
friend class grid_sm
It simply mean that all the classes grid are friend of all its specialization.
Definition grid_sm.hpp:863
__device__ __host__ mem_id LinId(const grid_key_dx< N, ids_type > &gk) const
Linearization of the grid_key_dx.
Definition grid_sm.hpp:578
std::string toString() const
Produce a string from the object.
Definition grid_sm.hpp:852
bool operator==(const grid_sm< N, T > &g)
Check if the two grid_sm are the same.
Definition grid_sm.hpp:691
size_t sz[N]
size of the grid
Definition grid_sm.hpp:175
__device__ __host__ grid_sm(const grid_sm< N, T > &g)
copy constructor
Definition grid_sm.hpp:376
__device__ __host__ mem_id Lin_impl(a v) const
Linearize a set of index.
Definition grid_sm.hpp:281
__device__ __host__ size_t size(unsigned int i) const
Definition grid_sm.hpp:750
__device__ __host__ grid_sm(const grid_sm< N, S > &g)
construct a grid from another grid
Definition grid_sm.hpp:357
Box< N, size_t > getBox() const
Return the box enclosing the grid.
Definition grid_sm.hpp:294
mem_id LinId(const grid_key_dx< N, ids_type > &gk, const signed char sum_id[N], const size_t(&bc)[N]) const
Linearization of the grid_key_dx with a specified shift.
Definition grid_sm.hpp:490
__device__ __host__ mem_id LinId(const size_t(&k)[N]) const
Linearization of the grid_key_dx.
Definition grid_sm.hpp:557
__device__ __host__ mem_id Lin(a v, lT...t) const
linearize an arbitrary set of index
Definition grid_sm.hpp:596
Declaration print_warning_on_adjustment.
Definition ids.hpp:169