From c5270b066f6f810b2fa184650a4215bb5c83ba27 Mon Sep 17 00:00:00 2001 From: Alain Miniussi Date: Mon, 18 Sep 2023 18:20:21 +0200 Subject: [PATCH] Make sure we free the Boost.MPI type built for C++ bool (sice there is no MPI Bool type) --- include/boost/mpi/datatype.hpp | 1 + src/mpi_datatype_cache.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/boost/mpi/datatype.hpp b/include/boost/mpi/datatype.hpp index 6e104c1..b9d4902 100644 --- a/include/boost/mpi/datatype.hpp +++ b/include/boost/mpi/datatype.hpp @@ -320,6 +320,7 @@ BOOST_MPI_DATATYPE(signed char, MPI_SIGNED_CHAR, builtin); namespace detail { inline MPI_Datatype build_mpi_datatype_for_bool() { + // this is explicitly freed in mpi_datatype_map::clear MPI_Datatype type; MPI_Type_contiguous(sizeof(bool), MPI_BYTE, &type); MPI_Type_commit(&type); diff --git a/src/mpi_datatype_cache.cpp b/src/mpi_datatype_cache.cpp index 8437e9d..1f8607f 100644 --- a/src/mpi_datatype_cache.cpp +++ b/src/mpi_datatype_cache.cpp @@ -8,6 +8,7 @@ #include #include +#include #include namespace boost { namespace mpi { namespace detail { @@ -34,6 +35,9 @@ namespace boost { namespace mpi { namespace detail { // ignore errors in the destructor for (stored_map_type::iterator it=impl->map.begin(); it != impl->map.end(); ++it) MPI_Type_free(&(it->second)); + // We explicitly created this one, as there is no equivalent in the MPI standard + MPI_Datatype bool_type = get_mpi_datatype(bool()); + MPI_Type_free(&bool_type); } }