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"
26template<
typename Tdst,
typename Tsrc>
35 static inline void operation(Tdst & dst,
const Tsrc & src)
37 dst = (src > dst)?src:dst;
47template<
typename Tdst,
typename Tsrc>
56 static inline void operation(Tdst & dst,
const Tsrc & src)
58 dst = (src < dst)?src:dst;
68template<
typename Tdst,
typename Tsrc>
77 __device__ __host__
static inline void operation(Tdst & dst,
const Tsrc & src)
83#if defined(__clang__) && !defined(CUDA_ON_CPU)
85template<
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;
99template<
typename Tdst,
typename Tsrc>
108 __device__ __host__
static inline void operation(Tdst & dst,
const Tsrc & src)
120template<
typename Tdst,
typename Tsrc>
129 static inline void operation(Tdst & dst,
const Tsrc & src)
141template<
typename Tdst,
typename Tsrc>
150 static inline void operation(Tdst & dst,
const Tsrc & src)
161template<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);
235template<
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;
253template<
template<
typename,
typename>
class op,
typename T>
264 op<T,T>::operation(dst,src);
269template<
template<
typename,
typename>
class op,
typename T>
282 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,T::max_prop>>(cp);
This structure define the operation add to use with copy general.
__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.
__device__ static __host__ void operation(Tdst &dst, const Tsrc &src)
Defition of the add operation.
Structure to copy aggregates applying an operation.
Structure to copy aggregates.
__device__ __host__ copy_general(const T &src, T &dst)
copy objects that has an operator= (implicit or explicit)
copy_general(const T &src, T &dst)
copy objects that are aggregates
copy_general(const T &src, T &dst)
copy objects that are aggregates but define an operator=
__device__ __host__ copy_general_op(const T &src, T &dst)
copy objects that has an operator= (implicit or explicit)
__device__ __host__ copy_general_op(const T &src, T &dst)
copy objects that are aggregates
structure to copy aggregates applying an operation
copy_general_op(const T &src, T &dst)
Specialization when there is unknown copy method.
structure to copy aggregates
copy_general(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.
This structure define the operation add to use with copy general.
static void operation(Tdst &dst, const Tsrc &src)
Defition of the add operation.
This structure define the operation add to use with copy general.
static void operation(Tdst &dst, const Tsrc &src)
Defition of the add operation.
This structure define the operation add to use with copy general.
static void operation(Tdst &dst, const Tsrc &src)
Defition of the replace operation.