From e0a8173fd5ec09538eafc6959a8a52fa9ce36804 Mon Sep 17 00:00:00 2001 From: degomme Date: Thu, 6 Apr 2017 00:28:10 +0200 Subject: [PATCH] cornercases handling --- src/smpi/smpi_op.cpp | 4 ++-- src/smpi/smpi_pmpi.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/smpi/smpi_op.cpp b/src/smpi/smpi_op.cpp index 5d3136e8f2..a4e42aa872 100644 --- a/src/smpi/smpi_op.cpp +++ b/src/smpi/smpi_op.cpp @@ -18,8 +18,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_op, smpi, "Logging specific to SMPI (op)"); #define BAND_OP(a, b) (b) &= (a) #define BOR_OP(a, b) (b) |= (a) #define BXOR_OP(a, b) (b) ^= (a) -#define MAXLOC_OP(a, b) (b) = (a.value) < (b.value) ? (b) : (a) -#define MINLOC_OP(a, b) (b) = (a.value) < (b.value) ? (a) : (b) +#define MAXLOC_OP(a, b) (b) = (a.value) < (b.value) ? (b) : ((a.value) == (b.value) ? ((a.index) < (b.index) ? (a) : (b)) : (a)) +#define MINLOC_OP(a, b) (b) = (a.value) < (b.value) ? (a) : ((a.value) == (b.value) ? ((a.index) < (b.index) ? (a) : (b)) : (b)) #define APPLY_FUNC(a, b, length, type, func) \ { \ diff --git a/src/smpi/smpi_pmpi.cpp b/src/smpi/smpi_pmpi.cpp index d68f54c12e..c6082e4e3e 100644 --- a/src/smpi/smpi_pmpi.cpp +++ b/src/smpi/smpi_pmpi.cpp @@ -2841,10 +2841,10 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){ //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address retval = MPI_ERR_ARG; } else if ((origin_count < 0 || target_count < 0 || result_count <0) || - (origin_addr==nullptr && origin_count > 0) || + (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) || (result_addr==nullptr && result_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((!origin_datatype->is_valid()) || + } else if ((origin_datatype!=MPI_DATATYPE_NULL && !origin_datatype->is_valid()) || (!target_datatype->is_valid())|| (!result_datatype->is_valid())) { retval = MPI_ERR_TYPE; @@ -2884,10 +2884,10 @@ MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request* request){ //in case of dynamic window, target_disp can be mistakenly seen as negative, as it is an address retval = MPI_ERR_ARG; } else if ((origin_count < 0 || target_count < 0 || result_count <0) || - (origin_addr==nullptr && origin_count > 0) || + (origin_addr==nullptr && origin_count > 0 && op != MPI_NO_OP) || (result_addr==nullptr && result_count > 0)){ retval = MPI_ERR_COUNT; - } else if ((!origin_datatype->is_valid()) || + } else if ((origin_datatype!=MPI_DATATYPE_NULL && !origin_datatype->is_valid()) || (!target_datatype->is_valid())|| (!result_datatype->is_valid())) { retval = MPI_ERR_TYPE; -- 2.20.1