From f3a79387688ab8ec3dea661dfd5d2fcf1dda57ba Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Mon, 13 Apr 2020 22:48:28 +0200 Subject: [PATCH] Add mermory_consumption --- include/deal.II/lac/la_sm_partitioner.h | 3 ++ source/lac/la_sm_partitioner.cc | 60 ++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/include/deal.II/lac/la_sm_partitioner.h b/include/deal.II/lac/la_sm_partitioner.h index b8243e1445..c5ba5165de 100644 --- a/include/deal.II/lac/la_sm_partitioner.h +++ b/include/deal.II/lac/la_sm_partitioner.h @@ -101,6 +101,9 @@ namespace LinearAlgebra std::size_t n_mpi_processes() const; + std::size_t + memory_consumption() const; + private: const MPI_Comm &comm; const MPI_Comm &comm_sm; diff --git a/source/lac/la_sm_partitioner.cc b/source/lac/la_sm_partitioner.cc index 61c4018922..b4ed9ec4a5 100644 --- a/source/lac/la_sm_partitioner.cc +++ b/source/lac/la_sm_partitioner.cc @@ -34,6 +34,14 @@ namespace LinearAlgebra std::vector recv_indices; std::vector recv_len; + // for(auto i : recv_sm_ptr) + // std::cout << i << " "; + // std::cout << std::endl; + // + // for(auto i : recv_sm_indices) + // std::cout << i << " "; + // std::cout << std::endl; + for (unsigned int i = 0; i + 1 < recv_sm_ptr.size(); i++) { if (recv_sm_ptr[i] != recv_sm_ptr[i + 1]) @@ -56,9 +64,24 @@ namespace LinearAlgebra recv_ptr.push_back(recv_indices.size()); } - recv_sm_ptr = recv_ptr; + recv_sm_ptr = recv_ptr; + recv_sm_ptr.shrink_to_fit(); recv_sm_indices = recv_indices; - recv_sm_len = recv_len; + recv_sm_indices.shrink_to_fit(); + recv_sm_len = recv_len; + recv_sm_len.shrink_to_fit(); + + // for(auto i : recv_sm_ptr) + // std::cout << i << " "; + // std::cout << std::endl; + // + // for(auto i : recv_sm_indices) + // std::cout << i << " "; + // std::cout << std::endl; + // + // for(auto i : recv_sm_len) + // std::cout << i << " "; + // std::cout << std::endl; } } // namespace internal @@ -260,6 +283,10 @@ namespace LinearAlgebra MPI_STATUSES_IGNORE); } + const auto a = + Utilities::MPI::sum(static_cast(this->memory_consumption()), + this->comm); + #if DO_COMPRESS internal::compress(recv_sm_ptr, recv_sm_indices, recv_sm_len); #endif @@ -283,6 +310,12 @@ namespace LinearAlgebra #if DO_COMPRESS internal::compress(send_sm_ptr, send_sm_indices, send_sm_len); #endif + + const auto b = + Utilities::MPI::sum(static_cast(this->memory_consumption()), + this->comm); + + std::cout << "memory_consumption " << a << " " << b << std::endl; } template @@ -551,6 +584,29 @@ namespace LinearAlgebra return n_mpi_processes_; } + std::size_t + Partitioner::memory_consumption() const + { + return 0 // + + MemoryConsumption::memory_consumption(recv_remote_ranks) // + + MemoryConsumption::memory_consumption(recv_remote_ptr) // + + MemoryConsumption::memory_consumption(recv_sm_ranks) // + + MemoryConsumption::memory_consumption(recv_sm_ptr) // + + MemoryConsumption::memory_consumption(recv_sm_indices) // + + MemoryConsumption::memory_consumption(recv_sm_len) // + + MemoryConsumption::memory_consumption(recv_sm_offset) // + + MemoryConsumption::memory_consumption(send_remote_ptr) // + + MemoryConsumption::memory_consumption(send_remote_indices) // + + MemoryConsumption::memory_consumption(send_remote_len) // + + MemoryConsumption::memory_consumption(send_remote_offset) // + + MemoryConsumption::memory_consumption(send_sm_ranks) // + + MemoryConsumption::memory_consumption(send_sm_ptr) // + + MemoryConsumption::memory_consumption(send_sm_indices) // + + MemoryConsumption::memory_consumption(send_sm_len) // + + MemoryConsumption::memory_consumption(send_sm_offset) // + ; + } + } // end of namespace SharedMPI } // end of namespace LinearAlgebra -- 2.39.5