1 #include "colls_private.h"
3 //#include <star-reduction.c>
5 int smpi_coll_tuned_reduce_binomial(void *sendbuf, void *recvbuf, int count,
6 MPI_Datatype datatype, MPI_Op op, int root,
11 int mask, relrank, source;
19 rank = smpi_comm_rank(comm);
20 comm_size = smpi_comm_size(comm);
22 extent = smpi_datatype_get_extent(datatype);
24 tmp_buf = (void *) xbt_malloc(count * extent);
26 smpi_mpi_sendrecv(sendbuf, count, datatype, rank, tag,
27 recvbuf, count, datatype, rank, tag, comm, &status);
29 relrank = (rank - root + comm_size) % comm_size;
31 while (mask < comm_size) {
33 if ((mask & relrank) == 0) {
34 source = (relrank | mask);
35 if (source < comm_size) {
36 source = (source + root) % comm_size;
37 smpi_mpi_recv(tmp_buf, count, datatype, source, tag, comm, &status);
38 smpi_op_apply(op, tmp_buf, recvbuf, &count, &datatype);
41 dst = ((relrank & (~mask)) + root) % comm_size;
42 smpi_mpi_send(recvbuf, count, datatype, dst, tag, comm);