From 1f9b69e371e621ff8a7152b7ab8f5a7459563a2d Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Fri, 6 Jul 2018 08:37:37 +0200 Subject: [PATCH] [SMPI] Make MPI_DATATYPE_NULL a non-null object We're calling methods on the Datatype objects, such as datatype->size(), especially in the replay component. With MPI_DATATYPE_NULL being the nullptr, we'd have to check every time whether or not a given object is actually MPI_DATATYPE_NULL before using it. Making MPI_DATATYPE_NULL a real object allows us to call methods on this object that will be meaningful (for instance, size() returns 0) and to avoid this constant checking. Thanks to Michael Mercier for reporting this bug. --- include/smpi/smpi.h | 2 +- src/smpi/mpi/smpi_datatype.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 12e2ae6d8a..32630eee36 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -224,7 +224,7 @@ typedef SMPI_Info* MPI_Info; #define MPI_STATUS_IGNORE ((MPI_Status*)NULL) #define MPI_STATUSES_IGNORE ((MPI_Status*)NULL) -#define MPI_DATATYPE_NULL ((const MPI_Datatype)NULL) +XBT_PUBLIC_DATA const MPI_Datatype MPI_DATATYPE_NULL; XBT_PUBLIC_DATA const MPI_Datatype MPI_CHAR; XBT_PUBLIC_DATA const MPI_Datatype MPI_SHORT; XBT_PUBLIC_DATA const MPI_Datatype MPI_INT; diff --git a/src/smpi/mpi/smpi_datatype.cpp b/src/smpi/mpi/smpi_datatype.cpp index 5e752c173f..954dbc96c8 100644 --- a/src/smpi/mpi/smpi_datatype.cpp +++ b/src/smpi/mpi/smpi_datatype.cpp @@ -76,6 +76,7 @@ CREATE_MPI_DATATYPE(MPI_REAL, 38, float); CREATE_MPI_DATATYPE(MPI_REAL4, 39, float); CREATE_MPI_DATATYPE(MPI_REAL8, 40, float); CREATE_MPI_DATATYPE(MPI_REAL16, 41, double); +CREATE_MPI_DATATYPE_NULL(MPI_DATATYPE_NULL, -1); CREATE_MPI_DATATYPE_NULL(MPI_COMPLEX8, 42); CREATE_MPI_DATATYPE_NULL(MPI_COMPLEX16, 43); CREATE_MPI_DATATYPE_NULL(MPI_COMPLEX32, 44); -- 2.20.1