1#include "Communicate/DataTypes.h"
3#include "Communicate/Operations.h"
8 void Communicator::gather(
const T* input, T* output,
int count,
int root) {
9 MPI_Datatype type = get_mpi_datatype<T>(*input);
11 MPI_Gather(
const_cast<T*
>(input), count, type, output, count, type, root, *comm_m);
15 void Communicator::scatter(
const T* input, T* output,
int count,
int root) {
16 MPI_Datatype type = get_mpi_datatype<T>(*input);
18 MPI_Scatter(
const_cast<T*
>(input), count, type, output, count, type, root, *comm_m);
21 template <
typename T,
class Op>
22 void Communicator::reduce(
const T* input, T* output,
int count, Op,
int root) {
23 MPI_Datatype type = get_mpi_datatype<T>(*input);
25 MPI_Op mpiOp = get_mpi_op<Op, T>();
27 MPI_Reduce(
const_cast<T*
>(input), output, count, type, mpiOp, root, *comm_m);
30 template <
typename T,
class Op>
31 void Communicator::reduce(
const T& input, T& output,
int count, Op op,
int root) {
32 reduce(&input, &output, count, op, root);
35 template <
typename T,
class Op>
36 void Communicator::allreduce(
const T* input, T* output,
int count, Op) {
37 MPI_Datatype type = get_mpi_datatype<T>(*input);
39 MPI_Op mpiOp = get_mpi_op<Op, T>();
41 MPI_Allreduce(
const_cast<T*
>(input), output, count, type, mpiOp, *comm_m);
44 template <
typename T,
class Op>
45 void Communicator::allreduce(
const T& input, T& output,
int count, Op op) {
46 allreduce(&input, &output, count, op);
49 template <
typename T,
class Op>
50 void Communicator::allreduce(T* inout,
int count, Op) {
51 MPI_Datatype type = get_mpi_datatype<T>(*inout);
53 MPI_Op mpiOp = get_mpi_op<Op, T>();
55 MPI_Allreduce(MPI_IN_PLACE, inout, count, type, mpiOp, *comm_m);
58 template <
typename T,
class Op>
59 void Communicator::allreduce(T& inout,
int count, Op op) {
60 allreduce(&inout, count, op);