X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/77b1286ea2fbc5c4dd502da81961599504f01000..863aeead864a309c494893a1b06ec33ed2b7daf1:/src/smpi/smpi_op.cpp diff --git a/src/smpi/smpi_op.cpp b/src/smpi/smpi_op.cpp index 5ef10681d2..9cd6612b1c 100644 --- a/src/smpi/smpi_op.cpp +++ b/src/smpi/smpi_op.cpp @@ -3,8 +3,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "mc/mc.h" -#include "private.h" +#include "src/smpi/private.h" +#include "src/smpi/smpi_datatype.hpp" +#include "src/smpi/smpi_op.hpp" +#include "src/smpi/smpi_process.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_op, smpi, "Logging specific to SMPI (op)"); @@ -14,12 +16,12 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_op, smpi, "Logging specific to SMPI (op)"); #define PROD_OP(a, b) (b) *= (a) #define LAND_OP(a, b) (b) = (a) && (b) #define LOR_OP(a, b) (b) = (a) || (b) -#define LXOR_OP(a, b) (b) = (!(a) && (b)) || ((a) && !(b)) +#define LXOR_OP(a, b) (b) = (not(a) && (b)) || ((a) && not(b)) #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) \ { \ @@ -190,6 +192,7 @@ static void replace_func(void *a, void *b, int *length, MPI_Datatype * datatype) static void no_func(void *a, void *b, int *length, MPI_Datatype * datatype) { + /* obviously a no-op */ } #define CREATE_MPI_OP(name, func) \ @@ -237,13 +240,13 @@ void Op::set_fortran_op() void Op::apply(void *invec, void *inoutvec, int *len, MPI_Datatype datatype) { - if(smpi_privatize_global_variables){//we need to switch as the called function may silently touch global variables + if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){//we need to switch as the called function may silently touch global variables XBT_DEBUG("Applying operation, switch to the right data frame "); smpi_switch_data_segment(smpi_process()->index()); } - if(!smpi_process()->replaying()){ - if(! is_fortran_op_) + if (not smpi_process()->replaying() && *len > 0) { + if (not is_fortran_op_) this->func_(invec, inoutvec, len, &datatype); else{ XBT_DEBUG("Applying operation of length %d from %p and from/to %p", *len, invec, inoutvec);