1 #include "colls_private.h"
2 //#include <star-reduction.c>
5 smpi_coll_tuned_reduce_flat_tree(void *sbuf, void *rbuf, int count,
6 MPI_Datatype dtype, MPI_Op op,
7 int root, MPI_Comm comm)
9 int i, tag = COLL_TAG_REDUCE;
17 rank = smpi_comm_rank(comm);
18 size = smpi_comm_size(comm);
20 /* If not root, send data to the root. */
21 extent = smpi_datatype_get_extent(dtype);
24 smpi_mpi_send(sbuf, count, dtype, root, tag, comm);
28 /* Root receives and reduces messages. Allocate buffer to receive
32 origin = (char *) xbt_malloc(count * extent);
35 /* Initialize the receive buffer. */
36 if (rank == (size - 1))
37 smpi_mpi_sendrecv(sbuf, count, dtype, rank, tag,
38 rbuf, count, dtype, rank, tag, comm, &status);
40 smpi_mpi_recv(rbuf, count, dtype, size - 1, tag, comm, &status);
42 /* Loop receiving and calling reduction function (C or Fortran). */
44 for (i = size - 2; i >= 0; --i) {
48 smpi_mpi_recv(origin, count, dtype, i, tag, comm, &status);
52 /* Call reduction function. */
53 smpi_op_apply(op, inbuf, rbuf, &count, &dtype);