diff --git a/src/tools/Communicator.cpp b/src/tools/Communicator.cpp index 87968e7e7cbf8b4d73a537c050cd8c41cb4e27d6..bc2e047426aa391db22148fc4860e8d5cfd1d8fe 100644 --- a/src/tools/Communicator.cpp +++ b/src/tools/Communicator.cpp @@ -131,6 +131,30 @@ void Communicator::Sum(Data data) { #endif } +void Communicator::Prod(Data data) { +#if defined(__PLUMED_HAS_MPI) + if(initialized()) MPI_Allreduce(MPI_IN_PLACE,data.pointer,data.size,data.type,MPI_PROD,communicator); +#else + (void) data; +#endif +} + +void Communicator::Max(Data data) { +#if defined(__PLUMED_HAS_MPI) + if(initialized()) MPI_Allreduce(MPI_IN_PLACE,data.pointer,data.size,data.type,MPI_MAX,communicator); +#else + (void) data; +#endif +} + +void Communicator::Min(Data data) { +#if defined(__PLUMED_HAS_MPI) + if(initialized()) MPI_Allreduce(MPI_IN_PLACE,data.pointer,data.size,data.type,MPI_MIN,communicator); +#else + (void) data; +#endif +} + Communicator::Request Communicator::Isend(ConstData data,int source,int tag) { Request req; #ifdef __PLUMED_HAS_MPI diff --git a/src/tools/Communicator.h b/src/tools/Communicator.h index 97cc60fb8c0b5bba02c8472db3915da3119ed954..eaf93054125b3265c9d8dec9f2d452698e933b07 100644 --- a/src/tools/Communicator.h +++ b/src/tools/Communicator.h @@ -175,6 +175,24 @@ public: template <class T> void Sum(T*buf,int count) {Sum(Data(buf,count));} /// Wrapper for MPI_Allreduce with MPI_SUM (reference) template <class T> void Sum(T&buf) {Sum(Data(buf));} +/// Wrapper for MPI_Allreduce with MPI_PROD (data struct) + void Prod(Data); +/// Wrapper for MPI_Allreduce with MPI_PROD (pointer) + template <class T> void Prod(T*buf,int count) {Prod(Data(buf,count));} +/// Wrapper for MPI_Allreduce with MPI_PROD (reference) + template <class T> void Prod(T&buf) {Prod(Data(buf));} +/// Wrapper for MPI_Allreduce with MPI_MAX (data struct) + void Max(Data); +/// Wrapper for MPI_Allreduce with MPI_MAX (pointer) + template <class T> void Max(T*buf,int count) {Max(Data(buf,count));} +/// Wrapper for MPI_Allreduce with MPI_MAX (reference) + template <class T> void Max(T&buf) {Max(Data(buf));} +/// Wrapper for MPI_Allreduce with MPI_MIN (data struct) + void Min(Data); +/// Wrapper for MPI_Allreduce with MPI_MIN (pointer) + template <class T> void Min(T*buf,int count) {Min(Data(buf,count));} +/// Wrapper for MPI_Allreduce with MPI_MIN (reference) + template <class T> void Min(T&buf) {Min(Data(buf));} /// Wrapper for MPI_Bcast (data struct) void Bcast(Data,int);