From 4790e99817c894d311c0d2ad149444c52f76668c Mon Sep 17 00:00:00 2001 From: paboyle Date: Tue, 20 Feb 2018 15:12:31 +0000 Subject: [PATCH] Extra communicator free that I had missed. Hard to audit them all as this is complex --- lib/communicator/Communicator_mpi3.cc | 12 ++++++++++-- lib/communicator/SharedMemory.h | 1 + lib/communicator/SharedMemoryMPI.cc | 4 ++++ lib/communicator/SharedMemoryNone.cc | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/communicator/Communicator_mpi3.cc b/lib/communicator/Communicator_mpi3.cc index eb0144f0..424b7973 100644 --- a/lib/communicator/Communicator_mpi3.cc +++ b/lib/communicator/Communicator_mpi3.cc @@ -89,10 +89,16 @@ void CartesianCommunicator::ProcessorCoorFromRank(int rank, std::vector &c CartesianCommunicator::CartesianCommunicator(const std::vector &processors) { MPI_Comm optimal_comm; - GlobalSharedMemory::OptimalCommunicator (processors,optimal_comm); // Remap using the shared memory optimising routine + //////////////////////////////////////////////////// + // Remap using the shared memory optimising routine + // The remap creates a comm which must be freed + //////////////////////////////////////////////////// + GlobalSharedMemory::OptimalCommunicator (processors,optimal_comm); InitFromMPICommunicator(processors,optimal_comm); SetCommunicator(optimal_comm); + /////////////////////////////////////////////////// // Free the temp communicator + /////////////////////////////////////////////////// MPI_Comm_free(&optimal_comm); } @@ -202,8 +208,10 @@ CartesianCommunicator::CartesianCommunicator(const std::vector &processors, // Take the right SHM buffers ////////////////////////////////////////////////////////////////////////////////////////////////////// SetCommunicator(comm_split); - + + /////////////////////////////////////////////// // Free the temp communicator + /////////////////////////////////////////////// MPI_Comm_free(&comm_split); if(0){ diff --git a/lib/communicator/SharedMemory.h b/lib/communicator/SharedMemory.h index 0f647dc6..9f6b1a25 100644 --- a/lib/communicator/SharedMemory.h +++ b/lib/communicator/SharedMemory.h @@ -133,6 +133,7 @@ class SharedMemory public: SharedMemory() {}; + ~SharedMemory(); /////////////////////////////////////////////////////////////////////////////////////// // set the buffers & sizes /////////////////////////////////////////////////////////////////////////////////////// diff --git a/lib/communicator/SharedMemoryMPI.cc b/lib/communicator/SharedMemoryMPI.cc index 2a62b7ac..9e5d8f15 100644 --- a/lib/communicator/SharedMemoryMPI.cc +++ b/lib/communicator/SharedMemoryMPI.cc @@ -399,5 +399,9 @@ void *SharedMemory::ShmBufferTranslate(int rank,void * local_p) return (void *) remote; } } +SharedMemory::~SharedMemory() +{ + MPI_Comm_free(&ShmComm); +}; } diff --git a/lib/communicator/SharedMemoryNone.cc b/lib/communicator/SharedMemoryNone.cc index 7feed7e4..a23e3c1c 100644 --- a/lib/communicator/SharedMemoryNone.cc +++ b/lib/communicator/SharedMemoryNone.cc @@ -122,5 +122,7 @@ void *SharedMemory::ShmBufferTranslate(int rank,void * local_p) { return NULL; } +SharedMemory::~SharedMemory() +{}; }