From 2b9d4596aeccb6d9291645cb040621c09e190b33 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Sat, 5 Mar 2022 11:42:00 +0100 Subject: [PATCH] AllReduce for Arrays --- libsrc/core/mpi_wrapper.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libsrc/core/mpi_wrapper.hpp b/libsrc/core/mpi_wrapper.hpp index 3675db7e..ee252f23 100644 --- a/libsrc/core/mpi_wrapper.hpp +++ b/libsrc/core/mpi_wrapper.hpp @@ -254,6 +254,15 @@ namespace ngcore return global_d; } + template ())> + void AllReduce (FlatArray d, const MPI_Op & op) const + { + static Timer t("MPI - AllReduce Array"); RegionTimer reg(t); + if (size == 1) return d; + + MPI_Allreduce (MPI_IN_PLACE, d.Data(), d.Size(), GetMPIType(), op, comm); + } + template ())> void Bcast (T & s, int root = 0) const { if (size == 1) return ; @@ -396,6 +405,9 @@ namespace ngcore template T AllReduce (T d, const MPI_Op & op) const { return d; } + template + void AllReduce (FlatArray d, const MPI_Op & op) const { ; } + template void Bcast (T & s, int root = 0) const { ; }