AllReduce for Arrays

This commit is contained in:
Joachim Schoeberl 2022-03-05 11:42:00 +01:00
parent d2348a7651
commit 2b9d4596ae

View File

@ -254,6 +254,15 @@ namespace ngcore
return global_d;
}
template <typename T, typename T2 = decltype(GetMPIType<T>())>
void AllReduce (FlatArray<T> 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<T>(), op, comm);
}
template <typename T, typename T2 = decltype(GetMPIType<T>())>
void Bcast (T & s, int root = 0) const {
if (size == 1) return ;
@ -396,6 +405,9 @@ namespace ngcore
template <typename T>
T AllReduce (T d, const MPI_Op & op) const { return d; }
template <typename T>
void AllReduce (FlatArray<T> d, const MPI_Op & op) const { ; }
template <typename T>
void Bcast (T & s, int root = 0) const { ; }