Memory Consumption of Primitives
Apparently, the memory footprint of our datastructures is much higher than the contained information would suggest. Consider the following example:
...
uint_t N=200;
auto meshInfo = MeshInfo::meshRectangle( 0, 1, MeshInfo::CRISS, N, N );
SetupPrimitiveStorage setupStorage( meshInfo, uint_c( walberla::mpi::MPIManager::instance()->numProcesses() ) );
printCurrentMemoryUsage();
std::stringstream ss;
setupStorage.toStream( ss, false );
WALBERLA_LOG_INFO_ON_ROOT( ss.str() );
Runnig this code in serial yields the following output:
...
+--------------+--------------+--------------+
| sum | min | max |
----------------------+--------------+--------------+--------------+
allocated memory (GB) | 0.257 | 0.257 | 0.257 |
----------------------+--------------+--------------+--------------+
...
Number of...
Vertices: 40401 | 800/40401 on boundary
Edges: 120400 | 800/120400 on boundary
Faces: 80000 | 0/80000 on boundary
Cells: 0 | 0/0 on boundary
By hand, I get to the following theoretical memory consumpiton:
- Each
Primitive
holds 4vector
s, 1map
, 1PrimitiveID
and 1meshBoundaryFlag
-> ca. 8*8B For the individual primitiveTypes the following stuff comes in addition to that: - Each
Vertex
holds 1DoFType
and 1Point3D
and has 6neighborEdges
and 6neighborFaces
-> + ca. 16*8B - Each
Edge
holds 5Point3D
and 1real_t
and has 2neighborVertices
and 2neighborFaces
-> + ca. 20*8B - Each
Face
holds 3Point3D
, 1real_t
3int
and has 3neighborVertices
, 3neighborEdges
and 12indirectNeighborFaces
-> + ca. 28 * 8B + 3 * 4B
In total this yields 59MB, more than a factor of 4 less than the actual memory consumption.
In 3D, it is even more extreme!
I also want to emphasise that even if we would achieve this theoretical memory, there is still tons of redundant information, e.g. each primitive holds all of its vertex coordinates although they could also be accessed via its veritces...