From: Wolfgang Bangerth Date: Wed, 21 Apr 2021 00:02:06 +0000 (-0600) Subject: Minor optimization in Utilities::MPI::broadcast(). X-Git-Tag: v9.3.0-rc1~201^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32fd05ec18a05cefa3a7090c740e87401febcfcc;p=dealii.git Minor optimization in Utilities::MPI::broadcast(). --- diff --git a/include/deal.II/base/mpi.h b/include/deal.II/base/mpi.h index 2a0e52342b..670f439b16 100644 --- a/include/deal.II/base/mpi.h +++ b/include/deal.II/base/mpi.h @@ -1114,7 +1114,9 @@ namespace Utilities * @param[in] root_process The process that sends the object to all * processes. By default the process with rank 0 is the root process. * - * @return Every process receives the object sent by the @p root_process. + * @return On the root process, return a copy of @p object_to_send. + * On every other process, return a copy of the object sent by + * the @p root_process. */ template T @@ -1514,6 +1516,8 @@ namespace Utilities # endif } + + template T broadcast(const MPI_Comm & comm, @@ -1553,7 +1557,10 @@ namespace Utilities MPI_Bcast(buffer.data(), buffer_size, MPI_CHAR, root_process, comm); AssertThrowMPI(ierr); - return Utilities::unpack(buffer, false); + if (Utilities::MPI::this_mpi_process(comm) == root_process) + return object_to_send; + else + return Utilities::unpack(buffer, false); # endif }