From: Timo Heister Date: Mon, 26 Oct 2020 13:27:13 +0000 (-0400) Subject: pass MPI_Comm by const ref X-Git-Tag: v9.3.0-rc1~925^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F11109%2Fhead;p=dealii.git pass MPI_Comm by const ref fixes #11107 --- diff --git a/include/deal.II/base/data_out_base.h b/include/deal.II/base/data_out_base.h index 2549a5df39..bbb6e8827a 100644 --- a/include/deal.II/base/data_out_base.h +++ b/include/deal.II/base/data_out_base.h @@ -2311,7 +2311,7 @@ namespace DataOutBase write_hdf5_parallel(const std::vector> &patches, const DataOutFilter & data_filter, const std::string & filename, - MPI_Comm comm); + const MPI_Comm & comm); /** * Write the data in @p data_filter to HDF5 file(s). If @p write_mesh_file is @@ -2327,7 +2327,7 @@ namespace DataOutBase const bool write_mesh_file, const std::string & mesh_filename, const std::string &solution_filename, - MPI_Comm comm); + const MPI_Comm & comm); /** * DataOutFilter is an intermediate data format that reduces the amount of @@ -2658,7 +2658,8 @@ public: * DataOutInterface::write_vtu(). */ void - write_vtu_in_parallel(const std::string &filename, MPI_Comm comm) const; + write_vtu_in_parallel(const std::string &filename, + const MPI_Comm & comm) const; /** * Some visualization programs, such as ParaView, can read several separate @@ -2793,7 +2794,7 @@ public: create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter, const std::string & h5_filename, const double cur_time, - MPI_Comm comm) const; + const MPI_Comm & comm) const; /** * Create an XDMFEntry based on the data in the data_filter. This assumes @@ -2805,7 +2806,7 @@ public: const std::string & h5_mesh_filename, const std::string & h5_solution_filename, const double cur_time, - MPI_Comm comm) const; + const MPI_Comm & comm) const; /** * Write an XDMF file based on the provided vector of XDMFEntry objects. @@ -2834,7 +2835,7 @@ public: void write_xdmf_file(const std::vector &entries, const std::string & filename, - MPI_Comm comm) const; + const MPI_Comm & comm) const; /** * Write the data in @p data_filter to a single HDF5 file containing both the @@ -2853,7 +2854,7 @@ public: void write_hdf5_parallel(const DataOutBase::DataOutFilter &data_filter, const std::string & filename, - MPI_Comm comm) const; + const MPI_Comm & comm) const; /** * Write the data in data_filter to HDF5 file(s). If write_mesh_file is @@ -2867,7 +2868,7 @@ public: const bool write_mesh_file, const std::string & mesh_filename, const std::string & solution_filename, - MPI_Comm comm) const; + const MPI_Comm & comm) const; /** * DataOutFilter is an intermediate data format that reduces the amount of diff --git a/include/deal.II/base/hdf5.h b/include/deal.II/base/hdf5.h index fe6a76bb65..c24dc47780 100644 --- a/include/deal.II/base/hdf5.h +++ b/include/deal.II/base/hdf5.h @@ -73,7 +73,7 @@ DEAL_II_NAMESPACE_OPEN * MPI support (several processes access the same HDF5 file). * File::File(const std::string &, const FileAccessMode) * opens/creates an HDF5 file for serial operations. - * File::File(const std::string &, const FileAccessMode, const MPI_Comm) + * File::File(const std::string &, const FileAccessMode, const MPI_Comm &) * creates or opens an HDF5 file in parallel using MPI. The HDF5 calls that * modify the structure of the file are always collective, whereas writing * and reading raw data in a dataset can be done independently or collectively. @@ -1090,12 +1090,12 @@ namespace HDF5 */ File(const std::string & name, const FileAccessMode mode, - const MPI_Comm mpi_communicator); + const MPI_Comm & mpi_communicator); private: /** * Delegation internal constructor. - * File(const std::string &, const MPI_Comm, const Mode); + * File(const std::string &, const MPI_Comm &, const Mode); * and * File(const std::string &, const Mode) * should be used to open or create HDF5 files. @@ -1103,7 +1103,7 @@ namespace HDF5 File(const std::string & name, const FileAccessMode mode, const bool mpi, - const MPI_Comm mpi_communicator); + const MPI_Comm & mpi_communicator); }; namespace internal diff --git a/include/deal.II/base/mpi.h b/include/deal.II/base/mpi.h index 19ae43725f..e77e8258e0 100644 --- a/include/deal.II/base/mpi.h +++ b/include/deal.II/base/mpi.h @@ -376,7 +376,7 @@ namespace Utilities * in the communicator. */ void - lock(MPI_Comm comm); + lock(const MPI_Comm &comm); /** * Release the lock. @@ -385,7 +385,7 @@ namespace Utilities * in the communicator. */ void - unlock(MPI_Comm comm); + unlock(const MPI_Comm &comm); private: /** diff --git a/include/deal.II/base/partitioner.h b/include/deal.II/base/partitioner.h index b28f635ff8..33717041e4 100644 --- a/include/deal.II/base/partitioner.h +++ b/include/deal.II/base/partitioner.h @@ -220,7 +220,7 @@ namespace Utilities */ Partitioner(const types::global_dof_index local_size, const types::global_dof_index ghost_size, - const MPI_Comm communicator); + const MPI_Comm & communicator); /** * Constructor with index set arguments. This constructor creates a @@ -231,7 +231,7 @@ namespace Utilities */ Partitioner(const IndexSet &locally_owned_indices, const IndexSet &ghost_indices_in, - const MPI_Comm communicator_in); + const MPI_Comm &communicator_in); /** * Constructor with one index set argument. This constructor creates a @@ -241,7 +241,7 @@ namespace Utilities * constructor with two index sets. */ Partitioner(const IndexSet &locally_owned_indices, - const MPI_Comm communicator_in); + const MPI_Comm &communicator_in); /** * Reinitialize the communication pattern. The first argument diff --git a/include/deal.II/base/process_grid.h b/include/deal.II/base/process_grid.h index 06faf24d2c..b6d0cbf2c5 100644 --- a/include/deal.II/base/process_grid.h +++ b/include/deal.II/base/process_grid.h @@ -71,7 +71,7 @@ namespace Utilities * number of cores * in the @p mpi_communicator. */ - ProcessGrid(MPI_Comm mpi_communicator, + ProcessGrid(const MPI_Comm & mpi_communicator, const unsigned int n_rows, const unsigned int n_columns); @@ -92,7 +92,7 @@ namespace Utilities * and the @p mpi_communicator with 11 cores will result in the $3x3$ * process grid. */ - ProcessGrid(MPI_Comm mpi_communicator, + ProcessGrid(const MPI_Comm & mpi_communicator, const unsigned int n_rows_matrix, const unsigned int n_columns_matrix, const unsigned int row_block_size, @@ -151,7 +151,7 @@ namespace Utilities * A private constructor which takes grid dimensions as an * std::pair. */ - ProcessGrid(MPI_Comm mpi_communicator, + ProcessGrid(const MPI_Comm & mpi_communicator, const std::pair &grid_dimensions); /** diff --git a/include/deal.II/base/timer.h b/include/deal.II/base/timer.h index 2bc08dd750..a59712b220 100644 --- a/include/deal.II/base/timer.h +++ b/include/deal.II/base/timer.h @@ -137,7 +137,7 @@ public: * communicator occurs; the extra cost of the synchronization is not * measured. */ - Timer(MPI_Comm mpi_communicator, const bool sync_lap_times = false); + Timer(const MPI_Comm &mpi_communicator, const bool sync_lap_times = false); /** * Return a reference to the data structure containing basic statistics on @@ -706,7 +706,7 @@ public: * MPI_Barrier call before starting and stopping the timer for * each section. */ - TimerOutput(MPI_Comm mpi_comm, + TimerOutput(const MPI_Comm & mpi_comm, std::ostream & stream, const OutputFrequency output_frequency, const OutputType output_type); @@ -734,7 +734,7 @@ public: * MPI_Barrier call before starting and stopping the timer for * each section.) */ - TimerOutput(MPI_Comm mpi_comm, + TimerOutput(const MPI_Comm & mpi_comm, ConditionalOStream & stream, const OutputFrequency output_frequency, const OutputType output_type); @@ -806,8 +806,8 @@ public: * median is given). */ void - print_wall_time_statistics(const MPI_Comm mpi_comm, - const double print_quantile = 0.) const; + print_wall_time_statistics(const MPI_Comm &mpi_comm, + const double print_quantile = 0.) const; /** * By calling this function, all output can be disabled. This function diff --git a/include/deal.II/distributed/fully_distributed_tria.h b/include/deal.II/distributed/fully_distributed_tria.h index f84adb4754..9faeaaa313 100644 --- a/include/deal.II/distributed/fully_distributed_tria.h +++ b/include/deal.II/distributed/fully_distributed_tria.h @@ -129,7 +129,7 @@ namespace parallel * @param mpi_communicator The MPI communicator to be used for the * triangulation. */ - explicit Triangulation(MPI_Comm mpi_communicator); + explicit Triangulation(const MPI_Comm &mpi_communicator); /** * Destructor. diff --git a/include/deal.II/distributed/grid_refinement.h b/include/deal.II/distributed/grid_refinement.h index 4ff1e2c348..96e73eaff9 100644 --- a/include/deal.II/distributed/grid_refinement.h +++ b/include/deal.II/distributed/grid_refinement.h @@ -47,7 +47,7 @@ namespace internal std::pair compute_global_min_and_max_at_root( const dealii::Vector &criteria, - MPI_Comm mpi_communicator); + const MPI_Comm & mpi_communicator); namespace RefineAndCoarsenFixedNumber { @@ -60,7 +60,7 @@ namespace internal compute_threshold(const dealii::Vector & criteria, const std::pair &global_min_and_max, const types::global_cell_index n_target_cells, - MPI_Comm mpi_communicator); + const MPI_Comm & mpi_communicator); } // namespace RefineAndCoarsenFixedNumber namespace RefineAndCoarsenFixedFraction @@ -76,7 +76,7 @@ namespace internal compute_threshold(const dealii::Vector & criteria, const std::pair &global_min_and_max, const double target_error, - MPI_Comm mpi_communicator); + const MPI_Comm & mpi_communicator); } // namespace RefineAndCoarsenFixedFraction } // namespace GridRefinement } // namespace distributed diff --git a/include/deal.II/distributed/shared_tria.h b/include/deal.II/distributed/shared_tria.h index 25439bb4a4..8cb2bedefd 100644 --- a/include/deal.II/distributed/shared_tria.h +++ b/include/deal.II/distributed/shared_tria.h @@ -235,7 +235,7 @@ namespace parallel * Otherwise all non-locally owned cells are considered ghost. */ Triangulation( - MPI_Comm mpi_communicator, + const MPI_Comm &mpi_communicator, const typename dealii::Triangulation::MeshSmoothing = (dealii::Triangulation::none), const bool allow_artificial_cells = false, diff --git a/include/deal.II/distributed/tria.h b/include/deal.II/distributed/tria.h index 18e42e92ab..ae440e3677 100644 --- a/include/deal.II/distributed/tria.h +++ b/include/deal.II/distributed/tria.h @@ -353,7 +353,7 @@ namespace parallel * triangulation is partitioned. */ explicit Triangulation( - MPI_Comm mpi_communicator, + const MPI_Comm &mpi_communicator, const typename dealii::Triangulation::MeshSmoothing smooth_grid = (dealii::Triangulation::none), const Settings settings = default_setting); @@ -967,7 +967,7 @@ namespace parallel class DataTransfer { public: - DataTransfer(MPI_Comm mpi_communicator); + DataTransfer(const MPI_Comm &mpi_communicator); /** * Prepare data transfer by calling the pack callback functions on each @@ -1247,7 +1247,7 @@ namespace parallel * the triangulation. */ Triangulation( - MPI_Comm mpi_communicator, + const MPI_Comm &mpi_communicator, const typename dealii::Triangulation<1, spacedim>::MeshSmoothing smooth_grid = (dealii::Triangulation<1, spacedim>::none), const Settings settings = default_setting); diff --git a/include/deal.II/distributed/tria_base.h b/include/deal.II/distributed/tria_base.h index a950bbee1d..5c818533dd 100644 --- a/include/deal.II/distributed/tria_base.h +++ b/include/deal.II/distributed/tria_base.h @@ -82,7 +82,7 @@ namespace parallel * Constructor. */ TriangulationBase( - MPI_Comm mpi_communicator, + const MPI_Comm &mpi_communicator, const typename dealii::Triangulation::MeshSmoothing smooth_grid = (dealii::Triangulation::none), const bool check_for_distorted_cells = false); @@ -357,7 +357,7 @@ namespace parallel * Constructor. */ DistributedTriangulationBase( - MPI_Comm mpi_communicator, + const MPI_Comm &mpi_communicator, const typename dealii::Triangulation::MeshSmoothing smooth_grid = (dealii::Triangulation::none), const bool check_for_distorted_cells = false); diff --git a/include/deal.II/dofs/number_cache.h b/include/deal.II/dofs/number_cache.h index d970baa157..59f1839d8f 100644 --- a/include/deal.II/dofs/number_cache.h +++ b/include/deal.II/dofs/number_cache.h @@ -117,7 +117,7 @@ namespace internal */ std::vector get_n_locally_owned_dofs_per_processor( - const MPI_Comm mpi_communicator) const; + const MPI_Comm &mpi_communicator) const; /** * Return a representation of @p locally_owned_dofs_per_processor both @@ -128,7 +128,7 @@ namespace internal */ std::vector get_locally_owned_dofs_per_processor( - const MPI_Comm mpi_communicator) const; + const MPI_Comm &mpi_communicator) const; /** * Total number of dofs, accumulated over all processors that may diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index 2252955399..893827015a 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -2974,7 +2974,7 @@ namespace GridTools std::vector>> exchange_local_bounding_boxes( const std::vector> &local_bboxes, - MPI_Comm mpi_communicator); + const MPI_Comm & mpi_communicator); /** * In this collective operation each process provides a vector @@ -3012,7 +3012,7 @@ namespace GridTools RTree, unsigned int>> build_global_description_tree( const std::vector> &local_description, - MPI_Comm mpi_communicator); + const MPI_Comm & mpi_communicator); /** * Collect for a given triangulation all locally relevant vertices that diff --git a/include/deal.II/grid/tria_description.h b/include/deal.II/grid/tria_description.h index 63bc1b30f7..0c89189522 100644 --- a/include/deal.II/grid/tria_description.h +++ b/include/deal.II/grid/tria_description.h @@ -435,7 +435,7 @@ namespace TriangulationDescription Description create_description_from_triangulation( const dealii::Triangulation &tria, - const MPI_Comm comm, + const MPI_Comm & comm, const TriangulationDescription::Settings settings = TriangulationDescription::Settings::default_setting, const unsigned int my_rank_in = numbers::invalid_unsigned_int); @@ -475,9 +475,9 @@ namespace TriangulationDescription const std::function &)> & serial_grid_generator, const std::function &, - const MPI_Comm, + const MPI_Comm &, const unsigned int)> &serial_grid_partitioner, - const MPI_Comm comm, + const MPI_Comm & comm, const int group_size = 1, const typename Triangulation::MeshSmoothing smoothing = dealii::Triangulation::none, diff --git a/include/deal.II/lac/affine_constraints.h b/include/deal.II/lac/affine_constraints.h index 11c0452448..28b3d427f8 100644 --- a/include/deal.II/lac/affine_constraints.h +++ b/include/deal.II/lac/affine_constraints.h @@ -1650,7 +1650,7 @@ public: bool is_consistent_in_parallel(const std::vector &locally_owned_dofs, const IndexSet & locally_active_dofs, - const MPI_Comm mpi_communicator, + const MPI_Comm & mpi_communicator, const bool verbose = false) const; /** diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index a9f0bfcc1e..8dc3938a11 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -119,7 +119,7 @@ bool AffineConstraints::is_consistent_in_parallel( const std::vector &locally_owned_dofs, const IndexSet & locally_active_dofs, - const MPI_Comm mpi_communicator, + const MPI_Comm & mpi_communicator, const bool verbose) const { // Helper to return a ConstraintLine object that belongs to row @p row. diff --git a/include/deal.II/lac/la_parallel_block_vector.h b/include/deal.II/lac/la_parallel_block_vector.h index 6c826897a1..419614e395 100644 --- a/include/deal.II/lac/la_parallel_block_vector.h +++ b/include/deal.II/lac/la_parallel_block_vector.h @@ -173,13 +173,13 @@ namespace LinearAlgebra */ BlockVector(const std::vector &local_ranges, const std::vector &ghost_indices, - const MPI_Comm communicator); + const MPI_Comm & communicator); /** * Same as above but the ghost indices are assumed to be empty. */ BlockVector(const std::vector &local_ranges, - const MPI_Comm communicator); + const MPI_Comm & communicator); /** * Destructor. diff --git a/include/deal.II/lac/la_parallel_block_vector.templates.h b/include/deal.II/lac/la_parallel_block_vector.templates.h index f2ba4daaa4..f302158c17 100644 --- a/include/deal.II/lac/la_parallel_block_vector.templates.h +++ b/include/deal.II/lac/la_parallel_block_vector.templates.h @@ -60,7 +60,7 @@ namespace LinearAlgebra template BlockVector::BlockVector(const std::vector &local_ranges, const std::vector &ghost_indices, - const MPI_Comm communicator) + const MPI_Comm & communicator) { std::vector sizes(local_ranges.size()); for (unsigned int i = 0; i < local_ranges.size(); ++i) @@ -76,7 +76,7 @@ namespace LinearAlgebra template BlockVector::BlockVector(const std::vector &local_ranges, - const MPI_Comm communicator) + const MPI_Comm & communicator) { std::vector sizes(local_ranges.size()); for (unsigned int i = 0; i < local_ranges.size(); ++i) diff --git a/include/deal.II/lac/la_parallel_vector.h b/include/deal.II/lac/la_parallel_vector.h index 0b97e7e36b..09d25ee218 100644 --- a/include/deal.II/lac/la_parallel_vector.h +++ b/include/deal.II/lac/la_parallel_vector.h @@ -301,12 +301,12 @@ namespace LinearAlgebra */ Vector(const IndexSet &local_range, const IndexSet &ghost_indices, - const MPI_Comm communicator); + const MPI_Comm &communicator); /** * Same constructor as above but without any ghost indices. */ - Vector(const IndexSet &local_range, const MPI_Comm communicator); + Vector(const IndexSet &local_range, const MPI_Comm &communicator); /** * Create the vector based on the parallel partitioning described in @p @@ -363,13 +363,13 @@ namespace LinearAlgebra void reinit(const IndexSet &local_range, const IndexSet &ghost_indices, - const MPI_Comm communicator); + const MPI_Comm &communicator); /** * Same as above, but without ghost entries. */ void - reinit(const IndexSet &local_range, const MPI_Comm communicator); + reinit(const IndexSet &local_range, const MPI_Comm &communicator); /** * Initialize the vector given to the parallel partitioning described in diff --git a/include/deal.II/lac/la_parallel_vector.templates.h b/include/deal.II/lac/la_parallel_vector.templates.h index 24a1864fa7..b484c308f8 100644 --- a/include/deal.II/lac/la_parallel_vector.templates.h +++ b/include/deal.II/lac/la_parallel_vector.templates.h @@ -627,7 +627,7 @@ namespace LinearAlgebra Vector::reinit( const IndexSet &locally_owned_indices, const IndexSet &ghost_indices, - const MPI_Comm communicator) + const MPI_Comm &communicator) { // set up parallel partitioner with index sets and communicator reinit(std::make_shared( @@ -640,7 +640,7 @@ namespace LinearAlgebra void Vector::reinit( const IndexSet &locally_owned_indices, - const MPI_Comm communicator) + const MPI_Comm &communicator) { // set up parallel partitioner with index sets and communicator reinit( @@ -719,7 +719,7 @@ namespace LinearAlgebra template Vector::Vector(const IndexSet &local_range, const IndexSet &ghost_indices, - const MPI_Comm communicator) + const MPI_Comm &communicator) : allocated_size(0) , vector_is_ghosted(false) , comm_sm(MPI_COMM_SELF) @@ -731,7 +731,7 @@ namespace LinearAlgebra template Vector::Vector(const IndexSet &local_range, - const MPI_Comm communicator) + const MPI_Comm &communicator) : allocated_size(0) , vector_is_ghosted(false) , comm_sm(MPI_COMM_SELF) diff --git a/include/deal.II/lac/petsc_precondition.h b/include/deal.II/lac/petsc_precondition.h index 73c44ef5b8..7e46a63658 100644 --- a/include/deal.II/lac/petsc_precondition.h +++ b/include/deal.II/lac/petsc_precondition.h @@ -164,7 +164,7 @@ namespace PETScWrappers * Intended to be used with SLEPc objects. */ PreconditionJacobi( - const MPI_Comm communicator, + const MPI_Comm & communicator, const AdditionalData &additional_data = AdditionalData()); /** @@ -246,7 +246,7 @@ namespace PETScWrappers * Intended to be used with SLEPc objects. */ PreconditionBlockJacobi( - const MPI_Comm communicator, + const MPI_Comm & communicator, const AdditionalData &additional_data = AdditionalData()); @@ -753,7 +753,7 @@ namespace PETScWrappers * Intended to be used with SLEPc objects. */ PreconditionBoomerAMG( - const MPI_Comm communicator, + const MPI_Comm & communicator, const AdditionalData &additional_data = AdditionalData()); diff --git a/include/deal.II/sundials/arkode.h b/include/deal.II/sundials/arkode.h index a2e76105b4..86435ad991 100644 --- a/include/deal.II/sundials/arkode.h +++ b/include/deal.II/sundials/arkode.h @@ -510,7 +510,7 @@ namespace SUNDIALS * @param mpi_comm MPI communicator */ ARKode(const AdditionalData &data = AdditionalData(), - const MPI_Comm mpi_comm = MPI_COMM_WORLD); + const MPI_Comm & mpi_comm = MPI_COMM_WORLD); /** * Destructor. diff --git a/include/deal.II/sundials/ida.h b/include/deal.II/sundials/ida.h index 0a920e06c4..d6cfca4df9 100644 --- a/include/deal.II/sundials/ida.h +++ b/include/deal.II/sundials/ida.h @@ -580,7 +580,7 @@ namespace SUNDIALS * @param mpi_comm MPI communicator */ IDA(const AdditionalData &data = AdditionalData(), - const MPI_Comm mpi_comm = MPI_COMM_WORLD); + const MPI_Comm & mpi_comm = MPI_COMM_WORLD); /** * Destructor. diff --git a/include/deal.II/sundials/kinsol.h b/include/deal.II/sundials/kinsol.h index 1fa4fb885d..88793da27a 100644 --- a/include/deal.II/sundials/kinsol.h +++ b/include/deal.II/sundials/kinsol.h @@ -454,7 +454,7 @@ namespace SUNDIALS * @param mpi_comm MPI communicator */ KINSOL(const AdditionalData &data = AdditionalData(), - const MPI_Comm mpi_comm = MPI_COMM_WORLD); + const MPI_Comm & mpi_comm = MPI_COMM_WORLD); /** * Destructor. diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index a3979ee16c..0d91d13b26 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -7120,7 +7120,7 @@ template void DataOutInterface::write_vtu_in_parallel( const std::string &filename, - MPI_Comm comm) const + const MPI_Comm & comm) const { #ifndef DEAL_II_WITH_MPI // without MPI fall back to the normal way to write a vtu file: @@ -7333,7 +7333,7 @@ DataOutInterface::create_xdmf_entry( const DataOutBase::DataOutFilter &data_filter, const std::string & h5_filename, const double cur_time, - MPI_Comm comm) const + const MPI_Comm & comm) const { return create_xdmf_entry( data_filter, h5_filename, h5_filename, cur_time, comm); @@ -7348,7 +7348,7 @@ DataOutInterface::create_xdmf_entry( const std::string & h5_mesh_filename, const std::string & h5_solution_filename, const double cur_time, - MPI_Comm comm) const + const MPI_Comm & comm) const { unsigned int local_node_cell_count[2], global_node_cell_count[2]; @@ -7419,7 +7419,7 @@ void DataOutInterface::write_xdmf_file( const std::vector &entries, const std::string & filename, - MPI_Comm comm) const + const MPI_Comm & comm) const { #ifdef DEAL_II_WITH_MPI const int myrank = Utilities::MPI::this_mpi_process(comm); @@ -7597,7 +7597,7 @@ void DataOutInterface::write_hdf5_parallel( const DataOutBase::DataOutFilter &data_filter, const std::string & filename, - MPI_Comm comm) const + const MPI_Comm & comm) const { DataOutBase::write_hdf5_parallel(get_patches(), data_filter, filename, comm); } @@ -7611,7 +7611,7 @@ DataOutInterface::write_hdf5_parallel( const bool write_mesh_file, const std::string & mesh_filename, const std::string & solution_filename, - MPI_Comm comm) const + const MPI_Comm & comm) const { DataOutBase::write_hdf5_parallel(get_patches(), data_filter, @@ -7629,7 +7629,7 @@ DataOutBase::write_hdf5_parallel( const std::vector> &patches, const DataOutBase::DataOutFilter & data_filter, const std::string & filename, - MPI_Comm comm) + const MPI_Comm & comm) { write_hdf5_parallel(patches, data_filter, true, filename, filename, comm); } @@ -7644,7 +7644,7 @@ DataOutBase::write_hdf5_parallel( const bool write_mesh_file, const std::string & mesh_filename, const std::string & solution_filename, - MPI_Comm comm) + const MPI_Comm & comm) { AssertThrow( spacedim >= 2, diff --git a/source/base/data_out_base.inst.in b/source/base/data_out_base.inst.in index 99ee9f5c4e..9218d409d1 100644 --- a/source/base/data_out_base.inst.in +++ b/source/base/data_out_base.inst.in @@ -209,7 +209,7 @@ for (deal_II_dimension : OUTPUT_DIMENSIONS; & patches, const DataOutFilter &data_filter, const std::string & filename, - MPI_Comm comm); + const MPI_Comm & comm); template void write_filtered_data( diff --git a/source/base/hdf5.cc b/source/base/hdf5.cc index ae14b47241..2575786a81 100644 --- a/source/base/hdf5.cc +++ b/source/base/hdf5.cc @@ -354,7 +354,7 @@ namespace HDF5 File::File(const std::string & name, const FileAccessMode mode, - const MPI_Comm mpi_communicator) + const MPI_Comm & mpi_communicator) : File(name, mode, true, mpi_communicator) {} @@ -363,7 +363,7 @@ namespace HDF5 File::File(const std::string & name, const FileAccessMode mode, const bool mpi, - const MPI_Comm mpi_communicator) + const MPI_Comm & mpi_communicator) : Group(name, mpi) { hdf5_reference = std::shared_ptr(new hid_t, [](hid_t *pointer) { diff --git a/source/base/mpi.cc b/source/base/mpi.cc index 269aea2e59..68b3347526 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -1101,7 +1101,7 @@ namespace Utilities void - CollectiveMutex::lock(MPI_Comm comm) + CollectiveMutex::lock(const MPI_Comm &comm) { (void)comm; @@ -1135,7 +1135,7 @@ namespace Utilities void - CollectiveMutex::unlock(MPI_Comm comm) + CollectiveMutex::unlock(const MPI_Comm &comm) { (void)comm; diff --git a/source/base/partitioner.cc b/source/base/partitioner.cc index aec6633bf7..b0eee440d6 100644 --- a/source/base/partitioner.cc +++ b/source/base/partitioner.cc @@ -60,7 +60,7 @@ namespace Utilities Partitioner::Partitioner(const types::global_dof_index local_size, const types::global_dof_index ghost_size, - const MPI_Comm communicator) + const MPI_Comm & communicator) : global_size(Utilities::MPI::sum(local_size, communicator)) , locally_owned_range_data(global_size) @@ -94,7 +94,7 @@ namespace Utilities Partitioner::Partitioner(const IndexSet &locally_owned_indices, const IndexSet &ghost_indices_in, - const MPI_Comm communicator_in) + const MPI_Comm &communicator_in) : global_size( static_cast(locally_owned_indices.size())) , n_ghost_indices_data(0) @@ -112,7 +112,7 @@ namespace Utilities Partitioner::Partitioner(const IndexSet &locally_owned_indices, - const MPI_Comm communicator_in) + const MPI_Comm &communicator_in) : global_size( static_cast(locally_owned_indices.size())) , n_ghost_indices_data(0) diff --git a/source/base/process_grid.cc b/source/base/process_grid.cc index 3772704ad0..bf9502a2a5 100644 --- a/source/base/process_grid.cc +++ b/source/base/process_grid.cc @@ -34,7 +34,7 @@ namespace * https://github.com/elemental/Elemental/blob/master/src/core/Grid.cpp#L67-L91 */ inline std::pair - compute_processor_grid_sizes(MPI_Comm mpi_comm, + compute_processor_grid_sizes(const MPI_Comm & mpi_comm, const unsigned int m, const unsigned int n, const unsigned int block_size_m, @@ -101,7 +101,7 @@ namespace Utilities namespace MPI { ProcessGrid::ProcessGrid( - MPI_Comm mpi_comm, + const MPI_Comm & mpi_comm, const std::pair &grid_dimensions) : mpi_communicator(mpi_comm) , this_mpi_process(Utilities::MPI::this_mpi_process(mpi_communicator)) @@ -206,7 +206,7 @@ namespace Utilities - ProcessGrid::ProcessGrid(MPI_Comm mpi_comm, + ProcessGrid::ProcessGrid(const MPI_Comm & mpi_comm, const unsigned int n_rows_matrix, const unsigned int n_columns_matrix, const unsigned int row_block_size, @@ -221,7 +221,7 @@ namespace Utilities - ProcessGrid::ProcessGrid(MPI_Comm mpi_comm, + ProcessGrid::ProcessGrid(const MPI_Comm & mpi_comm, const unsigned int n_rows, const unsigned int n_columns) : ProcessGrid(mpi_comm, std::make_pair(n_rows, n_columns)) diff --git a/source/base/timer.cc b/source/base/timer.cc index 8f1a875945..2f7e84ce86 100644 --- a/source/base/timer.cc +++ b/source/base/timer.cc @@ -162,7 +162,7 @@ Timer::Timer() -Timer::Timer(MPI_Comm mpi_communicator, const bool sync_lap_times_) +Timer::Timer(const MPI_Comm &mpi_communicator, const bool sync_lap_times_) : running(false) , mpi_communicator(mpi_communicator) , sync_lap_times(sync_lap_times_) @@ -322,7 +322,7 @@ TimerOutput::TimerOutput(ConditionalOStream & stream, -TimerOutput::TimerOutput(MPI_Comm mpi_communicator, +TimerOutput::TimerOutput(const MPI_Comm & mpi_communicator, std::ostream & stream, const OutputFrequency output_frequency, const OutputType output_type) @@ -335,7 +335,7 @@ TimerOutput::TimerOutput(MPI_Comm mpi_communicator, -TimerOutput::TimerOutput(MPI_Comm mpi_communicator, +TimerOutput::TimerOutput(const MPI_Comm & mpi_communicator, ConditionalOStream & stream, const OutputFrequency output_frequency, const OutputType output_type) @@ -841,8 +841,8 @@ TimerOutput::print_summary() const void -TimerOutput::print_wall_time_statistics(const MPI_Comm mpi_comm, - const double quantile) const +TimerOutput::print_wall_time_statistics(const MPI_Comm &mpi_comm, + const double quantile) const { // we are going to change the precision and width of output below. store the // old values so the get restored when exiting this function diff --git a/source/distributed/fully_distributed_tria.cc b/source/distributed/fully_distributed_tria.cc index 80c59ecd30..6bee001262 100644 --- a/source/distributed/fully_distributed_tria.cc +++ b/source/distributed/fully_distributed_tria.cc @@ -41,7 +41,8 @@ namespace parallel namespace fullydistributed { template - Triangulation::Triangulation(MPI_Comm mpi_communicator) + Triangulation::Triangulation( + const MPI_Comm &mpi_communicator) : parallel::DistributedTriangulationBase(mpi_communicator) , settings(TriangulationDescription::Settings::default_setting) , partitioner([](dealii::Triangulation &tria, diff --git a/source/distributed/grid_refinement.cc b/source/distributed/grid_refinement.cc index b3042b6c07..c0355617ad 100644 --- a/source/distributed/grid_refinement.cc +++ b/source/distributed/grid_refinement.cc @@ -71,7 +71,7 @@ namespace template double compute_global_sum(const dealii::Vector &criteria, - MPI_Comm mpi_communicator) + const MPI_Comm & mpi_communicator) { double my_sum = std::accumulate(criteria.begin(), @@ -263,7 +263,7 @@ namespace internal std::pair compute_global_min_and_max_at_root( const dealii::Vector &criteria, - MPI_Comm mpi_communicator) + const MPI_Comm & mpi_communicator) { // we'd like to compute the global max and min from the local ones in // one MPI communication. we can do that by taking the elementwise @@ -296,7 +296,7 @@ namespace internal compute_threshold(const dealii::Vector & criteria, const std::pair &global_min_and_max, const types::global_cell_index n_target_cells, - MPI_Comm mpi_communicator) + const MPI_Comm & mpi_communicator) { double interesting_range[2] = {global_min_and_max.first, global_min_and_max.second}; @@ -379,7 +379,7 @@ namespace internal compute_threshold(const dealii::Vector & criteria, const std::pair &global_min_and_max, const double target_error, - MPI_Comm mpi_communicator) + const MPI_Comm & mpi_communicator) { double interesting_range[2] = {global_min_and_max.first, global_min_and_max.second}; diff --git a/source/distributed/grid_refinement.inst.in b/source/distributed/grid_refinement.inst.in index c653059f77..1f5372af68 100644 --- a/source/distributed/grid_refinement.inst.in +++ b/source/distributed/grid_refinement.inst.in @@ -27,7 +27,7 @@ for (S : REAL_SCALARS) \{ template std::pair compute_global_min_and_max_at_root(const dealii::Vector &, - MPI_Comm); + const MPI_Comm &); namespace RefineAndCoarsenFixedNumber \{ @@ -35,7 +35,7 @@ for (S : REAL_SCALARS) compute_threshold(const dealii::Vector &, const std::pair &, const types::global_cell_index, - MPI_Comm); + const MPI_Comm &); \} namespace RefineAndCoarsenFixedFraction \{ @@ -43,7 +43,7 @@ for (S : REAL_SCALARS) compute_threshold(const dealii::Vector &, const std::pair &, const double, - MPI_Comm); + const MPI_Comm &); \} \} \} diff --git a/source/distributed/shared_tria.cc b/source/distributed/shared_tria.cc index 636f09f175..69a90bfe3e 100644 --- a/source/distributed/shared_tria.cc +++ b/source/distributed/shared_tria.cc @@ -37,7 +37,7 @@ namespace parallel { template Triangulation::Triangulation( - MPI_Comm mpi_communicator, + const MPI_Comm &mpi_communicator, const typename dealii::Triangulation::MeshSmoothing smooth_grid, const bool allow_artificial_cells, diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index 40c3148bce..383bab745a 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -1123,7 +1123,7 @@ namespace parallel template Triangulation::DataTransfer::DataTransfer( - MPI_Comm mpi_communicator) + const MPI_Comm &mpi_communicator) : mpi_communicator(mpi_communicator) , variable_size_data_stored(false) {} @@ -2110,7 +2110,7 @@ namespace parallel template Triangulation::Triangulation( - MPI_Comm mpi_communicator, + const MPI_Comm &mpi_communicator, const typename dealii::Triangulation::MeshSmoothing smooth_grid, const Settings settings) @@ -4967,7 +4967,7 @@ namespace parallel template Triangulation<1, spacedim>::Triangulation( - MPI_Comm mpi_communicator, + const MPI_Comm &mpi_communicator, const typename dealii::Triangulation<1, spacedim>::MeshSmoothing smooth_grid, const Settings /*settings*/) diff --git a/source/distributed/tria_base.cc b/source/distributed/tria_base.cc index c6fde425b5..e22a435e63 100644 --- a/source/distributed/tria_base.cc +++ b/source/distributed/tria_base.cc @@ -41,7 +41,7 @@ namespace parallel { template TriangulationBase::TriangulationBase( - MPI_Comm mpi_communicator, + const MPI_Comm &mpi_communicator, const typename dealii::Triangulation::MeshSmoothing smooth_grid, const bool check_for_distorted_cells) @@ -344,7 +344,7 @@ namespace parallel template DistributedTriangulationBase::DistributedTriangulationBase( - MPI_Comm mpi_communicator, + const MPI_Comm &mpi_communicator, const typename dealii::Triangulation::MeshSmoothing smooth_grid, const bool check_for_distorted_cells) diff --git a/source/dofs/number_cache.cc b/source/dofs/number_cache.cc index a677741df6..a99613c6b7 100644 --- a/source/dofs/number_cache.cc +++ b/source/dofs/number_cache.cc @@ -85,7 +85,7 @@ namespace internal std::vector NumberCache::get_n_locally_owned_dofs_per_processor( - const MPI_Comm mpi_communicator) const + const MPI_Comm &mpi_communicator) const { if (n_global_dofs == 0) return std::vector(); @@ -108,7 +108,7 @@ namespace internal std::vector NumberCache::get_locally_owned_dofs_per_processor( - const MPI_Comm mpi_communicator) const + const MPI_Comm &mpi_communicator) const { AssertDimension(locally_owned_dofs.size(), n_global_dofs); if (n_global_dofs == 0) diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index a1162a3fd7..f97d2eba4b 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -5382,7 +5382,7 @@ namespace GridTools std::vector>> exchange_local_bounding_boxes( const std::vector> &local_bboxes, - MPI_Comm mpi_communicator) + const MPI_Comm & mpi_communicator) { #ifndef DEAL_II_WITH_MPI (void)local_bboxes; @@ -5478,7 +5478,7 @@ namespace GridTools RTree, unsigned int>> build_global_description_tree( const std::vector> &local_description, - MPI_Comm mpi_communicator) + const MPI_Comm & mpi_communicator) { #ifndef DEAL_II_WITH_MPI (void)mpi_communicator; diff --git a/source/grid/grid_tools.inst.in b/source/grid/grid_tools.inst.in index d2e0e811cf..701a0444f6 100644 --- a/source/grid/grid_tools.inst.in +++ b/source/grid/grid_tools.inst.in @@ -157,7 +157,8 @@ for (deal_II_space_dimension : SPACE_DIMENSIONS) template std::vector>> GridTools::exchange_local_bounding_boxes( - const std::vector> &, MPI_Comm); + const std::vector> &, + const MPI_Comm &); template std::tuple>, std::map, @@ -177,7 +178,8 @@ for (deal_II_space_dimension : SPACE_DIMENSIONS) template RTree< std::pair, unsigned int>> GridTools::build_global_description_tree( - const std::vector> &, MPI_Comm); + const std::vector> &, + const MPI_Comm &); template Vector GridTools::compute_aspect_ratio_of_cells( const Mapping &, diff --git a/source/grid/tria_description.cc b/source/grid/tria_description.cc index 7dd871a6c5..e9aa760f8b 100644 --- a/source/grid/tria_description.cc +++ b/source/grid/tria_description.cc @@ -100,7 +100,7 @@ namespace TriangulationDescription Description create_description_from_triangulation( const dealii::Triangulation &tria, - const MPI_Comm comm, + const MPI_Comm & comm, const TriangulationDescription::Settings settings, const unsigned int my_rank_in) { @@ -405,7 +405,7 @@ namespace TriangulationDescription const std::function &, const MPI_Comm, const unsigned int)> &serial_grid_partitioner, - const MPI_Comm comm, + const MPI_Comm & comm, const int group_size, const typename Triangulation::MeshSmoothing smoothing, const TriangulationDescription::Settings settings) diff --git a/source/grid/tria_description.inst.in b/source/grid/tria_description.inst.in index 1bc17dcf55..29af0fa264 100644 --- a/source/grid/tria_description.inst.in +++ b/source/grid/tria_description.inst.in @@ -26,7 +26,7 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) create_description_from_triangulation( const dealii::Triangulation &tria, - const MPI_Comm comm, + const MPI_Comm & comm, const TriangulationDescription::Settings settings, const unsigned int my_rank_in); @@ -39,7 +39,7 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) dealii::Triangulation &, const MPI_Comm, const unsigned int)> &serial_grid_partitioner, - const MPI_Comm comm, + const MPI_Comm & comm, const int group_size, const typename Triangulation::MeshSmoothing diff --git a/source/lac/petsc_precondition.cc b/source/lac/petsc_precondition.cc index 68c207353e..de93af0f36 100644 --- a/source/lac/petsc_precondition.cc +++ b/source/lac/petsc_precondition.cc @@ -123,7 +123,7 @@ namespace PETScWrappers /* ----------------- PreconditionJacobi -------------------- */ - PreconditionJacobi::PreconditionJacobi(const MPI_Comm comm, + PreconditionJacobi::PreconditionJacobi(const MPI_Comm & comm, const AdditionalData &additional_data_) { additional_data = additional_data_; @@ -173,7 +173,7 @@ namespace PETScWrappers /* ----------------- PreconditionBlockJacobi -------------------- */ PreconditionBlockJacobi::PreconditionBlockJacobi( - const MPI_Comm comm, + const MPI_Comm & comm, const AdditionalData &additional_data_) { additional_data = additional_data_; @@ -450,7 +450,7 @@ namespace PETScWrappers PreconditionBoomerAMG::PreconditionBoomerAMG( - const MPI_Comm comm, + const MPI_Comm & comm, const AdditionalData &additional_data_) { additional_data = additional_data_; diff --git a/source/multigrid/mg_level_global_transfer.cc b/source/multigrid/mg_level_global_transfer.cc index 8dd388dc8e..51ffc58d02 100644 --- a/source/multigrid/mg_level_global_transfer.cc +++ b/source/multigrid/mg_level_global_transfer.cc @@ -165,7 +165,7 @@ namespace const MGConstrainedDoFs, MGLevelGlobalTransfer>> mg_constrained_dofs, - const MPI_Comm mpi_communicator, + const MPI_Comm & mpi_communicator, const bool transfer_solution_vectors, std::vector> & copy_indices, std::vector> & copy_indices_global_mine, diff --git a/source/sundials/arkode.cc b/source/sundials/arkode.cc index 64be7b34b2..b0dd8c672d 100644 --- a/source/sundials/arkode.cc +++ b/source/sundials/arkode.cc @@ -238,7 +238,7 @@ namespace SUNDIALS template ARKode::ARKode(const AdditionalData &data, - const MPI_Comm mpi_comm) + const MPI_Comm & mpi_comm) : data(data) , arkode_mem(nullptr) , yy(nullptr) diff --git a/source/sundials/ida.cc b/source/sundials/ida.cc index ef5397a9df..2e8454aebd 100644 --- a/source/sundials/ida.cc +++ b/source/sundials/ida.cc @@ -153,7 +153,7 @@ namespace SUNDIALS } // namespace template - IDA::IDA(const AdditionalData &data, const MPI_Comm mpi_comm) + IDA::IDA(const AdditionalData &data, const MPI_Comm &mpi_comm) : data(data) , ida_mem(nullptr) , yy(nullptr) diff --git a/source/sundials/kinsol.cc b/source/sundials/kinsol.cc index c463bdea41..ed2f26844b 100644 --- a/source/sundials/kinsol.cc +++ b/source/sundials/kinsol.cc @@ -151,7 +151,7 @@ namespace SUNDIALS template KINSOL::KINSOL(const AdditionalData &data, - const MPI_Comm mpi_comm) + const MPI_Comm & mpi_comm) : data(data) , kinsol_mem(nullptr) , solution(nullptr)