Skip to content
Snippets Groups Projects
Commit 1c137425 authored by David Immel's avatar David Immel
Browse files

bugfix for freeing MPI communicators every balance

parent 3918dbd4
Branches
Tags
No related merge requests found
......@@ -70,13 +70,22 @@ public:
// array of MPI communicators for each direction (to collect work
// on each plane)
communicators.resize(2 * this->dimension);
communicators.resize(6);
for (int i=0; i<6; i++) communicators.at(i) = MPI_COMM_NULL;
nNeighbors.resize(2 * this->dimension);
nBins.resize(this->dimension);
}
/// default destructor
~Histogram_LB() = default;
~Histogram_LB() {
for (int i=0; i<communicators.size(); i++) {
if (communicators.at(i) != MPI_COMM_NULL &&
communicators.at(i) != MPI_COMM_SELF &&
communicators.at(i) != MPI_COMM_WORLD)
MPI_Comm_free(&(communicators.at(i)));
}
}
/// method to setup the loac-balancing method
void setup() override;
......@@ -156,6 +165,14 @@ template <class T, class W> void Histogram_LB<T, W>::setup() {
// get the local rank from the MPI communicator
MPI_Cart_rank(this->globalComm, this->local_coords.data(), &this->localRank);
// free sub-communicators
for (int i=0; i<6; i++) {
if (communicators.at(i) != MPI_COMM_SELF &&
communicators.at(i) != MPI_COMM_WORLD &&
communicators.at(i) != MPI_COMM_NULL)
MPI_Comm_free(&(communicators.at(i)));
}
// create sub-communicators
// communicators 0 - 2: reduction of partial histograms
......@@ -358,14 +375,6 @@ template <class T, class W> void Histogram_LB<T, W>::balance(int step) {
<< std::endl;
find_neighbors();
MPI_Barrier(this->globalComm);
// free created communicators
for (int i = 0; i < 6; ++i) {
if (communicators.at(i) != MPI_COMM_SELF &&
communicators.at(i) != MPI_COMM_WORLD)
MPI_Comm_free(&(communicators.at(i)));
}
}
template <class T, class W> void Histogram_LB<T, W>::find_neighbors() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment