]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add MPI::free_communicator function
authorTimo Heister <timo.heister@gmail.com>
Tue, 22 Oct 2019 19:20:05 +0000 (21:20 +0200)
committerTimo Heister <timo.heister@gmail.com>
Tue, 22 Oct 2019 19:47:15 +0000 (21:47 +0200)
include/deal.II/base/mpi.h
source/base/mpi.cc

index 294994e744ecc84fcbf93f2bdbe4870c1d247628..2c03fabdf3b49c5240563e01240aee0769c0e1e3 100644 (file)
@@ -191,11 +191,26 @@ namespace Utilities
      * can interact without interfering with each other.
      *
      * When no longer needed, the communicator created here needs to be
-     * destroyed using <code>MPI_Comm_free</code>.
+     * destroyed using free_communicator().
+     *
+     * This function is equivalent to calling
+     * <code>MPI_Comm_dup(mpi_communicator, &return_value);</code>.
      */
     MPI_Comm
     duplicate_communicator(const MPI_Comm &mpi_communicator);
 
+    /**
+     * Free the given
+     * @ref GlossMPICommunicator "communicator"
+     * @p mpi_communicator that was duplicated using duplicate_communicator().
+     *
+     * The argument is passed by reference and will be invalidated and set to
+     * the MPI null handle. This function is equivalent to calling
+     * <code>MPI_Comm_free(&mpi_communicator);</code>.
+     */
+    void
+    free_communicator(MPI_Comm &mpi_communicator);
+
     /**
      * If @p comm is an intracommunicator, this function returns a new
      * communicator @p newcomm with communication group defined by the
index 4de6ac44eff8972f3918203baf8d1e4345f3025d..3c7318b5191194a36edf7a096bf7b08c11d284b7 100644 (file)
@@ -103,6 +103,15 @@ namespace Utilities
 
 
 
+    void
+    free_communicator(MPI_Comm &mpi_communicator)
+    {
+      const int ierr = MPI_Comm_free(&mpi_communicator);
+      AssertThrowMPI(ierr);
+    }
+
+
+
     int
     create_group(const MPI_Comm & comm,
                  const MPI_Group &group,
@@ -521,6 +530,7 @@ namespace Utilities
     }
 
 
+
     std::vector<IndexSet>
     create_ascending_partitioning(const MPI_Comm & /*comm*/,
                                   const IndexSet::size_type &local_size)
@@ -529,6 +539,7 @@ namespace Utilities
     }
 
 
+
     MPI_Comm
     duplicate_communicator(const MPI_Comm &mpi_communicator)
     {
@@ -537,6 +548,12 @@ namespace Utilities
 
 
 
+    void
+    free_communicator(MPI_Comm & /*mpi_communicator*/)
+    {}
+
+
+
     MinMaxAvg
     min_max_avg(const double my_value, const MPI_Comm &)
     {

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.