8#ifndef MEMORY_CONF_HPP_
9#define MEMORY_CONF_HPP_
11#include "util/variadic_to_vmpl.hpp"
12#include "t_to_memory_c.hpp"
13#include "Vector/vect_isel.hpp"
14#include "Vector/util.hpp"
15#include "util/tokernel_transformation.hpp"
16#include "util/hostDevice_util_funcs.hpp"
18constexpr int SOA_layout_IA = 2;
19constexpr int SOA_layout = 1;
20constexpr int AOS_layout = 0;
86 typedef typename inter_memc<typename T::type>::type
type;
91 typedef boost::mpl::int_<SOA_layout_IA> type_value;
102 template<
unsigned int p,
typename data_type,
typename g1_type,
typename key_type>
103 __host__ __device__
static inline auto get(data_type & data_,
const g1_type & g1,
const key_type & v1) ->
decltype(boost::fusion::at_c<p>(data_).mem_r.operator[](g1.LinId(v1)))
105 return boost::fusion::at_c<p>(data_).mem_r.operator[](g1.LinId(v1));
117 template<
unsigned int p,
typename data_type,
typename g1_type>
118 __host__ __device__
static inline auto get_lin(data_type & data_,
const g1_type & g1,
size_t lin_id) ->
decltype(boost::fusion::at_c<p>(data_).mem_r.operator[](lin_id))
120 return boost::fusion::at_c<p>(data_).mem_r.operator[](lin_id);
132 template<
unsigned int p,
typename data_type,
typename g1_type,
typename key_type>
133 __host__ __device__
static inline auto get_c(
const data_type & data_,
const g1_type & g1,
const key_type & v1) ->
decltype(boost::fusion::at_c<p>(data_).mem_r.operator[](g1.LinId(v1)))
135 return boost::fusion::at_c<p>(data_).mem_r.operator[](g1.LinId(v1));
147 template<
unsigned int p,
typename data_type,
typename g1_type>
148 __host__ __device__
static inline auto get_lin_c(
const data_type & data_,
const g1_type & g1,
size_t lin_id) ->
decltype(boost::fusion::at_c<p>(data_).mem_r.operator[](lin_id))
150 return boost::fusion::at_c<p>(data_).mem_r.operator[](lin_id);
161 template<
typename S,
typename data_type,
unsigned int ... prp>
166 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,
sizeof...(prp)> >(dth);
177 template<
typename data_type,
unsigned int ... prp>
182 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,
sizeof...(prp)> >(dth);
213template<
typename T,
bool is_agg>
247 typedef int yes_is_tlin;
249 typedef boost::mpl::int_<AOS_layout> type_value;
261 template<
unsigned int p,
typename data_type,
typename g1_type,
typename key_type,
typename std::enable_if<!std::is_same<data_type, memory_c<boost::fusion::vector<>, 1, memory>>::value,
int>::type = 0>
262 __host__ __device__
static inline auto get(data_type & data_,
const g1_type & g1,
const key_type & v1) ->
decltype(boost::fusion::at_c<p>(data_.mem_r.operator[](g1.LinId(v1)))) &
264 return boost::fusion::at_c<p>(data_.mem_r.operator[](g1.LinId(v1)));
277 template<
unsigned int p,
typename data_type,
typename g1_type,
typename key_type,
typename std::enable_if<std::is_same<data_type, memory_c<boost::fusion::vector<>, 1, memory>>::value,
int>::type = 0>
278 __host__ __device__
static inline void get(data_type & data_,
const g1_type & g1,
const key_type & v1) {}
290 template<
unsigned int p,
typename data_type,
typename g1_type,
typename std::enable_if<!std::is_same<data_type, memory_c<boost::fusion::vector<>, 1, memory>>::value,
int>::type = 0>
291 __host__ __device__
static inline auto get_lin(data_type & data_,
const g1_type & g1,
const size_t lin_id) ->
decltype(boost::fusion::at_c<p>(data_.mem_r.operator[](lin_id))) &
293 return boost::fusion::at_c<p>(data_.mem_r.operator[](lin_id));
306 template<
unsigned int p,
typename data_type,
typename g1_type,
typename std::enable_if<std::is_same<data_type, memory_c<boost::fusion::vector<>, 1, memory>>::value,
int>::type = 0>
307 __host__ __device__
static inline auto get_lin(data_type & data_,
const g1_type & g1,
const size_t lin_id) {}
318 template<
unsigned int p,
typename data_type,
typename g1_type,
typename key_type,
typename std::enable_if<!std::is_same<data_type, memory_c<boost::fusion::vector<>, 1, memory>>::value,
int>::type = 0>
319 __host__ __device__
static inline auto get_c(
const data_type & data_,
const g1_type & g1,
const key_type & v1) ->
decltype(boost::fusion::at_c<p>(data_.mem_r.operator[](g1.LinId(v1)))) &
321 return boost::fusion::at_c<p>(data_.mem_r.operator[](g1.LinId(v1)));
333 template<
unsigned int p,
typename data_type,
typename g1_type>
334 __host__ __device__
static inline auto get_lin_c(
const data_type & data_,
const g1_type & g1,
const size_t lin_id) ->
decltype(boost::fusion::at_c<p>(data_.mem_r.operator[](lin_id))) &
336 return boost::fusion::at_c<p>(data_.mem_r.operator[](lin_id));
347 template<
typename S,
typename data_type,
unsigned int ... prp>
350 data_.mem->hostToDevice(start*
sizeof(T),(stop+1)*
sizeof(T));
361 template<
typename data_type,
unsigned int ... prp>
364 data_.mem->deviceToHost(start*
sizeof(T),(stop+1)*
sizeof(T));
371template<
typename T,
typename Sfinae =
void>
389template<
typename T,
typename Sfinae =
void>
417template<typename T, unsigned int impl = is_vector<T>::value >
this class is a functor for "for_each" algorithm
this class is a functor for "for_each" algorithm
This class convert a boost::mpl::fusion/vector to a boost::mpl::fusion/vector with memory_c<....
This class convert a boost::mpl::fusion/vector to a boost::mpl::fusion/vector with memory_c interleav...
is_multiple_buffer_each_prp
Transform the boost::fusion::vector into memory specification (memory_traits)
inter_memc< typenameT::type >::type type
for each element in the vector interleave memory_c
__host__ static __device__ auto get_lin(data_type &data_, const g1_type &g1, size_t lin_id) -> decltype(boost::fusion::at_c< p >(data_).mem_r.operator[](lin_id))
Return a reference to the selected element.
__host__ static __device__ auto get_c(const data_type &data_, const g1_type &g1, const key_type &v1) -> decltype(boost::fusion::at_c< p >(data_).mem_r.operator[](g1.LinId(v1)))
Return a reference to the selected element.
__host__ static __device__ auto get_lin_c(const data_type &data_, const g1_type &g1, size_t lin_id) -> decltype(boost::fusion::at_c< p >(data_).mem_r.operator[](lin_id))
Return a reference to the selected element.
static void deviceToHost(data_type &data_, size_t start, size_t stop)
Synchronize the memory buffer in the device with the memory in the host.
int yes_is_inte
indicate that it change the memory layout from the original
__host__ static __device__ auto get(data_type &data_, const g1_type &g1, const key_type &v1) -> decltype(boost::fusion::at_c< p >(data_).mem_r.operator[](g1.LinId(v1)))
Return a reference to the selected element.
static void hostToDevice(data_type &data_, size_t start, size_t stop)
Synchronize the memory buffer in the device with the memory in the host.
Transform the boost::fusion::vector into memory specification (memory_traits)
Transform the boost::fusion::vector into memory specification (memory_traits)
__host__ static __device__ auto get_lin_c(const data_type &data_, const g1_type &g1, const size_t lin_id) -> decltype(boost::fusion::at_c< p >(data_.mem_r.operator[](lin_id))) &
Return a reference to the selected element.
__host__ static __device__ auto get_lin(data_type &data_, const g1_type &g1, const size_t lin_id)
Return a reference to the selected element SFINAE is used to hande CSR graphs, where boost::fusion::a...
__host__ static __device__ void get(data_type &data_, const g1_type &g1, const key_type &v1)
Return a reference to the selected element. SFINAE is used to hande CSR graphs, where boost::fusion::...
__host__ static __device__ auto get_c(const data_type &data_, const g1_type &g1, const key_type &v1) -> decltype(boost::fusion::at_c< p >(data_.mem_r.operator[](g1.LinId(v1)))) &
Return a reference to the selected element.
memory_traits_lin_type< T, openfpm::vect_isel< T >::value==OPENFPM_NATIVE >::type type
for each element in the vector interleave memory_c
__host__ static __device__ auto get_lin(data_type &data_, const g1_type &g1, const size_t lin_id) -> decltype(boost::fusion::at_c< p >(data_.mem_r.operator[](lin_id))) &
Return a reference to the selected element SFINAE is used to hande CSR graphs, where boost::fusion::a...
static void deviceToHost(data_type &data_, size_t start, size_t stop)
Synchronize the memory buffer in the device with the memory in the host.
__host__ static __device__ auto get(data_type &data_, const g1_type &g1, const key_type &v1) -> decltype(boost::fusion::at_c< p >(data_.mem_r.operator[](g1.LinId(v1)))) &
Return a reference to the selected element SFINAE is used to hande CSR graphs, where boost::fusion::a...
static void hostToDevice(data_type &data_, size_t start, size_t stop)
Copy the memory from host to device.