From dbfe89d3374d21b871e1114e7650717fd6b826d4 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Sat, 3 Apr 2021 02:40:40 +0200 Subject: [PATCH] validate that MPI_Op can be applied at entrance of MPI call, instead of xbt_dying deep inside SMPI. For RMA comms, somehow derived datatypes also are allowed. and it's too late for me to add this, so keep the previous checks for now. --- src/smpi/bindings/smpi_pmpi_coll.cpp | 14 +-- src/smpi/bindings/smpi_pmpi_op.cpp | 2 +- src/smpi/bindings/smpi_pmpi_win.cpp | 8 +- src/smpi/include/private.hpp | 19 ++-- src/smpi/include/smpi_datatype.hpp | 32 ++++--- src/smpi/include/smpi_op.hpp | 4 +- src/smpi/mpi/smpi_datatype.cpp | 126 +++++++++++++-------------- src/smpi/mpi/smpi_op.cpp | 39 +++++---- 8 files changed, 131 insertions(+), 113 deletions(-) diff --git a/src/smpi/bindings/smpi_pmpi_coll.cpp b/src/smpi/bindings/smpi_pmpi_coll.cpp index 478be13e52..95d8c7c217 100644 --- a/src/smpi/bindings/smpi_pmpi_coll.cpp +++ b/src/smpi/bindings/smpi_pmpi_coll.cpp @@ -439,7 +439,7 @@ int PMPI_Ireduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype dat CHECK_BUFFER(5, recvbuf, count) CHECK_TYPE(4, datatype) CHECK_COUNT(3, count) - CHECK_OP(5) + CHECK_OP(5, op, datatype) CHECK_ROOT(7) CHECK_REQUEST(8) @@ -466,7 +466,7 @@ int PMPI_Reduce_local(const void* inbuf, void* inoutbuf, int count, MPI_Datatype CHECK_BUFFER(2, inoutbuf, count) CHECK_TYPE(4, datatype) CHECK_COUNT(3, count) - CHECK_OP(5) + CHECK_OP(5, op, datatype) smpi_bench_end(); op->apply(inbuf, inoutbuf, &count, datatype); @@ -487,7 +487,7 @@ int PMPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype CHECK_TYPE(4, datatype) CHECK_COUNT(3, count) CHECK_REQUEST(7) - CHECK_OP(5) + CHECK_OP(5, op, datatype) smpi_bench_end(); std::vector tmp_sendbuf; @@ -523,7 +523,7 @@ int PMPI_Iscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datat CHECK_TYPE(4, datatype) CHECK_COUNT(3, count) CHECK_REQUEST(7) - CHECK_OP(5) + CHECK_OP(5, op, datatype) smpi_bench_end(); int rank = simgrid::s4u::this_actor::get_pid(); @@ -558,7 +558,7 @@ int PMPI_Iexscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype dat CHECK_TYPE(4, datatype) CHECK_COUNT(3, count) CHECK_REQUEST(7) - CHECK_OP(5) + CHECK_OP(5, op, datatype) smpi_bench_end(); int rank = simgrid::s4u::this_actor::get_pid(); @@ -592,7 +592,7 @@ int PMPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcoun CHECK_TYPE(4, datatype) CHECK_NULL(3, MPI_ERR_COUNT, recvcounts) CHECK_REQUEST(7) - CHECK_OP(5) + CHECK_OP(5, op, datatype) for (int i = 0; i < comm->size(); i++) { CHECK_COUNT(3, recvcounts[i]) CHECK_BUFFER(1, sendbuf, recvcounts[i]) @@ -642,7 +642,7 @@ int PMPI_Ireduce_scatter_block(const void* sendbuf, void* recvbuf, int recvcount CHECK_TYPE(4, datatype) CHECK_COUNT(3, recvcount) CHECK_REQUEST(7) - CHECK_OP(5) + CHECK_OP(5, op, datatype) smpi_bench_end(); int count = comm->size(); diff --git a/src/smpi/bindings/smpi_pmpi_op.cpp b/src/smpi/bindings/smpi_pmpi_op.cpp index e90a6ba99b..a6200c1d98 100644 --- a/src/smpi/bindings/smpi_pmpi_op.cpp +++ b/src/smpi/bindings/smpi_pmpi_op.cpp @@ -30,7 +30,7 @@ int PMPI_Op_free(MPI_Op * op) } int PMPI_Op_commutative(MPI_Op op, int* commute){ - CHECK_OP(1) + CHECK_MPI_NULL(1, MPI_OP_NULL, MPI_ERR_OP, op) CHECK_NULL(1, MPI_ERR_ARG, commute) *commute = op->is_commutative(); return MPI_SUCCESS; diff --git a/src/smpi/bindings/smpi_pmpi_win.cpp b/src/smpi/bindings/smpi_pmpi_win.cpp index 97af6822a2..e8861546c0 100644 --- a/src/smpi/bindings/smpi_pmpi_win.cpp +++ b/src/smpi/bindings/smpi_pmpi_win.cpp @@ -279,7 +279,7 @@ int PMPI_Rput(const void *origin_addr, int origin_count, MPI_Datatype origin_dat int PMPI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank, MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){ CHECK_RMA - CHECK_OP(8) + CHECK_MPI_NULL(8, MPI_OP_NULL, MPI_ERR_OP, op) CHECK_WIN(9, win) CHECK_TARGET_DISP(5) @@ -308,7 +308,7 @@ int PMPI_Raccumulate(const void *origin_addr, int origin_count, MPI_Datatype ori if(target_rank==MPI_PROC_NULL) *request = MPI_REQUEST_NULL; CHECK_RMA - CHECK_OP(8) + CHECK_MPI_NULL(8, MPI_OP_NULL, MPI_ERR_OP, op) CHECK_WIN(9, win) CHECK_TARGET_DISP(5) CHECK_NULL(10, MPI_ERR_ARG, request) @@ -350,7 +350,7 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){ CHECK_NEGATIVE(7, MPI_ERR_RANK, target_rank) CHECK_COUNT(9, target_count) CHECK_TYPE(10, target_datatype) - CHECK_OP(11) + CHECK_MPI_NULL(11, MPI_OP_NULL, MPI_ERR_OP, op) CHECK_WIN(12, win) CHECK_TARGET_DISP(8) @@ -392,7 +392,7 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){ CHECK_NEGATIVE(7, MPI_ERR_RANK, target_rank) CHECK_COUNT(9, target_count) CHECK_TYPE(10, target_datatype) - CHECK_OP(11) + CHECK_MPI_NULL(11, MPI_OP_NULL, MPI_ERR_OP, op) CHECK_WIN(12, win) CHECK_TARGET_DISP(8) CHECK_NULL(10, MPI_ERR_ARG, request) diff --git a/src/smpi/include/private.hpp b/src/smpi/include/private.hpp index fe6bd5ad5f..afd523a439 100644 --- a/src/smpi/include/private.hpp +++ b/src/smpi/include/private.hpp @@ -552,29 +552,32 @@ XBT_PRIVATE void private_execute_flops(double flops); #define CHECK_TYPE(num, datatype) \ CHECK_ARGS(((datatype) == MPI_DATATYPE_NULL|| not (datatype)->is_valid()), MPI_ERR_TYPE, \ "%s: param %d %s cannot be MPI_DATATYPE_NULL or invalid", __func__, (num), _XBT_STRINGIFY(datatype)); -#define CHECK_OP(num) \ - CHECK_MPI_NULL((num), MPI_OP_NULL, MPI_ERR_OP, op) +#define CHECK_OP(num, op, type) \ + CHECK_MPI_NULL((num), MPI_OP_NULL, MPI_ERR_OP, (op)) \ + CHECK_ARGS(((op)->allowed_types() && (((op)->allowed_types() & (type)->flags()) == 0)), MPI_ERR_OP, \ + "%s: param %d op %s can't be applied to type %s", __func__, (num), _XBT_STRINGIFY(op), type->name()); + #define CHECK_ROOT(num)\ CHECK_ARGS((root < 0 || root >= comm->size()), MPI_ERR_ROOT, \ "%s: param %d root (=%d) cannot be negative or larger than communicator size (=%d)", __func__, (num), \ root, comm->size()); #define CHECK_PROC(num,proc) \ - CHECK_MPI_NULL((num), MPI_PROC_NULL, MPI_SUCCESS, (proc)) + CHECK_MPI_NULL((num), MPI_PROC_NULL, MPI_SUCCESS, (proc)) #define CHECK_INFO(num,info) \ - CHECK_MPI_NULL((num), MPI_INFO_NULL, MPI_ERR_INFO, (info)) + CHECK_MPI_NULL((num), MPI_INFO_NULL, MPI_ERR_INFO, (info)) #define CHECK_TAG(num,tag) \ CHECK_ARGS(((tag) < 0 && (tag) != MPI_ANY_TAG), MPI_ERR_TAG, \ "%s: param %d %s (=%d) cannot be negative", __func__, (num), _XBT_STRINGIFY(tag), (tag)); #define CHECK_FILE(num, fh) \ - CHECK_MPI_NULL((num), MPI_FILE_NULL, MPI_ERR_FILE, (fh)) + CHECK_MPI_NULL((num), MPI_FILE_NULL, MPI_ERR_FILE, (fh)) #define CHECK_OFFSET(num, offset) \ CHECK_NEGATIVE((num), MPI_ERR_DISP, (offset)) #define CHECK_GROUP(num, group) \ - CHECK_MPI_NULL((num), MPI_GROUP_NULL, MPI_ERR_GROUP, (group)) + CHECK_MPI_NULL((num), MPI_GROUP_NULL, MPI_ERR_GROUP, (group)) #define CHECK_WIN(num, win) \ - CHECK_MPI_NULL((num), MPI_WIN_NULL, MPI_ERR_WIN, (win)) + CHECK_MPI_NULL((num), MPI_WIN_NULL, MPI_ERR_WIN, (win)) #define CHECK_RANK(num, rank, comm) \ - CHECK_ARGS(((rank) >= (comm)->group()->size() || (rank) <0), MPI_ERR_RANK, \ + CHECK_ARGS(((rank) >= (comm)->group()->size() || (rank) <0), MPI_ERR_RANK, \ "%s: param %d %s (=%d) cannot be < 0 or > %d", __func__, (num), _XBT_STRINGIFY(rank), \ (rank), (comm)->group()->size() ); #endif diff --git a/src/smpi/include/smpi_datatype.hpp b/src/smpi/include/smpi_datatype.hpp index 3874680a06..294e617381 100644 --- a/src/smpi/include/smpi_datatype.hpp +++ b/src/smpi/include/smpi_datatype.hpp @@ -11,18 +11,26 @@ #include #include -constexpr unsigned DT_FLAG_DESTROYED = 0x0001; /**< user destroyed but some other layers still have a reference */ -constexpr unsigned DT_FLAG_COMMITED = 0x0002; /**< ready to be used for a send/recv operation */ -constexpr unsigned DT_FLAG_CONTIGUOUS = 0x0004; /**< contiguous datatype */ -constexpr unsigned DT_FLAG_OVERLAP = 0x0008; /**< datatype is unproper for a recv operation */ -constexpr unsigned DT_FLAG_USER_LB = 0x0010; /**< has a user defined LB */ -constexpr unsigned DT_FLAG_USER_UB = 0x0020; /**< has a user defined UB */ -constexpr unsigned DT_FLAG_PREDEFINED = 0x0040; /**< cannot be removed: initial and predefined datatypes */ -constexpr unsigned DT_FLAG_NO_GAPS = 0x0080; /**< no gaps around the datatype */ -constexpr unsigned DT_FLAG_DATA = 0x0100; /**< data or control structure */ -constexpr unsigned DT_FLAG_ONE_SIDED = 0x0200; /**< datatype can be used for one sided operations */ -constexpr unsigned DT_FLAG_UNAVAILABLE = 0x0400; /**< datatypes unavailable on the build (OS or compiler dependent) */ -constexpr unsigned DT_FLAG_DERIVED = 0x0800; /**< is the datatype derived ? */ +constexpr unsigned DT_FLAG_DESTROYED = 0x00001; /**< user destroyed but some other layers still have a reference */ +constexpr unsigned DT_FLAG_COMMITED = 0x00002; /**< ready to be used for a send/recv operation */ +constexpr unsigned DT_FLAG_CONTIGUOUS = 0x00004; /**< contiguous datatype */ +constexpr unsigned DT_FLAG_OVERLAP = 0x00008; /**< datatype is unproper for a recv operation */ +constexpr unsigned DT_FLAG_USER_LB = 0x00010; /**< has a user defined LB */ +constexpr unsigned DT_FLAG_USER_UB = 0x00020; /**< has a user defined UB */ +constexpr unsigned DT_FLAG_PREDEFINED = 0x00040; /**< cannot be removed: initial and predefined datatypes */ +constexpr unsigned DT_FLAG_NO_GAPS = 0x00080; /**< no gaps around the datatype */ +constexpr unsigned DT_FLAG_DATA = 0x00100; /**< data or control structure */ +constexpr unsigned DT_FLAG_ONE_SIDED = 0x00200; /**< datatype can be used for one sided operations */ +constexpr unsigned DT_FLAG_UNAVAILABLE = 0x00400; /**< datatypes unavailable on the build (OS or compiler dependent) */ +constexpr unsigned DT_FLAG_DERIVED = 0x00800; /**< is the datatype derived ? */ +constexpr unsigned DT_FLAG_C_INTEGER = 0x01000; /**< Family: C ints */ +constexpr unsigned DT_FLAG_F_INTEGER = 0x02000; /**< Family: F ints */ +constexpr unsigned DT_FLAG_FP = 0x04000; /**< Family: Floating point */ +constexpr unsigned DT_FLAG_LOGICAL = 0x08000; /**< Family: Logical */ +constexpr unsigned DT_FLAG_COMPLEX = 0x10000; /**< Family: Complex */ +constexpr unsigned DT_FLAG_BYTE = 0x20000; /**< Family: Poor lonesome byte */ +constexpr unsigned DT_FLAG_MULTILANG = 0x40000; /**< Family: Multi-language */ +constexpr unsigned DT_FLAG_REDUCTION = 0x80000; /**< Family: Dual types for maxloc/minloc */ /* * We should make the difference here between the predefined contiguous and non contiguous * datatypes. The DT_FLAG_BASIC is held by all predefined contiguous datatypes. diff --git a/src/smpi/include/smpi_op.hpp b/src/smpi/include/smpi_op.hpp index edf2042b47..bfb1e7d8c9 100644 --- a/src/smpi/include/smpi_op.hpp +++ b/src/smpi/include/smpi_op.hpp @@ -18,12 +18,14 @@ class Op : public F2C{ bool is_fortran_op_ = false; int refcount_ = 1; bool is_predefined_; + int types_; //bitmask of the allowed datatypes flags public: - Op(MPI_User_function* function, bool commutative, bool predefined=false) : func_(function), is_commutative_(commutative), is_predefined_(predefined) {if(not predefined) this->add_f();} + Op(MPI_User_function* function, bool commutative, bool predefined=false, int types=0) : func_(function), is_commutative_(commutative), is_predefined_(predefined), types_(types) {if(not predefined) this->add_f();} bool is_commutative() const { return is_commutative_; } bool is_predefined() const { return is_predefined_; } bool is_fortran_op() const { return is_fortran_op_; } + int allowed_types() const { return types_; } // tell that we were created from fortran, so we need to translate the type to fortran when called void set_fortran_op() { is_fortran_op_ = true; } void apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype) const; diff --git a/src/smpi/mpi/smpi_datatype.cpp b/src/smpi/mpi/smpi_datatype.cpp index 3f6b298608..d504388150 100644 --- a/src/smpi/mpi/smpi_datatype.cpp +++ b/src/smpi/mpi/smpi_datatype.cpp @@ -21,11 +21,11 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_datatype, smpi, "Logging specific to SMPI ( static std::unordered_map id2type_lookup; -#define CREATE_MPI_DATATYPE(name, id, type) \ +#define CREATE_MPI_DATATYPE(name, id, type, flag) \ simgrid::smpi::Datatype _XBT_CONCAT(smpi_MPI_, name)((char*)"MPI_"#name, (id), sizeof(type), /* size */ \ 0, /* lb */ \ sizeof(type), /* ub = lb + size */ \ - DT_FLAG_BASIC /* flags */ \ + DT_FLAG_BASIC | flag /* flags */ \ ); #define CREATE_MPI_DATATYPE_NULL(name, id) \ @@ -37,71 +37,71 @@ static std::unordered_map id2type_lookup; // Predefined data types CREATE_MPI_DATATYPE_NULL(DATATYPE_NULL, -1) -CREATE_MPI_DATATYPE(DOUBLE, 0, double) -CREATE_MPI_DATATYPE(INT, 1, int) -CREATE_MPI_DATATYPE(CHAR, 2, char) -CREATE_MPI_DATATYPE(SHORT, 3, short) -CREATE_MPI_DATATYPE(LONG, 4, long) -CREATE_MPI_DATATYPE(FLOAT, 5, float) -CREATE_MPI_DATATYPE(BYTE, 6, int8_t) -CREATE_MPI_DATATYPE(LONG_LONG, 7, long long) -CREATE_MPI_DATATYPE(SIGNED_CHAR, 8, signed char) -CREATE_MPI_DATATYPE(UNSIGNED_CHAR, 9, unsigned char) -CREATE_MPI_DATATYPE(UNSIGNED_SHORT, 10, unsigned short) -CREATE_MPI_DATATYPE(UNSIGNED, 11, unsigned int) -CREATE_MPI_DATATYPE(UNSIGNED_LONG, 12, unsigned long) -CREATE_MPI_DATATYPE(UNSIGNED_LONG_LONG, 13, unsigned long long) -CREATE_MPI_DATATYPE(LONG_DOUBLE, 14, long double) -CREATE_MPI_DATATYPE(WCHAR, 15, wchar_t) -CREATE_MPI_DATATYPE(C_BOOL, 16, bool) -CREATE_MPI_DATATYPE(INT8_T, 17, int8_t) -CREATE_MPI_DATATYPE(INT16_T, 18, int16_t) -CREATE_MPI_DATATYPE(INT32_T, 19, int32_t) -CREATE_MPI_DATATYPE(INT64_T, 20, int64_t) -CREATE_MPI_DATATYPE(UINT8_T, 21, uint8_t) -CREATE_MPI_DATATYPE(UINT16_T, 22, uint16_t) -CREATE_MPI_DATATYPE(UINT32_T, 23, uint32_t) -CREATE_MPI_DATATYPE(UINT64_T, 24, uint64_t) -CREATE_MPI_DATATYPE(C_FLOAT_COMPLEX, 25, float _Complex) -CREATE_MPI_DATATYPE(C_DOUBLE_COMPLEX, 26, double _Complex) -CREATE_MPI_DATATYPE(C_LONG_DOUBLE_COMPLEX, 27, long double _Complex) -CREATE_MPI_DATATYPE(AINT, 28, MPI_Aint) -CREATE_MPI_DATATYPE(OFFSET, 29, MPI_Offset) - -CREATE_MPI_DATATYPE(FLOAT_INT, 30, float_int) -CREATE_MPI_DATATYPE(LONG_INT, 31, long_int) -CREATE_MPI_DATATYPE(DOUBLE_INT, 32, double_int) -CREATE_MPI_DATATYPE(SHORT_INT, 33, short_int) -CREATE_MPI_DATATYPE(2INT, 34, int_int) -CREATE_MPI_DATATYPE(2FLOAT, 35, float_float) -CREATE_MPI_DATATYPE(2DOUBLE, 36, double_double) -CREATE_MPI_DATATYPE(2LONG, 37, long_long) - -CREATE_MPI_DATATYPE(REAL, 38, float) -CREATE_MPI_DATATYPE(REAL4, 39, float) -CREATE_MPI_DATATYPE(REAL8, 40, double) -CREATE_MPI_DATATYPE(REAL16, 41, long double) -CREATE_MPI_DATATYPE(COMPLEX8, 42, float_float) -CREATE_MPI_DATATYPE(COMPLEX16, 43, double_double) -CREATE_MPI_DATATYPE(COMPLEX32, 44, double_double) -CREATE_MPI_DATATYPE(INTEGER1, 45, int) -CREATE_MPI_DATATYPE(INTEGER2, 46, int16_t) -CREATE_MPI_DATATYPE(INTEGER4, 47, int32_t) -CREATE_MPI_DATATYPE(INTEGER8, 48, int64_t) -CREATE_MPI_DATATYPE(INTEGER16, 49, integer128_t) - -CREATE_MPI_DATATYPE(LONG_DOUBLE_INT, 50, long_double_int) -CREATE_MPI_DATATYPE(CXX_BOOL, 51, bool) -CREATE_MPI_DATATYPE(CXX_FLOAT_COMPLEX, 52, std::complex) -CREATE_MPI_DATATYPE(CXX_DOUBLE_COMPLEX, 53, std::complex) -CREATE_MPI_DATATYPE(CXX_LONG_DOUBLE_COMPLEX, 54, std::complex) +CREATE_MPI_DATATYPE(DOUBLE, 0, double, DT_FLAG_FP) +CREATE_MPI_DATATYPE(INT, 1, int, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(CHAR, 2, char, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(SHORT, 3, short, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(LONG, 4, long, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(FLOAT, 5, float, DT_FLAG_FP) +CREATE_MPI_DATATYPE(BYTE, 6, int8_t, DT_FLAG_BYTE) +CREATE_MPI_DATATYPE(LONG_LONG, 7, long long, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(SIGNED_CHAR, 8, signed char, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(UNSIGNED_CHAR, 9, unsigned char, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(UNSIGNED_SHORT, 10, unsigned short, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(UNSIGNED, 11, unsigned int, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(UNSIGNED_LONG, 12, unsigned long, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(UNSIGNED_LONG_LONG, 13, unsigned long long, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(LONG_DOUBLE, 14, long double, DT_FLAG_FP) +CREATE_MPI_DATATYPE(WCHAR, 15, wchar_t, DT_FLAG_BASIC) +CREATE_MPI_DATATYPE(C_BOOL, 16, bool, DT_FLAG_LOGICAL) +CREATE_MPI_DATATYPE(INT8_T, 17, int8_t, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(INT16_T, 18, int16_t, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(INT32_T, 19, int32_t, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(INT64_T, 20, int64_t, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(UINT8_T, 21, uint8_t, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(UINT16_T, 22, uint16_t, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(UINT32_T, 23, uint32_t, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(UINT64_T, 24, uint64_t, DT_FLAG_C_INTEGER) +CREATE_MPI_DATATYPE(C_FLOAT_COMPLEX, 25, float _Complex, DT_FLAG_COMPLEX) +CREATE_MPI_DATATYPE(C_DOUBLE_COMPLEX, 26, double _Complex, DT_FLAG_COMPLEX) +CREATE_MPI_DATATYPE(C_LONG_DOUBLE_COMPLEX, 27, long double _Complex, DT_FLAG_COMPLEX) +CREATE_MPI_DATATYPE(AINT, 28, MPI_Aint, DT_FLAG_MULTILANG) +CREATE_MPI_DATATYPE(OFFSET, 29, MPI_Offset, DT_FLAG_MULTILANG) + +CREATE_MPI_DATATYPE(FLOAT_INT, 30, float_int, DT_FLAG_REDUCTION) +CREATE_MPI_DATATYPE(LONG_INT, 31, long_int, DT_FLAG_REDUCTION) +CREATE_MPI_DATATYPE(DOUBLE_INT, 32, double_int, DT_FLAG_REDUCTION) +CREATE_MPI_DATATYPE(SHORT_INT, 33, short_int, DT_FLAG_REDUCTION) +CREATE_MPI_DATATYPE(2INT, 34, int_int, DT_FLAG_REDUCTION) +CREATE_MPI_DATATYPE(2FLOAT, 35, float_float, DT_FLAG_REDUCTION) +CREATE_MPI_DATATYPE(2DOUBLE, 36, double_double, DT_FLAG_REDUCTION) +CREATE_MPI_DATATYPE(2LONG, 37, long_long, DT_FLAG_REDUCTION) + +CREATE_MPI_DATATYPE(REAL, 38, float, DT_FLAG_FP) +CREATE_MPI_DATATYPE(REAL4, 39, float, DT_FLAG_FP) +CREATE_MPI_DATATYPE(REAL8, 40, double, DT_FLAG_FP) +CREATE_MPI_DATATYPE(REAL16, 41, long double, DT_FLAG_FP) +CREATE_MPI_DATATYPE(COMPLEX8, 42, float_float, DT_FLAG_COMPLEX) +CREATE_MPI_DATATYPE(COMPLEX16, 43, double_double, DT_FLAG_COMPLEX) +CREATE_MPI_DATATYPE(COMPLEX32, 44, double_double, DT_FLAG_COMPLEX) +CREATE_MPI_DATATYPE(INTEGER1, 45, int, DT_FLAG_F_INTEGER) +CREATE_MPI_DATATYPE(INTEGER2, 46, int16_t, DT_FLAG_F_INTEGER) +CREATE_MPI_DATATYPE(INTEGER4, 47, int32_t, DT_FLAG_F_INTEGER) +CREATE_MPI_DATATYPE(INTEGER8, 48, int64_t, DT_FLAG_F_INTEGER) +CREATE_MPI_DATATYPE(INTEGER16, 49, integer128_t, DT_FLAG_F_INTEGER) + +CREATE_MPI_DATATYPE(LONG_DOUBLE_INT, 50, long_double_int, DT_FLAG_REDUCTION) +CREATE_MPI_DATATYPE(CXX_BOOL, 51, bool, DT_FLAG_LOGICAL) +CREATE_MPI_DATATYPE(CXX_FLOAT_COMPLEX, 52, std::complex, DT_FLAG_COMPLEX) +CREATE_MPI_DATATYPE(CXX_DOUBLE_COMPLEX, 53, std::complex, DT_FLAG_COMPLEX) +CREATE_MPI_DATATYPE(CXX_LONG_DOUBLE_COMPLEX, 54, std::complex, DT_FLAG_COMPLEX) CREATE_MPI_DATATYPE_NULL(UB, 55) CREATE_MPI_DATATYPE_NULL(LB, 56) -CREATE_MPI_DATATYPE(PACKED, 57, char) +CREATE_MPI_DATATYPE(PACKED, 57, char, DT_FLAG_PREDEFINED) // Internal use only -CREATE_MPI_DATATYPE(PTR, 58, void*) -CREATE_MPI_DATATYPE(COUNT, 59, long long) +CREATE_MPI_DATATYPE(PTR, 58, void*, DT_FLAG_PREDEFINED) +CREATE_MPI_DATATYPE(COUNT, 59, long long, DT_FLAG_MULTILANG) MPI_Datatype MPI_PTR = &smpi_MPI_PTR; diff --git a/src/smpi/mpi/smpi_op.cpp b/src/smpi/mpi/smpi_op.cpp index 89df84e5fc..14b42bcab6 100644 --- a/src/smpi/mpi/smpi_op.cpp +++ b/src/smpi/mpi/smpi_op.cpp @@ -221,23 +221,28 @@ static void no_func(void*, void*, int*, MPI_Datatype*) /* obviously a no-op */ } -#define CREATE_MPI_OP(name, func) \ - SMPI_Op _XBT_CONCAT(smpi_MPI_, name)(&(func) /* func */, true, true); \ - -CREATE_MPI_OP(MAX, max_func) -CREATE_MPI_OP(MIN, min_func) -CREATE_MPI_OP(SUM, sum_func) -CREATE_MPI_OP(PROD, prod_func) -CREATE_MPI_OP(LAND, land_func) -CREATE_MPI_OP(LOR, lor_func) -CREATE_MPI_OP(LXOR, lxor_func) -CREATE_MPI_OP(BAND, band_func) -CREATE_MPI_OP(BOR, bor_func) -CREATE_MPI_OP(BXOR, bxor_func) -CREATE_MPI_OP(MAXLOC, maxloc_func) -CREATE_MPI_OP(MINLOC, minloc_func) -CREATE_MPI_OP(REPLACE, replace_func) -CREATE_MPI_OP(NO_OP, no_func) + +#define CREATE_MPI_OP(name, func, types) \ + SMPI_Op _XBT_CONCAT(smpi_MPI_, name)(&(func) /* func */, true, true, types); + +#define MAX_TYPES DT_FLAG_C_INTEGER|DT_FLAG_F_INTEGER|DT_FLAG_FP|DT_FLAG_MULTILANG +#define LAND_TYPES DT_FLAG_C_INTEGER|DT_FLAG_FP|DT_FLAG_LOGICAL|DT_FLAG_MULTILANG +#define BAND_TYPES DT_FLAG_C_INTEGER|DT_FLAG_FP|DT_FLAG_BYTE|DT_FLAG_MULTILANG + +CREATE_MPI_OP(MAX, max_func, MAX_TYPES) +CREATE_MPI_OP(MIN, min_func, MAX_TYPES) +CREATE_MPI_OP(SUM, sum_func, MAX_TYPES|DT_FLAG_COMPLEX) +CREATE_MPI_OP(PROD, prod_func, MAX_TYPES|DT_FLAG_COMPLEX) +CREATE_MPI_OP(LAND, land_func, LAND_TYPES) +CREATE_MPI_OP(LOR, lor_func, LAND_TYPES) +CREATE_MPI_OP(LXOR, lxor_func, LAND_TYPES) +CREATE_MPI_OP(BAND, band_func, BAND_TYPES) +CREATE_MPI_OP(BOR, bor_func, BAND_TYPES) +CREATE_MPI_OP(BXOR, bxor_func, BAND_TYPES) +CREATE_MPI_OP(MAXLOC, maxloc_func, DT_FLAG_REDUCTION) +CREATE_MPI_OP(MINLOC, minloc_func, DT_FLAG_REDUCTION) +CREATE_MPI_OP(REPLACE, replace_func, 0) +CREATE_MPI_OP(NO_OP, no_func, 0) namespace simgrid{ namespace smpi{ -- 2.20.1