8 #ifndef OPENFPM_DATA_SRC_GRID_GRID_BASE_IMPLEMENTATION_HPP_
9 #define OPENFPM_DATA_SRC_GRID_GRID_BASE_IMPLEMENTATION_HPP_
11 #include "grid_base_impl_layout.hpp"
12 #include "util/cuda_util.hpp"
13 #include "cuda/cuda_grid_gpu_funcs.cuh"
14 #include "util/create_vmpl_sequence.hpp"
15 #include "util/object_si_di.hpp"
17 constexpr
int DATA_ON_HOST = 32;
18 constexpr
int DATA_ON_DEVICE = 64;
19 constexpr
int EXACT_RESIZE = 128;
21 template<
bool np,
typename T>
35 return T::noPointers();
42 struct copy_ndim_grid_device_active_impl
44 template<
typename gr
id_type1,
typename gr
id_type2,
typename ite_gpu_type>
45 static inline void copy(grid_type1 & g1, grid_type2 & g2, ite_gpu_type & ite)
50 template<
typename gr
id_type1,
typename gr
id_type2,
typename ite_gpu_type>
51 static inline void copy_block(grid_type1 & g1, grid_type2 & g2, ite_gpu_type & ite)
57 struct copy_ndim_grid_device_active_impl<true>
59 template<
typename gr
id_type1,
typename gr
id_type2,
typename ite_gpu_type>
60 static inline void copy(grid_type1 & g1, grid_type2 & g2, ite_gpu_type & ite)
62 CUDA_LAUNCH((copy_ndim_grid_device<grid_type1::dims,decltype(g1.toKernel())>),ite,g2.toKernel(),g1.toKernel());
65 template<
typename gr
id_type1,
typename gr
id_type2,
typename ite_gpu_type>
66 static inline void copy_block(grid_type1 & g1, grid_type2 & g2, ite_gpu_type & ite)
68 CUDA_LAUNCH((copy_ndim_grid_block_device<grid_type1::dims,decltype(g1.toKernel())>),ite,g2.toKernel(),g1.toKernel());
72 template<
typename S,
typename gr
id_dst_type,
typename gr
id_src_type>
73 void copy_grid_to_grid(grid_dst_type & gdst,
const grid_src_type & gsrc,
77 if (grid_dst_type::dims <= 3)
79 auto ite = gsrc.getGPUIterator(start,stop);
80 bool has_work = has_work_gpu(ite);
86 copy_ndim_grid_device_active_impl<S::isDeviceHostSame() ==
false>::copy(gdst,gsrc,ite);
90 move_work_to_blocks(ite);
92 ite.thr.x = blockSize;
94 copy_ndim_grid_device_active_impl<S::isDeviceHostSame() ==
false>::copy_block(gdst,gsrc,ite);
103 stop.
set_d(0,gsrc.getGrid().size());
106 sz[0]= gsrc.getGrid().size();
110 auto ite = getGPUIterator_impl<1>(g_sm_copy,start,stop);
112 copy_ndim_grid_device_active_impl<S::isDeviceHostSame() ==
false>::copy(gdst,gsrc,ite);
118 template<
typename dest_type,
typename src_type,
unsigned int ... prp>
121 #ifdef CUDIFY_USE_OPENMP
122 auto lamb = [&dst,&src,&ite] __device__ (dim3 & blockIdx, dim3 & threadIdx)
126 if (dest_type::dims == 1)
128 i.
set_d(0,blockIdx.x*blockDim.x + threadIdx.x + ite.start.get(0));
129 if (i.
get(0) >= src.size(0)) {
return;}
131 else if (dest_type::dims == 2)
133 i.
set_d(0,blockIdx.x*blockDim.x + threadIdx.x + ite.start.get(0));
134 i.
set_d(1,blockIdx.y*blockDim.y + threadIdx.y + ite.start.get(1));
135 if (i.
get(0) >= src.size(0) || i.
get(1) >= src.size(1)) {
return;}
137 else if (dest_type::dims == 3)
139 i.
set_d(0,blockIdx.x*blockDim.x + threadIdx.x + ite.start.get(0));
140 i.
set_d(1,blockIdx.y*blockDim.y + threadIdx.y + ite.start.get(1));
141 i.
set_d(2,blockIdx.z*blockDim.z + threadIdx.z + ite.start.get(2));
142 if (i.
get(0) >= src.size(0) || i.
get(1) >= src.size(1) || i.
get(2) >= src.size(2)) {
return;}
145 object_si_di<decltype(src.get_o(i)),decltype(dst.get_o(i)),OBJ_ENCAP,prp ...>(src.get_o(i),dst.get_o(i));
148 CUDA_LAUNCH_LAMBDA(ite,lamb);
150 std::cout << __FILE__ <<
":" << __LINE__ <<
" error CUDA on back end is disabled" << std::endl;
157 #define GRID_ID_3_RAW(start,stop) int x[3] = {threadIdx.x + blockIdx.x * blockDim.x + start.get(0),\
158 threadIdx.y + blockIdx.y * blockDim.y + start.get(1),\
159 threadIdx.z + blockIdx.z * blockDim.z + start.get(2)};\
161 if (x[0] > stop.get(0) || x[1] > stop.get(1) || x[2] > stop.get(2))\
164 #define GRID_ID_3_TRAW(start,stop) int tx = threadIdx.x + blockIdx.x * blockDim.x + start.get(0);\
165 int ty = threadIdx.y + blockIdx.y * blockDim.y + start.get(1);\
166 int tz = threadIdx.z + blockIdx.z * blockDim.z + start.get(2);\
168 if (tx > stop.get(0) || ty > stop.get(1) || tz > stop.get(2))\
171 #define GRID_ID_3(ite_gpu) grid_key_dx<3,int> key;\
172 key.set_d(0,threadIdx.x + blockIdx.x * blockDim.x + ite_gpu.start.get(0));\
173 key.set_d(1,threadIdx.y + blockIdx.y * blockDim.y + ite_gpu.start.get(1));\
174 key.set_d(2,threadIdx.z + blockIdx.z * blockDim.z + ite_gpu.start.get(2));\
176 if (key.get(0) > ite_gpu.stop.get(0) || key.get(1) > ite_gpu.stop.get(1) || key.get(2) > ite_gpu.stop.get(2))\
179 #define GRID_ID_2(ite_gpu) grid_key_dx<2,int> key;\
180 key.set_d(0,threadIdx.x + blockIdx.x * blockDim.x + ite_gpu.start.get(0));\
181 key.set_d(1,threadIdx.y + blockIdx.y * blockDim.y + ite_gpu.start.get(1));\
183 if (key.get(0) > ite_gpu.stop.get(0) || key.get(1) > ite_gpu.stop.get(1))\
189 template<
unsigned int dim,
typename ids_type =
int>
196 key.
set_d(0,blockIdx.x * blockDim.x + threadIdx.x);
197 key.
set_d(1,blockIdx.y * blockDim.y + threadIdx.y);
199 unsigned int bz = blockIdx.z * blockDim.z + threadIdx.z;
202 for (
unsigned int i = 3 ; i < dim ; i++)
215 key.
set_d(0,blockIdx.x * blockDim.x + threadIdx.x);
216 key.
set_d(1,blockIdx.y * blockDim.y + threadIdx.y);
218 unsigned int bz = blockIdx.z * blockDim.z + threadIdx.z;
219 key.
set_d(2,bz % g[2]);
221 for (
unsigned int i = 3 ; i < dim ; i++)
224 key.
set_d(i,bz % g[i]);
231 template<
typename ids_type>
232 struct grid_p<3,ids_type>
238 key.
set_d(0,blockIdx.x * blockDim.x + threadIdx.x);
239 key.
set_d(1,blockIdx.y * blockDim.y + threadIdx.y);
240 key.
set_d(2,blockIdx.z * blockDim.z + threadIdx.z);
249 key.
set_d(0,blockIdx.x * blockDim.x + threadIdx.x);
250 key.
set_d(1,blockIdx.y * blockDim.y + threadIdx.y);
251 key.
set_d(2,blockIdx.z * blockDim.z + threadIdx.z);
257 template<
typename ids_type>
258 struct grid_p<2,ids_type>
264 key.
set_d(0,blockIdx.x * blockDim.x + threadIdx.x);
265 key.
set_d(1,blockIdx.y * blockDim.y + threadIdx.y);
274 key.
set_d(0,blockIdx.x * blockDim.x + threadIdx.x);
275 key.
set_d(1,blockIdx.y * blockDim.y + threadIdx.y);
281 template<
typename ids_type>
282 struct grid_p<1,ids_type>
288 key.
set_d(0,blockIdx.x * blockDim.x + threadIdx.x);
297 template<
unsigned int dim>
302 ite.wthr.x = ite.wthr.x * ite.thr.x;
307 ite.wthr.x = ite.wthr.x * ite.thr.x;
308 ite.wthr.y = ite.wthr.y * ite.thr.y;
315 ite.wthr.x = ite.wthr.x * ite.thr.x;
316 ite.wthr.x = ite.wthr.y * ite.thr.y;
317 ite.wthr.x = ite.wthr.z * ite.thr.z;
326 #include "copy_grid_fast.hpp"
331 template<
typename gr
id_type>
334 std::cout <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" copy_grid_fast_caller failure" << std::endl;
338 template<
int ... prp>
341 template<
typename gr
id_type>
347 typedef typename std::remove_reference<decltype(gd)>::type grid_cp;
348 typedef typename std::remove_reference<decltype(gd.getGrid())>::type grid_info_cp;
355 grid_info_cp>::copy(gs.getGrid(),
373 template<
unsigned int dim,
376 template<
typename>
class layout_base,
381 typedef typename layout_base<T>::type
layout;
383 typedef typename apply_transform<layout_base,T>::type T_;
391 static constexpr
unsigned int dims = dim;
402 typedef ord_type linearizer_type;
404 typedef T background_type;
428 inline void check_init()
const
430 #ifndef __CUDA_ARCH__
433 std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" you must call SetMemory before access the grid\n";
434 ACTION_ON_ERROR(GRID_ERROR_OBJECT);
446 #ifndef __CUDA_ARCH__
447 for (
long int i = 0 ; i < dim ; i++)
451 std::cerr <<
"Error " __FILE__ <<
":" << __LINE__ <<
" grid overflow " <<
"x=[" << i <<
"]=" << v1.
get(i) <<
" >= " <<
getGrid().size(i) <<
"\n";
452 ACTION_ON_ERROR(GRID_ERROR_OBJECT);
454 else if (v1.
get(i) < 0)
456 std::cerr <<
"Error " __FILE__ <<
":" << __LINE__ <<
" grid overflow " <<
"x=[" << i <<
"]=" << v1.
get(i) <<
" is negative " <<
"\n";
457 ACTION_ON_ERROR(GRID_ERROR_OBJECT);
468 inline void check_bound(
size_t v1)
const
470 #ifndef __CUDA_ARCH__
473 std::cerr <<
"Error " __FILE__ <<
":" << __LINE__ <<
" grid overflow " << v1<<
" >= " <<
getGrid().size() <<
"\n";
474 ACTION_ON_ERROR(GRID_ERROR_OBJECT);
489 #ifndef __CUDA_ARCH__
490 for (
size_t i = 0 ; i < dim ; i++)
492 if (key2.
get(i) >= (
long int)g.
getGrid().size(i))
494 std::cerr <<
"Error " __FILE__ <<
":" << __LINE__ <<
" grid overflow " <<
"x=[" << i <<
"]=" << key2.
get(i) <<
" >= " << g.
getGrid().size(i) <<
"\n";
495 ACTION_ON_ERROR(GRID_ERROR_OBJECT);
497 else if (key2.
get(i) < 0)
499 std::cerr <<
"Error " __FILE__ <<
":" << __LINE__ <<
" grid overflow " <<
"x=[" << i <<
"]=" << key2.
get(i) <<
" is negative " <<
"\n";
500 ACTION_ON_ERROR(GRID_ERROR_OBJECT);
514 template<
typename Mem,
template <
typename>
class layout_base2>
517 #ifndef __CUDA_ARCH__
518 for (
size_t i = 0 ; i < dim ; i++)
520 if (key2.
get(i) >= (
long int)g.
getGrid().size(i))
522 std::cerr <<
"Error " __FILE__ <<
":" << __LINE__ <<
" grid overflow " <<
"x=[" << i <<
"]=" << key2.
get(i) <<
" >= " << g.
getGrid().size(i) <<
"\n";
523 ACTION_ON_ERROR(GRID_ERROR_OBJECT);
525 else if (key2.
get(i) < 0)
527 std::cerr <<
"Error " __FILE__ <<
":" << __LINE__ <<
" grid overflow " <<
"x=[" << i <<
"]=" << key2.
get(i) <<
" is negative " <<
"\n";
528 ACTION_ON_ERROR(GRID_ERROR_OBJECT);
544 #ifndef __CUDA_ARCH__
545 if (key2 >= g.
getGrid().size())
547 std::cerr <<
"Error " __FILE__ <<
":" << __LINE__ <<
" grid overflow " << key2 <<
" >= " <<
getGrid().size() <<
"\n";
548 ACTION_ON_ERROR(GRID_ERROR_OBJECT);
557 #if defined(CUDA_GPU) && defined(__NVCC__)
565 for (
size_t i = 0 ; i < dim ; i++)
570 if (grid_new.
g1.size(i) < sz[i])
571 {stop.
set_d(i,grid_new.
g1.size(i)-1);}
573 {stop.
set_d(i,sz[i]-1);}
576 copy_grid_to_grid<S>(grid_new,*
this,start,stop,blockSize);
580 std::cout << __FILE__ <<
":" << __LINE__ <<
" error: the function resize require the launch of a kernel, but it seem that this" <<
581 " file (grid_base_implementation.hpp) has not been compiled with NVCC " << std::endl;
589 for (
size_t i = 0 ; i < dim ; i++)
590 {sz_c[i] = (
g1.size(i) < sz[i])?
g1.size(i):sz[i];}
615 mem_setext<
typename std::remove_reference<decltype(grid_new)>::type,S,layout_base<T>,decltype(
data_)>
::set(grid_new,*
this,this->data_);
620 #if defined(CUDIFY_USE_SEQUENTIAL) || defined(CUDIFY_USE_OPENMP)
630 #include "grid_pack_unpack.ipp"
705 #if defined(CUDIFY_USE_SEQUENTIAL) || defined(CUDIFY_USE_OPENMP)
726 #if defined(CUDIFY_USE_SEQUENTIAL) || defined(CUDIFY_USE_OPENMP)
813 return getGPUIterator_impl<dim>(
g1,key1,key2,n_thr);
851 #if defined(CUDIFY_USE_SEQUENTIAL) || defined(CUDIFY_USE_OPENMP)
866 template<
unsigned int p>
869 return boost::fusion::at_c<p>(
data_).getMemory();
894 #if defined(CUDIFY_USE_SEQUENTIAL) || defined(CUDIFY_USE_OPENMP)
923 #if defined(CUDIFY_USE_SEQUENTIAL) || defined(CUDIFY_USE_OPENMP)
964 template <
unsigned int p,
typename r_type=decltype(layout_base<T>::
template get<p>(
data_,
g1,
grid_key_dx<dim>()))>
971 return this->get<p>(v1);
982 template <
unsigned int p,
typename r_type=decltype(layout_base<T>::
template get<p>(
data_,
g1,
grid_key_dx<dim>()))>
988 return layout_base<T>::template get<p>(
data_,
g1,v1);
1016 template <
unsigned int p,
typename r_type=decltype(layout_base<T>::
template get_c<p>(
data_,
g1,
grid_key_dx<dim>()))>
1022 return layout_base<T>::template get_c<p>(
data_,
g1,v1);
1032 template <
unsigned int p,
typename r_type=decltype(layout_base<T>::
template get<p>(
data_,
g1,
grid_key_dx<dim>()))>
1039 return layout_base<T>::template get<p>(
data_,
g1,v1);
1061 template <
unsigned int p,
typename r_type=decltype(layout_base<T>::
template get_c<p>(
data_,
g1,
grid_key_dx<dim>()))>
1068 return layout_base<T>::template get_c<p>(
data_,
g1,v1);
1078 template <
unsigned int p,
typename r_type=decltype(layout_base<T>::
template get_lin<p>(
data_,
g1,0))>
1079 __device__ __host__
inline r_type
get(
const size_t lin_id)
1083 check_bound(lin_id);
1085 return layout_base<T>::template get_lin<p>(
data_,
g1,lin_id);
1095 template <
unsigned int p,
typename r_type=decltype(layout_base<T>::
template get_lin<p>(
data_,
g1,0))>
1096 __device__ __host__
inline const r_type
get(
size_t lin_id)
const
1100 check_bound(lin_id);
1102 return layout_base<T>::get_lin_const(
data_,
g1,lin_id);
1144 ::get(
const_cast<typename std::add_lvalue_reference<decltype(this-
>data_)>::type>(
data_),
1207 ::get_lin(
const_cast<typename std::add_lvalue_reference<decltype(this-
>data_)>::type>(
data_),v1);
1220 if (prp != 0 ||
is_layout_mlin<layout_base<T>>::type::value ==
false)
1222 std::cout <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" unsupported fill operation " << std::endl;
1278 for (
size_t i = 0 ; i < dim ; i++)
1280 if (box_dst.
getHigh(i) >= (
long int)
g1.size(i))
1292 if (box_dst.
getLow(i) < 0)
1331 template<
unsigned int ... prp>
1336 typedef typename std::remove_reference<decltype(grid_src)>::type grid_cp;
1337 typedef typename std::remove_reference<decltype(grid_src.
getGrid())>::type grid_info_cp;
1345 grid_info_cp>::copy(grid_src.
getGrid(),
1349 grid_src,*
this,cnt);
1370 template<
template<
typename,
typename>
class op,
unsigned int ... prp>
1410 void resize(
const size_t (& sz)[dim],
size_t opt = DATA_ON_HOST | DATA_ON_DEVICE,
unsigned int blockSize = 1)
1420 if (opt & DATA_ON_HOST)
1423 if (opt & DATA_ON_DEVICE && S::isDeviceHostSame() ==
false)
1424 {resize_impl_device(sz,grid_new,blockSize);}
1430 this->
swap(grid_new);
1453 this->
swap(grid_new);
1466 std::cerr <<
"Error: " << __FILE__ <<
" " << __LINE__ <<
" remove work only on dimension == 1 " <<
"\n";
1473 data_.move(&this->
template get<0>());
1518 grid.is_mem_init = exg;
1520 #if defined(CUDIFY_USE_SEQUENTIAL) || defined(CUDIFY_USE_OPENMP)
1543 grid.is_mem_init = exg;
1548 grid.isExternal = exg;
1550 #if defined(CUDIFY_USE_SEQUENTIAL) || defined(CUDIFY_USE_OPENMP)
1578 template<
unsigned int ... prp>
1581 auto edest = this->
get_o(key1);
1582 auto esrc = g.
get_o(key2);
1586 boost::mpl::for_each_ref<boost::mpl::range_c<
int,0,
sizeof...(prp)>>(ec);
1608 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,T::max_prop> >(cp);
1627 this->
get_o(dx) = obj;
1646 check_bound(g,key2);
1660 inline void set(
const size_t key1,
1667 check_bound(g,key2);
1686 check_bound(g,key2);
1707 check_bound(g,key2);
1735 return g1.getSubIterator(start,stop);
1763 for (
int i = 0 ; i < dim ; i++)
1764 {sz[i] =
g1.size(i);}
1784 template<
unsigned int ... prp>
void deviceToHost(
size_t start,
size_t stop)
1795 #ifdef CUDIFY_USE_OPENMP
1799 for (
size_t i = 0 ; i < dim ; i++)
1801 start_.
set_d(i,start);
1802 stop_.
set_d(i,stop);
1805 auto ite = this->getGPUIterator(start_,stop_);
1808 copy_with_openmp_prp<decltype(this->
toKernel()),
typename std::remove_reference<decltype(*
this)>::type,prp ...>(this->
toKernel(),*
this,ite);
1820 #ifdef CUDIFY_USE_OPENMP
1825 for (
size_t i = 0 ; i < dim ; i++)
1828 stop_.
set_d(i,this->g1.size() - 1);
1831 auto ite = this->getGPUIterator(start_,stop_);
1834 copy_with_openmp_prp<decltype(this->
toKernel()),
typename std::remove_reference<decltype(*
this)>::type,prp ...>(this->
toKernel(),*
this,ite);
1844 template<
unsigned int ... prp>
void hostToDevice(
size_t start,
size_t stop)
1859 #if defined(CUDIFY_USE_SEQUENTIAL) || defined(CUDIFY_USE_OPENMP)
1914 template<
unsigned int Np>
1937 for (
int i = 0 ; i < dim ; i++)
1938 {sz[i] =
g1.size(i);}
1981 template<
unsigned int ... prp,
typename context_type>
1992 template<
unsigned int ... prp,
typename context_type>
This class represent an N-dimensional box.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
__device__ __host__ T getHigh(int i) const
get the high interval of the box
grid_key_dx< dim > getKP1() const
Get the point p1 as grid_key_dx.
grid_key_dx< dim > getKP2() const
Get the point p12 as grid_key_dx.
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
Implementation of a N-dimensional grid.
size_t size() const
return the size of the grid
layout layout_type
memory layout
void set(const grid_key_dx< dim > &key1, const grid_base_impl< dim, T, Mem, layout_base > &g, const grid_key_dx< dim > &key2)
Set an element of the grid from another element of another grid.
grid_key_dx_iterator< dim, stencil_offset_compute< dim, Np > > getIteratorStencil(const grid_key_dx< dim >(&stencil_pnt)[Np]) const
Return a grid iterator.
encapc< dim, T, layout > container
Object container for T, it is the return type of get_o it return a object type trough.
grid_base_impl< dim, T, S, layout_base > duplicate() const THROW
create a duplicated version of the grid
void remove(size_t key)
Remove one element valid only on 1D.
void hostToDeviceNUMA(size_t start, size_t stop)
Synchronize the memory buffer in the device with the memory in the host (respecting the NUMA domains)
__device__ __host__ r_type get_usafe(const grid_key_dx< dim > &v1)
Get the reference of the selected element.
void swap_nomode(grid_base_impl< dim, T, S, layout_base > &grid)
It swap the objects A become B and B become A using A.swap(B);.
bool operator==(const grid_base_impl< dim, T, S, layout_base > &g)
Compare two grids.
void set(grid_key_dx< dim > dx, const T &obj)
set an element of the grid
T::type T_type
boost::vector that describe the data type
void deviceToHost()
Synchronize the memory buffer in the device with the memory in the host.
void set(const size_t key1, const grid_base_impl< dim, T, S, layout_base > &g, const size_t key2)
Set an element of the grid from another element of another grid.
const grid_gpu_ker< dim, T_, layout_base, linearizer_type > toKernel() const
Convert the grid into a data-structure compatible for computing into GPU.
__device__ __host__ const r_type get(size_t lin_id) const
Get the const reference of the selected element.
void resetFlush()
It does nothing.
layout data_
Memory layout specification + memory chunk pointer.
void resize(const size_t(&sz)[dim], size_t opt=DATA_ON_HOST|DATA_ON_DEVICE, unsigned int blockSize=1)
Resize the grid.
grid_gpu_ker< dim, T_, layout_base, linearizer_type > toKernel()
Convert the grid into a data-structure compatible for computing into GPU.
ord_type g1
This is a structure that store all information related to the grid and how indexes are linearized.
__device__ __host__ r_type get_unsafe(const grid_key_dx< dim > &v1) const
Get the const reference of the selected element.
bool isSkipLabellingPossible()
This function check if keep geometry is possible for this grid.
void removeAddUnpackFinalize(const context_type &gpuContext, int opt)
In this case it does nothing.
const void * getPointer() const
Return a plain pointer to the internal data.
void removeCopyToFinalize(const context_type &gpuContext, int opt)
In this case it does nothing.
bool isExternal
The memory allocator is not internally created.
grid_base_impl(const grid_base_impl &g) THROW
create a grid from another grid
grid_key_dx_iterator_sub< dim > getIterator(const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop, bool to_init=false) const
Return a grid iterator over all points included between start and stop point.
__device__ __host__ r_type get(const grid_key_dx< dim > &v1) const
Get the const reference of the selected element.
auto getMemory() -> decltype(boost::fusion::at_c< p >(data_).getMemory())
Return the memory object.
r_type insert(const grid_key_dx< dim > &v1)
In this case insert is equivalent to get.
~grid_base_impl() THROW
Destructor.
void copy_to_op(const grid_base_impl< dim, T, S, layout_base > &gs, const Box< dim, size_t > &bx_src, const Box< dim, size_t > &bx_dst)
copy an external grid into a specific place into this grid
int yes_i_am_grid
it define that this data-structure is a grid
void set(const grid_key_dx< dim > &key1, const grid_base_impl< dim, T, S, layout_base > &g, const grid_key_dx< dim > &key2)
Set an element of the grid from another element of another grid.
T value_type
The object type the grid is storing.
void resize_impl_host(const size_t(&sz)[dim], grid_base_impl< dim, T, S, layout_base, ord_type > &grid_new)
__device__ __host__ void set(const grid_key_dx< dim > &key1, const grid_base_impl &g, const grid_key_dx< dim > &key2)
set only some properties
void setMemory()
Create the object that provide memory.
void hostToDevice()
Copy the memory from host to device.
int size(int i) const
Get the size if the grid in the direction i.
encapc< dim, T, layout > get_o(const grid_key_dx< dim > &v1)
Get the of the selected element as a boost::fusion::vector.
memory_traits_lin< typename T::type >::type memory_lin
Definition of the layout.
__device__ __host__ r_type get(const grid_key_dx< dim > &v1)
Get the reference of the selected element.
encapc< dim, T, layout > insert_o(const grid_key_dx< dim > &v1)
Get the of the selected element as a boost::fusion::vector.
grid_base_impl() THROW
Default constructor.
void * getPointer()
Return a plain pointer to the internal data.
grid_key_dx_iterator_sub< dim > getSubIterator(const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop) const
Return a sub-grid iterator.
const layout & get_internal_data_() const
return the internal data_
layout & get_internal_data_()
return the internal data_
void remove(Box< dim, long int > §ion_to_delete)
Remove all the points in this region.
grid_base_impl< dim, T, S, layout_base > & operator=(const grid_base_impl< dim, T, S, layout_base > &g)
It copy a grid.
void copy_to_prp(const grid_base_impl< dim, T, S, layout_base > &grid_src, const Box< dim, size_t > &box_src, const Box< dim, size_t > &box_dst)
copy an external grid into a specific place into this grid
void swap(grid_base_impl< dim, T, S, layout_base, ord_type > &grid)
It swap the objects A become B and B become A using A.swap(B);.
encapc< dim, T, layout > get_o(size_t v1)
Get the of the selected element as a boost::fusion::vector.
void removeAddUnpackReset()
In this case it does nothing.
void copyRemoveReset()
Reset the queue to remove and copy section of grids.
grid_key_dx_iterator_sub< dim > getSubIterator(size_t m)
Return a sub-grid iterator.
void setMemory(S &m)
Set the object that provide memory from outside.
const ord_type & getGrid() const
Return the internal grid information.
layout_base< T > layout_base_
base layout type
grid_key_dx< dim > access_key
Access key.
void set(grid_key_dx< dim > dx, const encapc< 1, T, Memory > &obj)
set an element of the grid
grid_base_impl< dim, T, S, layout_base > & operator=(grid_base_impl< dim, T, S, layout_base > &&g)
It copy a grid.
void setGPUInsertBuffer(unsigned int nb, unsigned int nt)
No blocks here, it does nothing.
const encapc< dim, T, layout > get_o(const grid_key_dx< dim > &v1) const
Get the of the selected element as a boost::fusion::vector.
const encapc< dim, T, layout > get_o(size_t v1) const
Get the of the selected element as a boost::fusion::vector.
void set_general(const grid_key_dx< dim > &key1, const grid_base_impl< dim, T, Mem, layout_base2 > &g, const grid_key_dx< dim > &key2)
Set an element of the grid from another element of another grid.
int getBlockEdgeSize()
No blocks here, it return 1.
grid_key_dx_iterator< dim > getIterator() const
Return a grid iterator.
bool is_mem_init
Is the memory initialized.
void swap(grid_base_impl< dim, T, S, layout_base > &&grid)
It move the allocated object from one grid to another.
grid_base_impl(const size_t &sz) THROW
create a grid of size sz on each direction
void fill(unsigned char fl)
Fill the memory with the selected byte.
void clear()
It does nothing.
__device__ __host__ r_type get(const size_t lin_id)
Get the reference of the selected element.
void hostToDeviceNUMA()
Synchronize the memory buffer in the device with the memory in the host (respecting the NUMA domains)
void hostToDevice(size_t start, size_t stop)
Synchronize the memory buffer in the device with the memory in the host.
void copy_to(const grid_base_impl< dim, T, S, layout_base > &grid_src, const Box< dim, long int > &box_src, const Box< dim, long int > &box_dst)
copy an external grid into a specific place into this grid
void setMemoryArray(S *m)
Set the object that provide memory from outside.
layout_base< T >::type layout
memory layout
void resize_impl_memset(grid_base_impl< dim, T, S, layout_base, ord_type > &grid_new)
void resize_no_device(const size_t(&sz)[dim])
Resize the space.
__device__ __host__ unsigned char getFlag(const grid_key_dx< dim > &v1) const
Get the point flag (in this case just return 0)
void deviceToHost(size_t start, size_t stop)
Synchronize the memory buffer in the device with the memory in the host.
static bool is_unpack_header_supported()
Indicate that unpacking the header is supported.
static constexpr unsigned int dims
expose the dimansionality as a static const
grid_base_impl(const size_t(&sz)[dim]) THROW
Constructor.
This is a distributed grid.
static const unsigned int dims
Number of dimensions.
grid interface available when on gpu
bool isNext()
Check if there is the next element.
grid_key_dx< dim > get() const
Return the actual grid key iterator.
const grid_key_dx< dim > & get() const
Get the actual key.
bool isNext()
Check if there is the next element.
grid_key_dx is the key to access any element in the grid
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
__device__ __host__ index_type get(index_type i) const
Get the i index.
__device__ __host__ size_t size() const
Return the size of the grid.
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data
this class is a functor for "for_each" algorithm
this class is a functor for "for_each" algorithm
This is a way to quickly copy a grid into another grid.
It return true if the object T require complex serialization.
It copy the properties from one object to another applying an operation.
It copy the properties from one object to another applying an operation.
to_variadic_impl< N+1, M, exit_::value, N >::type type
generate the boost::fusion::vector apply H on each term