From 224db799c3d9b6b36fcbebaa12e178b58d90f308 Mon Sep 17 00:00:00 2001 From: David Wells Date: Fri, 18 Feb 2022 10:58:26 -0500 Subject: [PATCH] Move some inline function definitions down. --- .../base/mpi_compute_index_owner_internal.h | 76 +++++++++++-------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/include/deal.II/base/mpi_compute_index_owner_internal.h b/include/deal.II/base/mpi_compute_index_owner_internal.h index 21eebfcfe7..2ae145bb36 100644 --- a/include/deal.II/base/mpi_compute_index_owner_internal.h +++ b/include/deal.II/base/mpi_compute_index_owner_internal.h @@ -204,26 +204,14 @@ namespace Utilities * ensure a balance over the MPI ranks due to the grain size. */ unsigned int - dof_to_dict_rank(const types::global_dof_index i) - { - // note: this formula is also explicitly used in - // get_index_offset(), so keep the two in sync - return (i / dofs_per_process) * stride_small_size; - } + dof_to_dict_rank(const types::global_dof_index i); /** * Given an MPI rank id of an arbitrary processor, return the index * offset where the local range of that processor begins. */ types::global_dof_index - get_index_offset(const unsigned int rank) - { - return std::min(dofs_per_process * - static_cast( - (rank + stride_small_size - 1) / - stride_small_size), - size); - } + get_index_offset(const unsigned int rank); /** * Given the rank in the owned indices from `actually_owning_ranks`, @@ -232,22 +220,7 @@ namespace Utilities */ unsigned int get_owning_rank_index(const unsigned int rank_in_owned_indices, - const unsigned int guess = 0) - { - AssertIndexRange(guess, actually_owning_rank_list.size()); - if (actually_owning_rank_list[guess] == rank_in_owned_indices) - return guess; - else - { - auto it = std::lower_bound(actually_owning_rank_list.begin(), - actually_owning_rank_list.end(), - rank_in_owned_indices); - Assert(it != actually_owning_rank_list.end(), - ExcInternalError()); - Assert(*it == rank_in_owned_indices, ExcInternalError()); - return it - actually_owning_rank_list.begin(); - } - } + const unsigned int guess = 0); private: /** @@ -425,6 +398,49 @@ namespace Utilities const unsigned int rank_of_request); }; + /* ------------------------- inline functions ----------------------- */ + + inline unsigned int + Dictionary::dof_to_dict_rank(const types::global_dof_index i) + { + // note: this formula is also explicitly used in + // get_index_offset(), so keep the two in sync + return (i / dofs_per_process) * stride_small_size; + } + + + inline types::global_dof_index + Dictionary::get_index_offset(const unsigned int rank) + { + return std::min(dofs_per_process * + static_cast( + (rank + stride_small_size - 1) / + stride_small_size), + size); + } + + + + inline unsigned int + Dictionary::get_owning_rank_index( + const unsigned int rank_in_owned_indices, + const unsigned int guess) + { + AssertIndexRange(guess, actually_owning_rank_list.size()); + if (actually_owning_rank_list[guess] == rank_in_owned_indices) + return guess; + else + { + auto it = std::lower_bound(actually_owning_rank_list.begin(), + actually_owning_rank_list.end(), + rank_in_owned_indices); + Assert(it != actually_owning_rank_list.end(), ExcInternalError()); + Assert(*it == rank_in_owned_indices, ExcInternalError()); + return it - actually_owning_rank_list.begin(); + } + } + + } // namespace ComputeIndexOwner } // namespace internal } // namespace MPI -- 2.39.5