From d5e44448d02938865d85a9822070362195900bfb Mon Sep 17 00:00:00 2001 From: degomme Date: Thu, 6 Apr 2017 11:03:23 +0200 Subject: [PATCH] try to appease ubsan a bit --- src/smpi/smpi_op.cpp | 2 +- src/smpi/smpi_request.cpp | 10 +++++++--- teshsuite/smpi/mpich3-test/rma/manyrma2.c | 2 +- teshsuite/smpi/mpich3-test/rma/rma-contig.c | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/smpi/smpi_op.cpp b/src/smpi/smpi_op.cpp index a4e42aa872..9d14284567 100644 --- a/src/smpi/smpi_op.cpp +++ b/src/smpi/smpi_op.cpp @@ -243,7 +243,7 @@ void Op::apply(void *invec, void *inoutvec, int *len, MPI_Datatype datatype) smpi_switch_data_segment(smpi_process()->index()); } - if(!smpi_process()->replaying()){ + if(!smpi_process()->replaying() && *len > 0){ if(! is_fortran_op_) this->func_(invec, inoutvec, len, &datatype); else{ diff --git a/src/smpi/smpi_request.cpp b/src/smpi/smpi_request.cpp index f4d54103f7..33eaa9a483 100644 --- a/src/smpi/smpi_request.cpp +++ b/src/smpi/smpi_request.cpp @@ -111,9 +111,13 @@ Request::Request(void *buf, int count, MPI_Datatype datatype, int src, int dst, if(((((flags & RECV) != 0) && ((flags & ACCUMULATE) !=0)) || (datatype->flags() & DT_FLAG_DERIVED)) && (!smpi_is_shared(buf_))){ // This part handles the problem of non-contiguous memory old_buf = buf; - buf_ = count==0 ? nullptr : xbt_malloc(count*datatype->size()); - if ((datatype->flags() & DT_FLAG_DERIVED) && ((flags & SEND) != 0)) { - datatype->serialize(old_buf, buf_, count); + if (count==0){ + buf_ = nullptr; + }else { + buf_ = xbt_malloc(count*datatype->size()); + if ((datatype->flags() & DT_FLAG_DERIVED) && ((flags & SEND) != 0)) { + datatype->serialize(old_buf, buf_, count); + } } } // This part handles the problem of non-contiguous memory (for the unserialisation at the reception) diff --git a/teshsuite/smpi/mpich3-test/rma/manyrma2.c b/teshsuite/smpi/mpich3-test/rma/manyrma2.c index c7436bcc29..f86619eba9 100644 --- a/teshsuite/smpi/mpich3-test/rma/manyrma2.c +++ b/teshsuite/smpi/mpich3-test/rma/manyrma2.c @@ -16,7 +16,7 @@ #include #define MAX_COUNT 512 -#define MAX_RMA_SIZE 2 /* 16 in manyrma performance test */ +#define MAX_RMA_SIZE 1 /* 16 in manyrma performance test */ #define MAX_RUNS 8 #define MAX_ITER_TIME 5.0 /* seconds */ diff --git a/teshsuite/smpi/mpich3-test/rma/rma-contig.c b/teshsuite/smpi/mpich3-test/rma/rma-contig.c index 4ca7127ad7..7cc14de5e6 100644 --- a/teshsuite/smpi/mpich3-test/rma/rma-contig.c +++ b/teshsuite/smpi/mpich3-test/rma/rma-contig.c @@ -20,7 +20,7 @@ static int rank; static void run_test(int lock_mode, int lock_assert) { int nproc, test_iter, target_rank, data_size; - int *buf, *win_buf; + char *buf, *win_buf; MPI_Win win; MPI_Comm_rank(MPI_COMM_WORLD, &rank); @@ -101,8 +101,8 @@ static void run_test(int lock_mode, int lock_assert) t_acc = MPI_Wtime(); MPI_Win_lock(lock_mode, target_rank, lock_assert, win); - MPI_Accumulate(buf, data_size / sizeof(int), MPI_INT, target_rank, - 0, data_size / sizeof(int), MPI_INT, MPI_SUM, win); + MPI_Accumulate(buf, data_size, MPI_BYTE, target_rank, + 0, data_size, MPI_BYTE, MPI_SUM, win); MPI_Win_unlock(target_rank, win); } t_acc = (MPI_Wtime() - t_acc) / num_iter; -- 2.20.1