Commit 66434cfd authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Small feature updates.

parent d850f7ad
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace AMDiS { namespace AMDiS {
void CheckerPartitioner::createInitialPartitioning() bool CheckerPartitioner::createInitialPartitioning()
{ {
FUNCNAME("CheckerPartitioner::createInitialPartitioning()"); FUNCNAME("CheckerPartitioner::createInitialPartitioning()");
...@@ -127,6 +127,8 @@ namespace AMDiS { ...@@ -127,6 +127,8 @@ namespace AMDiS {
elInfo = stack.traverseNext(elInfo); elInfo = stack.traverseNext(elInfo);
} }
return true;
} }
} }
...@@ -62,7 +62,7 @@ namespace AMDiS { ...@@ -62,7 +62,7 @@ namespace AMDiS {
~CheckerPartitioner() {} ~CheckerPartitioner() {}
void createInitialPartitioning(); bool createInitialPartitioning();
/// \ref MeshPartitioner::partition /// \ref MeshPartitioner::partition
bool partition(map<int, double> &elemWeights, PartitionMode mode = INITIAL) bool partition(map<int, double> &elemWeights, PartitionMode mode = INITIAL)
......
...@@ -357,14 +357,12 @@ namespace AMDiS { ...@@ -357,14 +357,12 @@ namespace AMDiS {
createMacroElementInfo(); createMacroElementInfo();
// create an initial partitioning of the mesh // create an initial partitioning of the mesh
partitioner->createInitialPartitioning(); bool useInitialPartitioning = partitioner->createInitialPartitioning();
// set the element weights, which are 1 at the very first begin // set the element weights, which are 1 at the very first begin
setInitialElementWeights(); setInitialElementWeights();
string filename = ""; if (!useInitialPartitioning) {
Parameters::get("parallel->partitioner->read meta arh", filename);
if (filename == "" || ArhReader::readMetaData(filename) != mpiSize) {
// and now partition the mesh // and now partition the mesh
bool partitioningSucceed = partitioner->partition(elemWeights, INITIAL); bool partitioningSucceed = partitioner->partition(elemWeights, INITIAL);
TEST_EXIT(partitioningSucceed)("Initial partitioning does not work!\n"); TEST_EXIT(partitioningSucceed)("Initial partitioning does not work!\n");
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
namespace AMDiS { namespace AMDiS {
void MeshPartitioner::createInitialPartitioning() bool MeshPartitioner::createInitialPartitioning()
{ {
FUNCNAME("MeshPartitioner::createInitialPartitioning()"); FUNCNAME("MeshPartitioner::createInitialPartitioning()");
...@@ -26,7 +26,7 @@ namespace AMDiS { ...@@ -26,7 +26,7 @@ namespace AMDiS {
int mpiSize = mpiComm->Get_size(); int mpiSize = mpiComm->Get_size();
int nLeaves = mesh->getNumberOfLeaves(); int nLeaves = mesh->getNumberOfLeaves();
int elPerRank = nLeaves / mpiSize; int elPerRank = nLeaves / mpiSize;
bool useInitialPartitioning = false;
// === Check for reading ARH meta file to create initial partitioning. === // === Check for reading ARH meta file to create initial partitioning. ===
...@@ -35,14 +35,23 @@ namespace AMDiS { ...@@ -35,14 +35,23 @@ namespace AMDiS {
string partitioningFile = ""; string partitioningFile = "";
Parameters::get("parallel->initial partitioning file", partitioningFile); Parameters::get("parallel->initial partitioning file", partitioningFile);
if (partitioningFile != "") { if (partitioningFile != "") {
MSG("Read initial partitioning file: %s\n", partitioningFile.c_str());
ifstream file; ifstream file;
file.open(partitioningFile.c_str()); file.open(partitioningFile.c_str());
TEST_EXIT(file.is_open())("Should not happen!\n");
int nElements = 0; int nElements = 0;
file >> nElements; file >> nElements;
for (int i = 0; i < nElements; i++) for (int i = 0; i < nElements; i++) {
file >> mapElInRank[i]; int rank = -1;
file >> rank;
mapElInRank[i] = rank;
}
file.close(); file.close();
useInitialPartitioning = true;
} else { } else {
string arhMetaFile = ""; string arhMetaFile = "";
Parameters::get("parallel->partitioner->read meta arh", arhMetaFile); Parameters::get("parallel->partitioner->read meta arh", arhMetaFile);
...@@ -51,6 +60,8 @@ namespace AMDiS { ...@@ -51,6 +60,8 @@ namespace AMDiS {
int nProc = ArhReader::readMetaData(arhMetaFile, mapElInRank, arhElCodeSize); int nProc = ArhReader::readMetaData(arhMetaFile, mapElInRank, arhElCodeSize);
if (nProc != mpiSize) if (nProc != mpiSize)
partitioningArhBased = false; partitioningArhBased = false;
else
useInitialPartitioning = true;
} }
} }
...@@ -157,6 +168,8 @@ namespace AMDiS { ...@@ -157,6 +168,8 @@ namespace AMDiS {
} }
} }
} }
return useInitialPartitioning;
} }
......
...@@ -62,10 +62,16 @@ namespace AMDiS { ...@@ -62,10 +62,16 @@ namespace AMDiS {
virtual ~MeshPartitioner() {} virtual ~MeshPartitioner() {}
/// Creates an initial paritioning of the AMDiS mesh. This partitioning /** \brief
/// can be arbitrary, the only requirement is that each macro element * Creates an initial paritioning of the AMDiS mesh. This partitioning
/// must be uniquely assign to a rank. * can be arbitrary, the only requirement is that each macro element
virtual void createInitialPartitioning(); * must be uniquely assign to a rank.
*
* \return If the function returns true, the initial partitioning should
* be used for the very first computations. This can be e.g. due
* to the usage of an initial partitioning file.
*/
virtual bool createInitialPartitioning();
/** \brief /** \brief
* Function the takes a weighted set of macro elements and returns a * Function the takes a weighted set of macro elements and returns a
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment