From: David Wells Date: Mon, 19 Dec 2022 17:41:19 +0000 (-0500) Subject: Add a few missing memory consumption calls/implementations. X-Git-Tag: v9.5.0-rc1~718^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bad743621c2a51513e77b1e5923b30573dc0606c;p=dealii.git Add a few missing memory consumption calls/implementations. --- diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index 76acfd009f..b5344d499f 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -2778,6 +2778,12 @@ namespace GridTools * @ref GlossPeriodicConstraints "glossary entry on periodic conditions". */ FullMatrix 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 + std::size_t + PeriodicFacePair::memory_consumption() const + { + return sizeof(*this) + matrix.memory_consumption(); + } + + + namespace internal { namespace ProjectToObject diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 0866e39ab8..1d764eec3d 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -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 ReferenceCell::faces_for_given_vertex(const unsigned int vertex) const { diff --git a/source/base/partitioner.cc b/source/base/partitioner.cc index 89ef30f6e5..693042d549 100644 --- a/source/base/partitioner.cc +++ b/source/base/partitioner.cc @@ -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; } diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 87f10c5d23..11a3e08b06 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -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::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); diff --git a/source/grid/tria_faces.cc b/source/grid/tria_faces.cc index f0e079a321..a747850864 100644 --- a/source/grid/tria_faces.cc +++ b/source/grid/tria_faces.cc @@ -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; diff --git a/source/grid/tria_levels.cc b/source/grid/tria_levels.cc index 4ca5a4180a..3d16d31345 100644 --- a/source/grid/tria_levels.cc +++ b/source/grid/tria_levels.cc @@ -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