OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
hostDevice_util_funcs.hpp
1#ifndef HOSTDEVICE_UTIL_FUNCS_HPP_
2#define HOSTDEVICE_UTIL_FUNCS_HPP_
3
14template<typename T_type, template<typename> class layout_base, unsigned int ... prp>
16{
18 typename layout_base<T_type>::type & dst;
19
21 typedef typename to_boost_vmpl<prp...>::type v_prp;
22
24 size_t start;
25
27 size_t stop;
28
35 inline device_to_host_start_stop_impl(typename layout_base<T_type>::type & dst,size_t start,size_t stop)
37 {
38 };
39
40
42 template<typename T>
43 inline void operator()(T& t) const
44 {
45 typedef typename boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type prp_id;
46
47 typedef typename boost::mpl::at<typename T_type::type,prp_id>::type p_type;
48
49 boost::fusion::at_c<prp_id::value>(dst).mem->deviceToHost(start*sizeof(p_type),(stop+1)*sizeof(p_type));
50 }
51};
52
63template<typename T_type, template<typename> class layout_base, unsigned int ... prp>
65{
67 typename layout_base<T_type>::type & dst;
68
70 typedef typename to_boost_vmpl<prp...>::type v_prp;
71
78 inline device_to_host_impl(typename layout_base<T_type>::type & dst)
79 :dst(dst)
80 {
81 };
82
83
85 template<typename T>
86 inline void operator()(T& t) const
87 {
88 boost::fusion::at_c<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>(dst).mem->deviceToHost();
89 }
90};
91
102template<typename T_type, template<typename> class layout_base , typename Memory, unsigned int ... prp>
104{
106 typename layout_base<T_type>::type & dst;
107
109 typedef typename to_boost_vmpl<prp...>::type v_prp;
110
112 size_t start;
113
115 size_t stop;
116
123 inline host_to_device_impl(typename layout_base<T_type>::type & dst,size_t start, size_t stop)
125 {};
126
127
129 template<typename T>
130 inline void operator()(T& t) const
131 {
132 typedef typename boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type ele_type;
133
134 typedef decltype(boost::fusion::at_c<ele_type::value>(dst).mem_r) mem_r_type;
135
136 typedef typename boost::mpl::at<typename T_type::type,ele_type>::type type_prp;
137
139
140 typedef boost::mpl::int_<(is_vector<typename mem_r_type::value_type>::value ||
142 is_gpu_celllist<typename mem_r_type::value_type>::value) + 2*std::is_array<type_prp>::value + std::rank<type_prp>::value> crh_cond;
143
144 call_recursive_host_device_if_vector<typename mem_r_type::value_type,
145 kernel_type,
146 type_prp,
147 layout_base,
148 crh_cond::value>
149 ::template transform<Memory,mem_r_type>(static_cast<Memory *>(boost::fusion::at_c<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>(dst).mem),
150 boost::fusion::at_c<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>(dst).mem_r,
151 start*sizeof(type_prp),
152 (stop+1)*sizeof(type_prp));
153
154 // here we have to recursively call hostToDevice for each nested vector
155 call_recursive_host_device_if_vector<typename mem_r_type::value_type,
156 kernel_type,
157 type_prp,
158 layout_base,
159 0>
160 ::call(boost::fusion::at_c<boost::mpl::at<v_prp,boost::mpl::int_<T::value>>::type::value>(dst).mem_r,start,stop);
161 }
162};
163
164#endif
this class is a functor for "for_each" algorithm
device_to_host_impl(typename layout_base< T_type >::type &dst)
constructor
to_boost_vmpl< prp... >::type v_prp
Convert the packed properties into an MPL vector.
layout_base< T_type >::type & dst
encapsulated destination object
void operator()(T &t) const
It call the copy function for each property.
this class is a functor for "for_each" algorithm
void operator()(T &t) const
It call the copy function for each property.
to_boost_vmpl< prp... >::type v_prp
Convert the packed properties into an MPL vector.
device_to_host_start_stop_impl(typename layout_base< T_type >::type &dst, size_t start, size_t stop)
constructor
layout_base< T_type >::type & dst
encapsulated destination object
this class is a functor for "for_each" algorithm
layout_base< T_type >::type & dst
encapsulated destination object
size_t start
starting element
void operator()(T &t) const
It call the copy function for each property.
to_boost_vmpl< prp... >::type v_prp
Convert the packed properties into an MPL vector.
host_to_device_impl(typename layout_base< T_type >::type &dst, size_t start, size_t stop)
constructor
Check this is a gpu or cpu type cell-list.
Definition util.hpp:74