From: Martin Kronbichler Date: Sat, 11 Jun 2016 20:23:41 +0000 (+0200) Subject: Also allow MPI::sum on complex numbers X-Git-Tag: v8.5.0-rc1~977^2~6 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=418920b2e27d53d4c24351fff3d7a4ae07c32c21;p=dealii.git Also allow MPI::sum on complex numbers --- diff --git a/include/deal.II/base/mpi.templates.h b/include/deal.II/base/mpi.templates.h index f4108f2142..a5806cc217 100644 --- a/include/deal.II/base/mpi.templates.h +++ b/include/deal.II/base/mpi.templates.h @@ -121,6 +121,43 @@ namespace Utilities } } + template + void all_reduce (const MPI_Op &mpi_op, + const std::complex *const values, + const MPI_Comm &mpi_communicator, + std::complex *output, + const std::size_t size) + { +#ifdef DEAL_II_WITH_MPI + if (job_supports_mpi()) + { + T dummy_selector; + MPI_Allreduce (values != output + ? + // TODO This const_cast is only needed for older + // (e.g., openMPI 1.6, released in 2012) + // implementations of MPI-2. It is not needed as of + // MPI-3 and we should remove it at some point in + // the future. + const_cast(static_cast(values)) + : + MPI_IN_PLACE, + static_cast(output), + static_cast(size*2), + internal::mpi_type_id(&dummy_selector), + mpi_op, + mpi_communicator); + } + else +#endif + { + (void)mpi_op; + (void)mpi_communicator; + for (std::size_t i=0; i T all_reduce (const MPI_Op &mpi_op, const T &t, diff --git a/source/base/mpi.inst.in b/source/base/mpi.inst.in index 531f86beb1..19a06a0328 100644 --- a/source/base/mpi.inst.in +++ b/source/base/mpi.inst.in @@ -39,6 +39,19 @@ for (S : MPI_SCALARS) } +for (S : COMPLEX_SCALARS) +{ + template + void sum (const Vector &, const MPI_Comm &, Vector &); + + template + S sum (const S &, const MPI_Comm &); + + template + void sum (const std::vector &, const MPI_Comm &, std::vector &); +} + + for (S : REAL_SCALARS; rank: RANKS; dim : SPACE_DIMENSIONS) { template