8 #ifndef OPENFPM_DATA_SRC_UTIL_COPY_GENERAL_HPP_ 9 #define OPENFPM_DATA_SRC_UTIL_COPY_GENERAL_HPP_ 11 #include "util/common.hpp" 12 #include "util/util_debug.hpp" 13 #include "copy_compare_aggregates.hpp" 14 #include "util/for_each_ref.hpp" 15 #include <boost/mpl/range_c.hpp> 17 #include "util/cuda_util.hpp" 18 #include "data_type/aggregate.hpp" 26 template<
typename Tdst,
typename Tsrc>
35 static inline void operation(Tdst & dst,
const Tsrc & src)
37 dst = (src > dst)?src:dst;
47 template<
typename Tdst,
typename Tsrc>
56 static inline void operation(Tdst & dst,
const Tsrc & src)
58 dst = (src < dst)?src:dst;
68 template<
typename Tdst,
typename Tsrc>
77 __device__ __host__
static inline void operation(Tdst & dst,
const Tsrc & src)
83 #if defined(__clang__) && !defined(CUDA_ON_CPU) 85 template<
typename Tsrc>
86 __host__ Tsrc atomicAdd(Tsrc * ptr, Tsrc value)
88 std::cout << __FILE__ <<
":" << __LINE__ <<
"Error: atomicAdd is supported only in device code not host" << std::endl;
99 template<
typename Tdst,
typename Tsrc>
108 __device__ __host__
static inline void operation(Tdst & dst,
const Tsrc & src)
120 template<
typename Tdst,
typename Tsrc>
129 static inline void operation(Tdst & dst,
const Tsrc & src)
141 template<
typename Tdst,
typename Tsrc>
150 static inline void operation(Tdst & dst,
const Tsrc & src)
161 template<typename T, unsigned int agg=2 * is_aggregate<T>::value + std::is_copy_assignable<T>::value>
172 #ifndef DISABLE_ALL_RTTI 173 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" " << demangle(
typeid(T).name()) <<
" does not have an operator= and is not an aggregate or an openfpm native structure, copy is not possible" <<
"\n";
208 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,T::max_prop>>(cp);
235 template<
template<
typename,
typename>
class op,
typename T,
unsigned int agg=2 *
is_aggregate<T>::value + std::is_copy_assignable<T>::value>
246 #ifndef DISABLE_ALL_RTTI 247 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" " << demangle(
typeid(T).name()) <<
" does not have an operator " << demangle(
typeid(op<T,T>).name()) <<
"defined" << std::endl;
253 template<
template<
typename,
typename>
class op,
typename T>
264 op<T,T>::operation(dst,src);
269 template<
template<
typename,
typename>
class op,
typename T>
282 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,T::max_prop>>(cp);
__device__ __host__ copy_general(const T &src, T &dst)
copy objects that has an operator= (implicit or explicit)
__device__ static __host__ void operation(Tdst &dst, const Tsrc &src)
Defition of the add operation.
Structure to copy aggregates.
__device__ __host__ copy_general_op(const T &src, T &dst)
copy objects that are aggregates
structure to copy aggregates applying an operation
This structure define the operation add to use with copy general.
This structure define the operation add to use with copy general.
structure to copy aggregates
This structure define the operation add to use with copy general.
static void operation(Tdst &dst, const Tsrc &src)
Defition of the add operation.
Structure to copy aggregates applying an operation.
static void operation(Tdst &dst, const Tsrc &src)
Defition of the add operation.
copy_general(const T &src, T &dst)
copy objects that are aggregates but define an operator=
static void operation(Tdst &dst, const Tsrc &src)
Defition of the replace operation.
copy_general_op(const T &src, T &dst)
Specialization when there is unknown copy method.
This structure define the operation add to use with copy general.
static void operation(Tdst &dst, const Tsrc &src)
Defition of the add operation.
copy_general(const T &src, T &dst)
Specialization when there is unknown copy method.
__device__ __host__ copy_general_op(const T &src, T &dst)
copy objects that has an operator= (implicit or explicit)
__device__ static __host__ void operation(Tdst &dst, const Tsrc &src)
Defition of the add operation.
This structure define the operation add to use with copy general.
This structure define the operation add to use with copy general.
copy_general(const T &src, T &dst)
copy objects that are aggregates