]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a few missing memory consumption calls/implementations.
authorDavid Wells <drwells@email.unc.edu>
Mon, 19 Dec 2022 17:41:19 +0000 (12:41 -0500)
committerDavid Wells <drwells@email.unc.edu>
Mon, 19 Dec 2022 22:08:13 +0000 (17:08 -0500)
include/deal.II/grid/grid_tools.h
include/deal.II/grid/reference_cell.h
source/base/partitioner.cc
source/grid/tria.cc
source/grid/tria_faces.cc
source/grid/tria_levels.cc

index 76acfd009f8c8247d3c7f21a2cc1ad5e12e7c73c..b5344d499fa041b97ca97ababbe126bdb40fea83 100644 (file)
@@ -2778,6 +2778,12 @@ namespace GridTools
      * @ref GlossPeriodicConstraints "glossary entry on periodic conditions".
      */
     FullMatrix<double> matrix;
+
+    /**
+     * Return an estimate, in bytes, for the memory consumption of the object.
+     */
+    std::size_t
+    memory_consumption() const;
   };
 
 
@@ -3848,6 +3854,15 @@ namespace GridTools
 
 
 
+  template <typename CellIterator>
+  std::size_t
+  PeriodicFacePair<CellIterator>::memory_consumption() const
+  {
+    return sizeof(*this) + matrix.memory_consumption();
+  }
+
+
+
   namespace internal
   {
     namespace ProjectToObject
index 0866e39ab8f5a905bee1aaa12366c97ed542ac8c..1d764eec3d9e2b343a2d6d5d7dc0d1328a72c3b5 100644 (file)
@@ -680,6 +680,12 @@ public:
   void
   serialize(Archive &archive, const unsigned int /*version*/);
 
+  /**
+   * Return the number of bytes used by an instance of this class.
+   */
+  static constexpr std::size_t
+  memory_consumption();
+
   /**
    * @}
    */
@@ -850,6 +856,14 @@ ReferenceCell::serialize(Archive &archive, const unsigned int /*version*/)
 
 
 
+inline constexpr std::size_t
+ReferenceCell::memory_consumption()
+{
+  return sizeof(ReferenceCells::Invalid);
+}
+
+
+
 inline ArrayView<const unsigned int>
 ReferenceCell::faces_for_given_vertex(const unsigned int vertex) const
 {
index 89ef30f6e5f437ce6fe5b18ed485d535ae684268..693042d549a90d47cc50fed5d852bb6a608f0ed0 100644 (file)
@@ -510,19 +510,30 @@ namespace Utilities
     std::size_t
     Partitioner::memory_consumption() const
     {
-      std::size_t memory = (3 * sizeof(types::global_dof_index) +
-                            4 * sizeof(unsigned int) + sizeof(MPI_Comm));
-      memory += MemoryConsumption::memory_consumption(locally_owned_range_data);
+      std::size_t memory = MemoryConsumption::memory_consumption(global_size);
+      memory += locally_owned_range_data.memory_consumption();
+      memory += MemoryConsumption::memory_consumption(local_range_data);
+      memory += ghost_indices_data.memory_consumption();
+      memory += sizeof(n_ghost_indices_data);
       memory += MemoryConsumption::memory_consumption(ghost_targets_data);
-      memory += MemoryConsumption::memory_consumption(import_targets_data);
       memory += MemoryConsumption::memory_consumption(import_indices_data);
+      memory += sizeof(import_indices_plain_dev) +
+                sizeof(*import_indices_plain_dev.begin()) *
+                  import_indices_plain_dev.capacity();
+      memory += MemoryConsumption::memory_consumption(n_import_indices_data);
+      memory += MemoryConsumption::memory_consumption(import_targets_data);
       memory += MemoryConsumption::memory_consumption(
         import_indices_chunks_by_rank_data);
+      memory +=
+        MemoryConsumption::memory_consumption(n_ghost_indices_in_larger_set);
       memory += MemoryConsumption::memory_consumption(
         ghost_indices_subset_chunks_by_rank_data);
       memory +=
         MemoryConsumption::memory_consumption(ghost_indices_subset_data);
-      memory += MemoryConsumption::memory_consumption(ghost_indices_data);
+      memory += MemoryConsumption::memory_consumption(my_pid);
+      memory += MemoryConsumption::memory_consumption(n_procs);
+      memory += MemoryConsumption::memory_consumption(communicator);
+      memory += MemoryConsumption::memory_consumption(have_ghost_indices);
       return memory;
     }
 
index 87f10c5d230a78445cc3492a5f629f3d6c42fea4..11a3e08b06bd5b48e8990426c36090192b508d7c 100644 (file)
@@ -58,11 +58,21 @@ namespace internal
     std::size_t
     NumberCache<1>::memory_consumption() const
     {
-      return (MemoryConsumption::memory_consumption(n_levels) +
-              MemoryConsumption::memory_consumption(n_lines) +
-              MemoryConsumption::memory_consumption(n_lines_level) +
-              MemoryConsumption::memory_consumption(n_active_lines) +
-              MemoryConsumption::memory_consumption(n_active_lines_level));
+      std::size_t mem =
+        MemoryConsumption::memory_consumption(n_levels) +
+        MemoryConsumption::memory_consumption(n_lines) +
+        MemoryConsumption::memory_consumption(n_lines_level) +
+        MemoryConsumption::memory_consumption(n_active_lines) +
+        MemoryConsumption::memory_consumption(n_active_lines_level);
+
+      if (active_cell_index_partitioner)
+        mem += active_cell_index_partitioner->memory_consumption();
+
+      for (const auto &partitioner : level_cell_index_partitioners)
+        if (partitioner)
+          mem += partitioner->memory_consumption();
+
+      return mem;
     }
 
 
@@ -16386,6 +16396,9 @@ std::size_t
 Triangulation<dim, spacedim>::memory_consumption() const
 {
   std::size_t mem = 0;
+  mem += sizeof(MeshSmoothing);
+  mem += MemoryConsumption::memory_consumption(reference_cells);
+  mem += MemoryConsumption::memory_consumption(periodic_face_pairs_level_0);
   mem += MemoryConsumption::memory_consumption(levels);
   for (const auto &level : levels)
     mem += MemoryConsumption::memory_consumption(*level);
index f0e079a321a1044adcf42bcdbe9597b3002aece9..a747850864a6b92d703a763e5c0d0f57617d7c8a 100644 (file)
@@ -38,6 +38,8 @@ namespace internal
         return MemoryConsumption::memory_consumption(lines);
       if (dim == 3)
         return (MemoryConsumption::memory_consumption(quads) +
+                MemoryConsumption::memory_consumption(quads_line_orientations) +
+                MemoryConsumption::memory_consumption(quad_reference_cell) +
                 MemoryConsumption::memory_consumption(lines));
 
       return 0;
index 4ca5a4180a592ed785a0568f9843dea1f7bf3bd0..3d16d31345bebd9dc7ef979483dbc9f50fedc397 100644 (file)
@@ -27,15 +27,21 @@ namespace internal
     std::size_t
     TriaLevel::memory_consumption() const
     {
-      return (MemoryConsumption::memory_consumption(refine_flags) +
-              MemoryConsumption::memory_consumption(coarsen_flags) +
-              MemoryConsumption::memory_consumption(active_cell_indices) +
-              MemoryConsumption::memory_consumption(neighbors) +
-              MemoryConsumption::memory_consumption(subdomain_ids) +
-              MemoryConsumption::memory_consumption(level_subdomain_ids) +
-              MemoryConsumption::memory_consumption(parents) +
-              MemoryConsumption::memory_consumption(direction_flags) +
-              MemoryConsumption::memory_consumption(cells));
+      return (
+        MemoryConsumption::memory_consumption(refine_flags) +
+        MemoryConsumption::memory_consumption(coarsen_flags) +
+        MemoryConsumption::memory_consumption(active_cell_indices) +
+        MemoryConsumption::memory_consumption(global_active_cell_indices) +
+        MemoryConsumption::memory_consumption(global_level_cell_indices) +
+        MemoryConsumption::memory_consumption(neighbors) +
+        MemoryConsumption::memory_consumption(subdomain_ids) +
+        MemoryConsumption::memory_consumption(level_subdomain_ids) +
+        MemoryConsumption::memory_consumption(parents) +
+        MemoryConsumption::memory_consumption(direction_flags) +
+        MemoryConsumption::memory_consumption(cells) +
+        MemoryConsumption::memory_consumption(face_orientations) +
+        MemoryConsumption::memory_consumption(reference_cell) +
+        MemoryConsumption::memory_consumption(cell_vertex_indices_cache));
     }
   } // namespace TriangulationImplementation
 } // namespace internal

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.