8#ifndef OPENFPM_DATA_SRC_GRID_GRID_BASE_IMPL_LAYOUT_HPP_
9#define OPENFPM_DATA_SRC_GRID_GRID_BASE_IMPL_LAYOUT_HPP_
11#include <boost/fusion/include/mpl.hpp>
12#include "memory_ly/memory_conf.hpp"
13#include <boost/fusion/include/for_each.hpp>
14#include "memory_ly/Encap.hpp"
15#include "Space/Shape/Box.hpp"
41 t.setMemory(*
new S());
44 if (
sz != 0) t.allocate(
sz);
65 frswap(s_m & swap_dst, s_m & swap_src)
66 :swap_src(swap_src),swap_dst(swap_dst)
73 boost::fusion::at_c<T::value>(swap_dst).swap(boost::fusion::at_c<T::value>(swap_src));
88template<
typename s_m,
typename Mem_type>
96 :swap_src(swap_src),swap_dst(swap_dst)
103 boost::fusion::at_c<T::value>(swap_dst).template swap_nomode<Mem_type>(boost::fusion::at_c<T::value>(swap_src));
108template<typename S, typename layout, typename data_type, typename g1_type, unsigned int sel = 2*is_layout_mlin<layout>::value +
is_layout_inte<layout>::value >
111 static inline void setMemory(data_type & data_,
const g1_type & g1,
bool & is_mem_init)
116 data_.setMemory(*mem);
119 if (g1.size() != 0) data_.allocate(g1.size());
126template<
typename S,
typename layout,
typename data_type,
typename g1_type>
129 static inline void setMemory(data_type & data_,
const g1_type & g1,
bool & is_mem_init)
135 boost::fusion::for_each(data_,all);
143template<typename grid_type, typename S , typename layout, typename data_type, unsigned int sel = 2*is_layout_mlin<layout>::value +
is_layout_inte<layout>::value >
148 grid_new.setMemory(
static_cast<S&
>(data_.getMemory()));
164template<
typename gr
id_type,
typename data_type,
typename S>
179 :grid_new(g_new),old(old),data_(data_)
186 grid_new.template setMemory<T::value>(
static_cast<S&
>(boost::fusion::at_c<T::value>(data_).getMemory()));
201template<
typename gr
id_type,
typename Memory>
218 :grid_new(g_new),mem(mem),sz(sz),np(np)
225 grid_new.template setMemory<T::value>(mem[T::value]);
228 if (sz != 0) boost::fusion::at_c<T::value>(grid_new.get_internal_data_()).allocate(sz,np);
233template<
typename gr
id_type,
typename S ,
typename layout,
typename data_type>
242 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,grid_type::value_type::max_prop>>(mst);
250template<typename T , typename layout, typename data_type, typename grid_type, unsigned int sel = 2*is_layout_mlin<layout>::value +
is_layout_inte<layout>::value >
253 static inline void swap(data_type & data_dst, data_type & data_src)
256 data_dst.swap(data_src);
259 template<
typename Mem_type>
260 static inline void swap_nomode(data_type & data_dst, data_type & data_src)
263 data_dst.swap_nomode(data_src);
268template<
typename T ,
typename layout,
typename data_type,
typename gr
id_type>
271 static inline void swap(data_type & data_dst, data_type & data_src)
274 frswap<
decltype(data_dst)> sw(data_dst,data_src);
276 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,T::max_prop> >(sw);
279 template<
typename Mem_type>
280 static inline void swap_nomode(data_type & data_dst, data_type & data_src)
283 frswap_nomode<
decltype(data_dst),Mem_type> sw(data_dst,data_src);
285 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,T::max_prop> >(sw);
292 template<
unsigned int d> __device__ __host__
static void * getPointer(data_type & data_)
294 return data_.mem_r.get_pointer();
297 template<
unsigned int d> __device__ __host__
static void * getPointer(
const data_type & data_)
299 return data_.mem_r.get_pointer();
303template<
typename data_type,
typename layout>
306 template<
unsigned int p> __device__ __host__
static void * getPointer(data_type & data_)
308 return boost::fusion::at_c<p>(data_).mem_r.get_pointer();
311 template<
unsigned int p> __device__ __host__
static const void * getPointer(
const data_type & data_)
313 return boost::fusion::at_c<p>(data_).mem_r.get_pointer();
317template<typename data_type, typename Mem_type, typename layout, unsigned int sel = 2*is_layout_mlin<layout>::value +
is_layout_inte<layout>::value>
320 template<
unsigned int d>
static void setMemory(data_type & data_, Mem_type & m,
size_t sz,
bool np)
326 if (sz != 0) data_.allocate(sz,np);
332 data_.setMemory(m[0]);
335 if (sz != 0) data_.allocate(sz,np);
339template<
typename data_type,
typename Mem_type,
typename layout>
342 template<
unsigned int p>
static void setMemory(data_type & data_, Mem_type & m,
size_t sz,
bool np)
345 boost::fusion::at_c<p>(data_).setMemory(m);
348 if (sz != 0) boost::fusion::at_c<p>(data_).allocate(sz,np);
356 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,grid_type::value_type::max_prop>>(ma);
This is a distributed grid.
this class is a functor for "for_each" algorithm
void operator()(T &t) const
It call the allocate function for each member.
allocate(size_t sz)
constructor it fix the size
size_t sz
size to allocate
this class is a functor for "for_each" algorithm
void operator()(T &t) const
It call the allocate function for each member.
frswap_nomode(s_m &swap_dst, s_m &swap_src)
constructor
this class is a functor for "for_each" algorithm
frswap(s_m &swap_dst, s_m &swap_src)
constructor
void operator()(T &t) const
It call the allocate function for each member.
this class is a functor for "for_each" algorithm
void operator()(T &t)
It call the copy function for each property.
mem_setarray(grid_type &g_new, Memory *mem, size_t sz, bool np)
constructor
this class is a functor for "for_each" algorithm
void operator()(T &t)
It call the copy function for each property.
mem_setext_prp(grid_type &g_new, grid_type &old, data_type &data_)
constructor
static void setMemory(data_type &data_, const g1_type &g1, bool &is_mem_init)
static void setMemory(data_type &data_, const g1_type &g1, bool &is_mem_init)
static void setMemory(data_type &data_, Mem_type &m, size_t sz, bool np)
static void setMemory(data_type &data_, Mem_type &m, size_t sz, bool np)
static void setMemoryArray(data_type &data_, Mem_type *m, size_t sz, bool np)