7 #ifndef cf3_common_PE_operations_hpp
8 #define cf3_common_PE_operations_hpp
14 #include <boost/type_traits/is_arithmetic.hpp>
47 MPI_CHECK_RESULT(MPI_Op_create, (Op::template func<T>, Op::is_commutative, &op));
60 template<
typename T,
typename Op,
typename selector =
void >
class get_mpi_op
65 static Operation op() {
return detail::get_mpi_op_impl<T,Op>(); }
75 #define MPI_CUSTOM_OPERATION(name,commutative,expression) class name \
78 static const bool is_commutative=commutative; \
79 template<typename T> static void func(void* in_, void* out_, int* len, Datatype* type) \
83 for (int i=0; i<*len; i++) \
106 template<
typename T>
struct get_mpi_op<
T,
max, typename
boost::enable_if<boost::is_arithmetic<T> >::type > {
public:
static Operation op() {
return MPI_MAX; } };
107 template<
typename T>
struct get_mpi_op<
T,
min, typename
boost::enable_if<boost::is_arithmetic<T> >::type > {
public:
static Operation op() {
return MPI_MIN; } };
108 template<
typename T>
struct get_mpi_op<
T, plus, typename
boost::enable_if<boost::is_arithmetic<T> >::type > {
public:
static Operation op() {
return MPI_SUM; } };
109 template<
typename T>
struct get_mpi_op<
T, multiplies, typename
boost::enable_if<boost::is_arithmetic<T> >::type > {
public:
static Operation op() {
return MPI_PROD; } };
110 template<
typename T>
struct get_mpi_op<
T, logical_and, typename
boost::enable_if<boost::is_arithmetic<T> >::type > {
public:
static Operation op() {
return MPI_LAND; } };
111 template<
typename T>
struct get_mpi_op<
T, logical_or, typename
boost::enable_if<boost::is_arithmetic<T> >::type > {
public:
static Operation op() {
return MPI_LOR; } };
112 template<
typename T>
struct get_mpi_op<
T, logical_xor, typename
boost::enable_if<boost::is_arithmetic<T> >::type > {
public:
static Operation op() {
return MPI_LXOR; } };
113 template<
typename T>
struct get_mpi_op<
T, bitwise_and, typename
boost::enable_if<boost::is_arithmetic<T> >::type > {
public:
static Operation op() {
return MPI_BAND; } };
114 template<
typename T>
struct get_mpi_op<
T, bitwise_or, typename
boost::enable_if<boost::is_arithmetic<T> >::type > {
public:
static Operation op() {
return MPI_BOR; } };
115 template<
typename T>
struct get_mpi_op<
T, bitwise_xor, typename
boost::enable_if<boost::is_arithmetic<T> >::type > {
public:
static Operation op() {
return MPI_BXOR; } };
144 #endif // cf3_common_PE_operations_hpp
MPI_CUSTOM_OPERATION(max, true,*out=*in > *out?*in:*out)
BUILT-IN OPERATIONS.
external boost library namespace
Real max(const Real a, const Real b)
Maximum between two scalars.
Real min(const Real a, const Real b)
Minimum between two scalars.
Top-level namespace for coolfluid.
#define MPI_CHECK_RESULT(MPIFunc, Args)
Macro for checking return values of any mpi calls and throws exception on error.
Operation get_mpi_op_impl()
ACCESS AND REGISTRATION MECHANISM.
MPI_Op Operation
operation (mostly for reduce and all_reduce)