Skip to content
Snippets Groups Projects

added maximum based tensor method

1 file
+ 13
9
Compare changes
  • Side-by-side
  • Inline
+ 13
9
@@ -78,7 +78,7 @@ public:
@@ -78,7 +78,7 @@ public:
/// method to execute a load-balancing step
/// method to execute a load-balancing step
/// @param[in] step number of the load-balancing step
/// @param[in] step number of the load-balancing step
virtual void balance(int step) override;
virtual void balance(int step) override {balance(step, MPI_SUM);}
// getter for variables (passed by reference to avoid
// getter for variables (passed by reference to avoid
// direct access to private members of the object)
// direct access to private members of the object)
@@ -92,6 +92,9 @@ public:
@@ -92,6 +92,9 @@ public:
/// @param[in] data pointer to the data structure
/// @param[in] data pointer to the data structure
virtual void setAdditionalData(known_unused const void *data) override {}
virtual void setAdditionalData(known_unused const void *data) override {}
 
/// method to execute a load-balancing step
 
/// @param[in] step number of the load-balancing step
 
virtual void balance(int step, MPI_Op reductionMode);
private:
private:
// type for MPI communication
// type for MPI communication
MPI_Datatype MPIDataTypeT;
MPI_Datatype MPIDataTypeT;
@@ -104,9 +107,10 @@ private:
@@ -104,9 +107,10 @@ private:
// list of neighbors
// list of neighbors
std::vector<int> neighbors;
std::vector<int> neighbors;
std::vector<int> nNeighbors;
std::vector<int> nNeighbors;
 
 
protected:
 
// used MPI reduction method
const MPI_Op reductionMode = MPI_SUM;
};
};
// setup routine for the tensor-based load-balancing scheme
// setup routine for the tensor-based load-balancing scheme
@@ -176,17 +180,20 @@ template <class T, class W> void Tensor_LB<T, W>::setup() {
@@ -176,17 +180,20 @@ template <class T, class W> void Tensor_LB<T, W>::setup() {
}
}
}
}
template <class T, class W> void Tensor_LB<T, W>::balance(int) {
template <class T, class W> void Tensor_LB<T, W>::balance(int step, MPI_Op reductionMode) {
int dim = this->getDimension();
int dim = this->getDimension();
std::vector<Point<T>> newVertices = this->vertices;
std::vector<Point<T>> newVertices = this->vertices;
this->prevVertices = this->vertices;
this->prevVertices = this->vertices;
 
bool localIsSum = reductionMode == MPI_SUM;
 
bool localIsMax = reductionMode == MPI_MAX;
 
// loop over all available dimensions
// loop over all available dimensions
for (int i = 0; i < dim; ++i) {
for (int i = 0; i < dim; ++i) {
W work_local_plane;
W work_local_plane;
// collect work from all processes in the same plane
// collect work from all processes in the same plane
MPI_Allreduce(this->getWork().data(), &work_local_plane, 1, MPIDataTypeW,
MPI_Allreduce(this->getWork().data(), &work_local_plane, 1, MPIDataTypeW,
this->reductionMode, communicators.at(i));
reductionMode, communicators.at(i));
// correct right border:
// correct right border:
@@ -277,10 +284,7 @@ template <class T, class W> class TensorMax_LB : public Tensor_LB<T, W> {
@@ -277,10 +284,7 @@ template <class T, class W> class TensorMax_LB : public Tensor_LB<T, W> {
public:
public:
TensorMax_LB() {}
TensorMax_LB() {}
TensorMax_LB(int d, W w, T g) : Tensor_LB<T, W>(d, w, g) {}
TensorMax_LB(int d, W w, T g) : Tensor_LB<T, W>(d, w, g) {}
virtual void balance(int step) override {Tensor_LB<T,W>::balance(step, MPI_MAX);}
private:
// used MPI reduction method
const MPI_Op reductionMode = MPI_MAX;
};
};
} // namespace ALL
} // namespace ALL
Loading