5#include "parallel/KDDecomposition.h"
7#include "parallel/MPIKDNode.h"
40 _child1(nullptr),
_child2(nullptr), _load(0.0), _optimalLoadPerProcess(0.0),
51 _load(other._load), _optimalLoadPerProcess(other._optimalLoadPerProcess),
55 for (
int dim = 0; dim < KDDIM; dim++) {
62 KDNode(
int numP,
const int low[KDDIM],
const int high[KDDIM],
int id,
int owner,
bool coversAll[KDDIM],
int level)
64 _child1(nullptr),
_child2(nullptr), _load(0.0), _optimalLoadPerProcess(0.0),
67 for (
int dim = 0; dim < KDDIM; dim++) {
110 double calculateAvgLoadPerProc()
const {
119 double meanProcessorSpeed[] = { 1., 1. };
120 double totalMeanProcessorSpeed = 1.;
121 if (accumulatedProcessorSpeeds and not accumulatedProcessorSpeeds->empty()) {
126 size_t numProcs = accumulatedProcessorSpeeds->size() - 1;
127 totalMeanProcessorSpeed = (*accumulatedProcessorSpeeds)[numProcs] / numProcs;
129 double child1Dev =
_child1->calculateAvgLoadPerProc()
130 - _optimalLoadPerProcess * meanProcessorSpeed[0] / totalMeanProcessorSpeed;
131 child1Dev = child1Dev * child1Dev;
132 double child2Dev =
_child2->calculateAvgLoadPerProc()
133 - _optimalLoadPerProcess * meanProcessorSpeed[1] / totalMeanProcessorSpeed;
134 child2Dev = child2Dev * child2Dev;
138 void calculateDeviation(std::vector<double>* processorSpeeds =
nullptr,
const double &totalMeanProcessorSpeed = 1.) {
141 if (processorSpeeds !=
nullptr && processorSpeeds->size() > (
unsigned int)
_owningProc) {
145 double dev = _load - _optimalLoadPerProcess * speed / totalMeanProcessorSpeed;
159 void getOwningProcs(
const int low[KDDIM],
const int high[KDDIM], std::vector<int>& procIDs, std::vector<int>& neighbHaloAreas)
const;
173 void split(
int divDimension,
int splitIndex,
int numProcsLeft);
197 void plotNode(
const std::string& vtkFile,
const std::vector<double>* processorSpeeds=
nullptr)
const;
210 MPIKDNode::shutdownDatatype();
238 double _optimalLoadPerProcess;
represents a node in the decomposition tree when using KDDecomposition
Definition: KDNode.h:28
double _deviation
Definition: KDNode.h:247
bool equals(KDNode &other)
Definition: KDNode.cpp:34
int _owningProc
process which owns this KDNode (only possible for leaf nodes)
Definition: KDNode.h:230
MPIKDNodePacked MPIKDNode
Definition: KDNode.h:37
int _lowCorner[3]
in cells relative to global domain
Definition: KDNode.h:221
KDNode * _child1
"left" child of this KDNode (only used if the child is no leaf)
Definition: KDNode.h:233
void plotNode(const std::string &vtkFile, const std::vector< double > *processorSpeeds=nullptr) const
Definition: KDNode.cpp:281
double _deviationLowerBound
Definition: KDNode.h:243
void getOwningProcs(const int low[KDDIM], const int high[KDDIM], std::vector< int > &procIDs, std::vector< int > &neighbHaloAreas) const
Definition: KDNode.cpp:321
void serialize(const std::string &fileName)
Definition: KDNode.cpp:206
int _nodeID
ID of this KDNode.
Definition: KDNode.h:228
KDNode * _child2
"left" child of this KDNode (only used if the child is no leaf)
Definition: KDNode.h:235
void deserialize(const std::string &fileName)
Definition: KDNode.cpp:243
bool isResolvable()
Definition: KDNode.cpp:142
void calculateDeviationLowerBound(std::vector< double > *accumulatedProcessorSpeeds=nullptr)
Definition: KDNode.h:118
void split(int divDimension, int splitIndex, int numProcsLeft)
Definition: KDNode.cpp:160
int _highCorner[3]
in cells relative to global domain
Definition: KDNode.h:223
KDNode(const KDNode &other)
Definition: KDNode.h:49
~KDNode()
The destructor deletes the childs (recursive call of destructors)
Definition: KDNode.h:80
int _numProcs
number of procs which share this area
Definition: KDNode.h:219
KDNode * findAreaForProcess(int rank)
Definition: KDNode.cpp:18
static void initMPIDataType()
Definition: KDNode.h:202
int _level
level of this node (at root node, level = 0)
Definition: KDNode.h:250
MPIKDNode getMPIKDNode()
Definition: KDNode.cpp:118
void buildKDTree()
create an initial decomposition of the domain represented by this node.
Definition: KDNode.cpp:68
bool _coversWholeDomain[KDDIM]
true if the domain in the given dimension is not divided into more than one process
Definition: KDNode.h:225
static void shutdownMPIDataType()
Definition: KDNode.h:209
void printTree(const std::string &prefix, std::ostream &ostream)
prints this (sub-) tree to stdout
Definition: KDNode.cpp:91
unsigned int getNumMaxProcs()
Definition: KDNode.cpp:151
Definition: MPIKDNode.h:19
static void initDatatype()
Definition: MPIKDNode.cpp:305
Definition: VTKGridWriterImplementation.h:23
::xsd::cxx::tree::id< char, ncname > id
C++ type corresponding to the ID XML Schema built-in type.
Definition: vtk-punstructured.h:322
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
Definition: vtk-punstructured.h:270