Commit 4a950584 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Added some first memory usage output test.

parent 5a71c46a
......@@ -1048,4 +1048,85 @@ namespace AMDiS {
}
}
unsigned long ElementObjectDatabase::calculateMemoryUsage()
{
const unsigned int structElObjDataSize = sizeof(ElementObjectData);
const unsigned int dofSize = sizeof(DegreeOfFreedom);
const unsigned int edgeSize = sizeof(DofEdge);
const unsigned int faceSize = sizeof(DofFace);
const unsigned int vectorOverhead = sizeof(vector<int>);
const unsigned int mapOverhead = 48; //sizeof(_Rb_tree<int, int>);
const unsigned int mapEntryOverhead = 40; // sizeof(_Rb_tree_node_base);
unsigned long value = 0;
// vertexElements
value += mapOverhead + vertexElements.size() * mapEntryOverhead;
for (map<DegreeOfFreedom, vector<ElementObjectData> >::iterator mapIt =
vertexElements.begin(); mapIt != vertexElements.end(); ++mapIt)
value += dofSize + vectorOverhead + mapIt->second.size() * structElObjDataSize;
// edgeElements
value += mapOverhead + edgeElements.size() * mapEntryOverhead;
for (map<DofEdge, vector<ElementObjectData> >::iterator mapIt =
edgeElements.begin(); mapIt != edgeElements.end(); ++mapIt)
value += dofSize + vectorOverhead + mapIt->second.size() * structElObjDataSize;
// faceElements
value += mapOverhead + faceElements.size() * mapEntryOverhead;
for (map<DofFace, vector<ElementObjectData> >::iterator mapIt =
faceElements.begin(); mapIt != faceElements.end(); ++mapIt)
value += dofSize + vectorOverhead + mapIt->second.size() * structElObjDataSize;
// vertexLocalMap
value += mapOverhead + vertexLocalMap.size() * (mapEntryOverhead + structElObjDataSize + dofSize);
// edgeLocalMap
value += mapOverhead + edgeLocalMap.size() * (mapEntryOverhead + structElObjDataSize + edgeSize);
// faceLocalMap
value += mapOverhead + faceLocalMap.size() * (mapEntryOverhead + structElObjDataSize + faceSize);
// vertexInRank
value += mapOverhead + vertexInRank.size() * mapEntryOverhead;
for (map<DegreeOfFreedom, map<int, ElementObjectData> >::iterator mapIt =
vertexInRank.begin(); mapIt != vertexInRank.end(); ++mapIt)
value += dofSize + mapOverhead +
mapIt->second.size() * (mapEntryOverhead + sizeof(int) + structElObjDataSize);
// edgeInRank
value += mapOverhead + edgeInRank.size() * mapEntryOverhead;
for (map<DofEdge, map<int, ElementObjectData> >::iterator mapIt =
edgeInRank.begin(); mapIt != edgeInRank.end(); ++mapIt)
value += edgeSize + mapOverhead +
mapIt->second.size() * (mapEntryOverhead + sizeof(int) + structElObjDataSize);
// faceInRank
value += mapOverhead + faceInRank.size() * mapEntryOverhead;
for (map<DofFace, map<int, ElementObjectData> >::iterator mapIt =
faceInRank.begin(); mapIt != faceInRank.end(); ++mapIt)
value += faceSize + mapOverhead +
mapIt->second.size() * (mapEntryOverhead + sizeof(int) + structElObjDataSize);
if (bConnMap.size() || periodicVertices.size() || periodicDofAssoc.size()) {
ERROR_EXIT("Not yet implemented for periodic meshes!\n");
}
// edgeReverseMode
value += mapOverhead + edgeReverseMode.size() * (mapEntryOverhead + 2 * structElObjDataSize + sizeof(bool));
// faceReverseMode
value += mapOverhead + faceReverseMode.size() * (mapEntryOverhead + 2 * structElObjDataSize + sizeof(bool));
// macroElIndexMap
value += mapOverhead + macroElIndexMap.size() * (mapEntryOverhead + sizeof(int) + sizeof(int*));
// macroElIndexTypeMap
value += mapOverhead + macroElIndexTypeMap.size() * (mapEntryOverhead + sizeof(int) + sizeof(int*));
return value;
}
}
......@@ -130,11 +130,9 @@ namespace AMDiS {
void createMacroElementInfo(vector<MacroElement*> &mel);
/** \brief
* Create for a filled object database the membership information for all
* element objects. An object is owned by a rank, if the rank has the
* heighest rank number of all ranks where the object is part of.
*/
/// Create for a filled object database the membership information for all
/// element objects. An object is owned by a rank, if the rank has the
/// heighest rank number of all ranks where the object is part of.
void updateRankData();
/** \brief
......@@ -428,6 +426,9 @@ namespace AMDiS {
/// Read the element database from disk.
void deserialize(istream &in);
/// Returns the estimated memory usage of an object of this class.
unsigned long calculateMemoryUsage();
protected:
/** \brief
* Adds an element to the object database. If the element is part of a
......
......@@ -20,7 +20,7 @@ namespace AMDiS {
ParallelCoarseSpaceMatVec::ParallelCoarseSpaceMatVec()
: interiorMap(NULL),
lastMeshNnz(0),
lastMeshNnz(-1),
alwaysCreateNnzStructure(false),
meshDistributor(NULL),
subdomainLevel(0),
......
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