From 3877e07be52c2c53fe7d35d11b386e2b350e2ed8 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Tue, 16 Feb 2021 20:53:45 +0100 Subject: [PATCH] Add NoncontiguousPartitioner::temporary_storage_size --- .../base/mpi_noncontiguous_partitioner.h | 20 ++++++++++++------- .../mpi_noncontiguous_partitioner.templates.h | 12 +++++++++-- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/deal.II/base/mpi_noncontiguous_partitioner.h b/include/deal.II/base/mpi_noncontiguous_partitioner.h index de17fc2d77..deb0432970 100644 --- a/include/deal.II/base/mpi_noncontiguous_partitioner.h +++ b/include/deal.II/base/mpi_noncontiguous_partitioner.h @@ -99,10 +99,8 @@ namespace Utilities * used. * * @pre The size of the @p temporary_storage vector has to be at least - * as large as the sum of the number of entries in the index sets - * passed to the constructor and the reinit() functions. The reason - * for this is that this vector is used as buffer for both sending - * and receiving data. + * temporary_storage_size. The reason for this is that this vector is + * used as buffer for both sending and receiving data. */ template void @@ -124,7 +122,7 @@ namespace Utilities * allows for padding and other post-processing of the received data. * * @pre The required size of the vectors are the same as in the functions - * above. + * above. */ template void @@ -146,7 +144,7 @@ namespace Utilities * destination vector. * * @pre The required size of the vectors are the same as in the functions - * above. + * above. */ template void @@ -160,7 +158,15 @@ namespace Utilities * number of processes this process receives data from. */ std::pair - n_targets(); + n_targets() const; + + /** + * Return the size of the temporary storage needed by the + * export_to_ghosted_array() functions, if the temporary storage is + * handled by the user code. + */ + unsigned int + temporary_storage_size() const; /** * Return memory consumption in Byte. diff --git a/include/deal.II/base/mpi_noncontiguous_partitioner.templates.h b/include/deal.II/base/mpi_noncontiguous_partitioner.templates.h index 0b0426e526..958d45f968 100644 --- a/include/deal.II/base/mpi_noncontiguous_partitioner.templates.h +++ b/include/deal.II/base/mpi_noncontiguous_partitioner.templates.h @@ -54,13 +54,21 @@ namespace Utilities std::pair - NoncontiguousPartitioner::n_targets() + NoncontiguousPartitioner::n_targets() const { return {send_ranks.size(), recv_ranks.size()}; } + unsigned int + NoncontiguousPartitioner::temporary_storage_size() const + { + return send_ptr.back(); + } + + + types::global_dof_index NoncontiguousPartitioner::memory_consumption() { @@ -252,7 +260,7 @@ namespace Utilities requests.resize(send_ranks.size() + recv_ranks.size()); if (this->buffers.size() != send_ptr.back() * sizeof(Number)) - this->buffers.resize(send_ptr.back() * sizeof(Number), 0); + this->buffers.resize(this->temporary_storage_size() * sizeof(Number)); // perform actual exchange this->template export_to_ghosted_array( -- 2.39.5