1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-13 04:37:05 +01:00

Solving a memory leak in Communicator_mpi

This commit is contained in:
Guido Cossu
2017-09-18 14:39:04 +01:00
parent b542d349b8
commit 999c623590
5 changed files with 135 additions and 99 deletions

View File

@ -152,6 +152,7 @@ class CartesianCommunicator {
// Constructor of any given grid
////////////////////////////////////////////////
CartesianCommunicator(const std::vector<int> &pdimensions_in);
virtual ~CartesianCommunicator();
////////////////////////////////////////////////////////////////////////////////////////
// Wraps MPI_Cart routines, or implements equivalent on other impls

View File

@ -75,6 +75,13 @@ CartesianCommunicator::CartesianCommunicator(const std::vector<int> &processors)
assert(Size==_Nprocessors);
}
CartesianCommunicator::~CartesianCommunicator(){
if (communicator && !MPI::Is_finalized())
MPI_Comm_free(&communicator);
}
void CartesianCommunicator::GlobalSum(uint32_t &u){
int ierr=MPI_Allreduce(MPI_IN_PLACE,&u,1,MPI_UINT32_T,MPI_SUM,communicator);
assert(ierr==0);