From: Wolfgang Bangerth Date: Fri, 21 Jan 2022 21:37:22 +0000 (-0700) Subject: Use MPI::Utilities::free_communicator() where possible. X-Git-Tag: v9.4.0-rc1~576^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13280%2Fhead;p=dealii.git Use MPI::Utilities::free_communicator() where possible. --- diff --git a/include/deal.II/base/aligned_vector.h b/include/deal.II/base/aligned_vector.h index ff3dffbbd6..b9718a503b 100644 --- a/include/deal.II/base/aligned_vector.h +++ b/include/deal.II/base/aligned_vector.h @@ -1141,8 +1141,7 @@ AlignedVector::Deleter::MPISharedMemDeleterAction::delete_array( ierr = MPI_Win_free(&shmem_window); AssertThrowMPI(ierr); - ierr = MPI_Comm_free(&shmem_group_communicator); - AssertThrowMPI(ierr); + Utilities::MPI::free_communicator(shmem_group_communicator); } # endif @@ -1558,8 +1557,7 @@ AlignedVector::replicate_across_communicator(const MPI_Comm & communicator, ExcInternalError()); // And get rid of the temporary communicator - ierr = MPI_Comm_free(&shmem_group_communicator_temp); - AssertThrowMPI(ierr); + Utilities::MPI::free_communicator(shmem_group_communicator_temp); } const bool is_shmem_root = Utilities::MPI::this_mpi_process(shmem_group_communicator) == 0; @@ -1665,10 +1663,7 @@ AlignedVector::replicate_across_communicator(const MPI_Comm & communicator, } // We no longer need the shmem roots communicator, so get rid of it - { - const int ierr = MPI_Comm_free(&shmem_roots_communicator); - AssertThrowMPI(ierr); - } + Utilities::MPI::free_communicator(shmem_group_communicator); // **** Step 3 **** diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index 5b229d85a5..92490893f7 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -7841,8 +7841,7 @@ DataOutInterface::write_vtu_with_pvtu_record( int ierr = MPI_Comm_split(mpi_communicator, color, rank, &comm_group); AssertThrowMPI(ierr); this->write_vtu_in_parallel(filename.c_str(), comm_group); - ierr = MPI_Comm_free(&comm_group); - AssertThrowMPI(ierr); + Utilities::MPI::free_communicator(comm_group); #else AssertThrow(false, ExcMessage("Logical error. Should not arrive here.")); #endif diff --git a/source/base/mpi.cc b/source/base/mpi.cc index 6d04a9b395..15f101bad7 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -246,10 +246,8 @@ namespace Utilities } if (*new_comm != comm_old) { - ierr = MPI_Comm_free(&ic); - AssertThrowMPI(ierr); - ierr = MPI_Comm_free(&comm_old); - AssertThrowMPI(ierr); + Utilities::MPI::free_communicator(ic); + Utilities::MPI::free_communicator(comm_old); } } diff --git a/source/base/process_grid.cc b/source/base/process_grid.cc index 5c1541f9e2..18b7905bbc 100644 --- a/source/base/process_grid.cc +++ b/source/base/process_grid.cc @@ -235,7 +235,7 @@ namespace Utilities Cblacs_gridexit(blacs_context); if (mpi_communicator_inactive_with_root != MPI_COMM_NULL) - MPI_Comm_free(&mpi_communicator_inactive_with_root); + Utilities::MPI::free_communicator(mpi_communicator_inactive_with_root); } diff --git a/source/base/utilities.cc b/source/base/utilities.cc index 88ca4dcafb..f4aa85c564 100644 --- a/source/base/utilities.cc +++ b/source/base/utilities.cc @@ -1158,10 +1158,10 @@ namespace Utilities Epetra_MpiComm *mpi_comm = dynamic_cast(&communicator); if (mpi_comm != nullptr) { - MPI_Comm comm = mpi_comm->GetMpiComm(); - *mpi_comm = Epetra_MpiComm(MPI_COMM_SELF); - const int ierr = MPI_Comm_free(&comm); - AssertThrowMPI(ierr); + MPI_Comm comm = mpi_comm->GetMpiComm(); + *mpi_comm = Epetra_MpiComm(MPI_COMM_SELF); + + Utilities::MPI::free_communicator(comm); } # endif } diff --git a/source/lac/scalapack.cc b/source/lac/scalapack.cc index c8bd59b519..3ac33789b6 100644 --- a/source/lac/scalapack.cc +++ b/source/lac/scalapack.cc @@ -484,7 +484,7 @@ ScaLAPACKMatrix::copy_from(const LAPACKFullMatrix &B, MPI_Group_free(&group_A); MPI_Group_free(&group_B); if (MPI_COMM_NULL != communicator_B) - MPI_Comm_free(&communicator_B); + Utilities::MPI::free_communicator(communicator_B); state = LAPACKSupport::matrix; } @@ -654,7 +654,7 @@ ScaLAPACKMatrix::copy_to(LAPACKFullMatrix &B, MPI_Group_free(&group_A); MPI_Group_free(&group_B); if (MPI_COMM_NULL != communicator_B) - MPI_Comm_free(&communicator_B); + Utilities::MPI::free_communicator(communicator_B); } @@ -954,10 +954,7 @@ ScaLAPACKMatrix::copy_to(ScaLAPACKMatrix &dest) const Cblacs_gridexit(union_blacs_context); if (mpi_communicator_union != MPI_COMM_NULL) - { - ierr = MPI_Comm_free(&mpi_communicator_union); - AssertThrowMPI(ierr); - } + Utilities::MPI::free_communicator(mpi_communicator_union); ierr = MPI_Group_free(&group_source); AssertThrowMPI(ierr); ierr = MPI_Group_free(&group_dest); diff --git a/source/sundials/arkode.cc b/source/sundials/arkode.cc index 7626bcea66..b8da2b5f5b 100644 --- a/source/sundials/arkode.cc +++ b/source/sundials/arkode.cc @@ -378,6 +378,8 @@ namespace SUNDIALS set_functions_to_trigger_an_assert(); } + + template ARKode::~ARKode() { @@ -390,11 +392,7 @@ namespace SUNDIALS # ifdef DEAL_II_WITH_MPI if (is_serial_vector::value == false) - { - const int ierr = MPI_Comm_free(&communicator); - (void)ierr; - AssertNothrow(ierr == MPI_SUCCESS, ExcMPI(ierr)); - } + Utilities::MPI::free_communicator(communicator); # endif } diff --git a/source/sundials/ida.cc b/source/sundials/ida.cc index 08ca464a09..27b7819851 100644 --- a/source/sundials/ida.cc +++ b/source/sundials/ida.cc @@ -213,11 +213,7 @@ namespace SUNDIALS IDAFree(&ida_mem); # ifdef DEAL_II_WITH_MPI if (is_serial_vector::value == false) - { - const int ierr = MPI_Comm_free(&communicator); - (void)ierr; - AssertNothrow(ierr == MPI_SUCCESS, ExcMPI(ierr)); - } + Utilities::MPI::free_communicator(communicator); # endif }