From c8fe71649f644619ea7fe8ffb71e7ce1c52f3e47 Mon Sep 17 00:00:00 2001 From: Matthias Troyer Date: Thu, 7 May 2009 05:48:26 +0000 Subject: [PATCH] Fixes for bugs 2586 and 2594 [SVN r52820] --- include/boost/mpi/collectives/all_reduce.hpp | 2 +- include/boost/mpi/collectives/reduce.hpp | 4 ++-- include/boost/mpi/collectives/scan.hpp | 2 +- include/boost/mpi/detail/mpi_datatype_cache.hpp | 2 ++ src/environment.cpp | 2 ++ src/mpi_datatype_cache.cpp | 8 +++++++- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/boost/mpi/collectives/all_reduce.hpp b/include/boost/mpi/collectives/all_reduce.hpp index 9a62d3b..26b8fc9 100644 --- a/include/boost/mpi/collectives/all_reduce.hpp +++ b/include/boost/mpi/collectives/all_reduce.hpp @@ -33,7 +33,7 @@ namespace detail { BOOST_MPI_CHECK_RESULT(MPI_Allreduce, (const_cast(in_values), out_values, n, boost::mpi::get_mpi_datatype(*in_values), - is_mpi_op::op(), comm)); + (is_mpi_op::op()), comm)); } /********************************************************************** diff --git a/include/boost/mpi/collectives/reduce.hpp b/include/boost/mpi/collectives/reduce.hpp index 6ea8279..f1dee82 100644 --- a/include/boost/mpi/collectives/reduce.hpp +++ b/include/boost/mpi/collectives/reduce.hpp @@ -52,7 +52,7 @@ namespace detail { BOOST_MPI_CHECK_RESULT(MPI_Reduce, (const_cast(in_values), out_values, n, boost::mpi::get_mpi_datatype(*in_values), - is_mpi_op::op(), root, comm)); + (is_mpi_op::op()), root, comm)); } // We are reducing to the root for a type that has an associated MPI @@ -65,7 +65,7 @@ namespace detail { BOOST_MPI_CHECK_RESULT(MPI_Reduce, (const_cast(in_values), 0, n, boost::mpi::get_mpi_datatype(*in_values), - is_mpi_op::op(), root, comm)); + (is_mpi_op::op()), root, comm)); } /********************************************************************** diff --git a/include/boost/mpi/collectives/scan.hpp b/include/boost/mpi/collectives/scan.hpp index 83dc8ca..4cba4a8 100644 --- a/include/boost/mpi/collectives/scan.hpp +++ b/include/boost/mpi/collectives/scan.hpp @@ -52,7 +52,7 @@ namespace detail { BOOST_MPI_CHECK_RESULT(MPI_Scan, (const_cast(in_values), out_values, n, boost::mpi::get_mpi_datatype(*in_values), - is_mpi_op::op(), comm)); + (is_mpi_op::op()), comm)); } /********************************************************************** diff --git a/include/boost/mpi/detail/mpi_datatype_cache.hpp b/include/boost/mpi/detail/mpi_datatype_cache.hpp index 4564849..cc073e2 100644 --- a/include/boost/mpi/detail/mpi_datatype_cache.hpp +++ b/include/boost/mpi/detail/mpi_datatype_cache.hpp @@ -79,6 +79,8 @@ public: return datatype; } + + void clear(); private: MPI_Datatype get(const std::type_info* t); diff --git a/src/environment.cpp b/src/environment.cpp index ae475e4..4da8447 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -7,6 +7,7 @@ // Message Passing Interface 1.1 -- 7.1.1. Environmental Inquiries #include #include +#include #include #include #include @@ -45,6 +46,7 @@ environment::~environment() if (std::uncaught_exception() && abort_on_exception) { abort(-1); } else if (!finalized()) { + detail::mpi_datatype_cache().clear(); BOOST_MPI_CHECK_RESULT(MPI_Finalize, ()); } } diff --git a/src/mpi_datatype_cache.cpp b/src/mpi_datatype_cache.cpp index ab52b64..8134351 100644 --- a/src/mpi_datatype_cache.cpp +++ b/src/mpi_datatype_cache.cpp @@ -25,7 +25,7 @@ namespace boost { namespace mpi { namespace detail { impl = new implementation(); } - mpi_datatype_map::~mpi_datatype_map() + void mpi_datatype_map::clear() { // do not free after call to MPI_FInalize int finalized=0; @@ -35,6 +35,12 @@ namespace boost { namespace mpi { namespace detail { for (stored_map_type::iterator it=impl->map.begin(); it != impl->map.end(); ++it) MPI_Type_free(&(it->second)); } + } + + + mpi_datatype_map::~mpi_datatype_map() + { + clear(); delete impl; }