]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use MPI::Utilities::free_communicator() where possible. 13280/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 21 Jan 2022 21:37:22 +0000 (14:37 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 21 Jan 2022 21:37:22 +0000 (14:37 -0700)
include/deal.II/base/aligned_vector.h
source/base/data_out_base.cc
source/base/mpi.cc
source/base/process_grid.cc
source/base/utilities.cc
source/lac/scalapack.cc
source/sundials/arkode.cc
source/sundials/ida.cc

index ff3dffbbd6a29cc5d4155693e92c9753a95e2fed..b9718a503b55222ec2afa2c755e70d1233daab5e 100644 (file)
@@ -1141,8 +1141,7 @@ AlignedVector<T>::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<T>::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<T>::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 ****
index 5b229d85a5a8909d6adcc5485a0d841daa3ef3a9..92490893f751b3861d57bfdc8bb39372066f3b39 100644 (file)
@@ -7841,8 +7841,7 @@ DataOutInterface<dim, spacedim>::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
index 6d04a9b395526e36adb34fe35d5e3b86c5fc2c24..15f101bad7fda08dbdcb73296eb6677e60e49618 100644 (file)
@@ -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);
             }
         }
 
index 5c1541f9e28ff1e949282795add620470cfb1247..18b7905bbc6b48c50f7c5be8c3cf13181244c527 100644 (file)
@@ -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);
     }
 
 
index 88ca4dcafbf2a566b2cbdbbd7973e999547a6705..f4aa85c564fd32baba19ca908c71b0b1b4831852 100644 (file)
@@ -1158,10 +1158,10 @@ namespace Utilities
       Epetra_MpiComm *mpi_comm = dynamic_cast<Epetra_MpiComm *>(&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
     }
index c8bd59b519ead73ea116675c194069d23bccb825..3ac33789b676297aa7128daf5f39bad68eac7821 100644 (file)
@@ -484,7 +484,7 @@ ScaLAPACKMatrix<NumberType>::copy_from(const LAPACKFullMatrix<NumberType> &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<NumberType>::copy_to(LAPACKFullMatrix<NumberType> &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<NumberType>::copy_to(ScaLAPACKMatrix<NumberType> &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);
index 7626bcea664a8f71757cc85d7b193b425df6d665..b8da2b5f5b204fee14283d7bb7b1797fe39b6026 100644 (file)
@@ -378,6 +378,8 @@ namespace SUNDIALS
     set_functions_to_trigger_an_assert();
   }
 
+
+
   template <typename VectorType>
   ARKode<VectorType>::~ARKode()
   {
@@ -390,11 +392,7 @@ namespace SUNDIALS
 
 #  ifdef DEAL_II_WITH_MPI
     if (is_serial_vector<VectorType>::value == false)
-      {
-        const int ierr = MPI_Comm_free(&communicator);
-        (void)ierr;
-        AssertNothrow(ierr == MPI_SUCCESS, ExcMPI(ierr));
-      }
+      Utilities::MPI::free_communicator(communicator);
 #  endif
   }
 
index 08ca464a09f73d1742ebc127d3118f489552b166..27b78198517c983b04209b37499d18ea4af044ef 100644 (file)
@@ -213,11 +213,7 @@ namespace SUNDIALS
       IDAFree(&ida_mem);
 #  ifdef DEAL_II_WITH_MPI
     if (is_serial_vector<VectorType>::value == false)
-      {
-        const int ierr = MPI_Comm_free(&communicator);
-        (void)ierr;
-        AssertNothrow(ierr == MPI_SUCCESS, ExcMPI(ierr));
-      }
+      Utilities::MPI::free_communicator(communicator);
 #  endif
   }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.