1 #include "colls_private.h"
2 //#include <star-reduction.c>
4 // this requires that count >= NP
5 int smpi_coll_tuned_allreduce_rab2(void *sbuff, void *rbuff,
6 int count, MPI_Datatype dtype,
7 MPI_Op op, MPI_Comm comm)
11 int nbytes, send_size, s_offset, r_offset;
12 void *recv, *send, *tmp;
14 #ifdef MPICH2_REDUCTION
15 MPI_User_function * uop = MPIR_Op_table[op % 16 - 1];
17 MPI_User_function *uop;
18 struct MPIR_OP *op_ptr;
19 op_ptr = MPIR_ToPointer(op);
23 rank = smpi_comm_rank(comm);
24 nprocs = smpi_comm_size(comm);
27 s_extent = smpi_datatype_get_extent(dtype);
34 send_size = (count + nprocs) / nprocs;
35 nbytes = send_size * s_extent;
37 send = (void *) xbt_malloc(s_extent * send_size * nprocs);
38 recv = (void *) xbt_malloc(s_extent * send_size * nprocs);
39 tmp = (void *) xbt_malloc(nbytes);
41 memcpy(send, sbuff, s_extent * count);
43 mpi_coll_alltoall_fun(send, send_size, dtype, recv, send_size, dtype, comm);
45 memcpy(tmp, recv, nbytes);
47 for (i = 1, s_offset = nbytes; i < nprocs; i++, s_offset = i * nbytes)
48 smpi_op_apply(op, (char *) recv + s_offset, tmp, &send_size, &dtype);
50 mpi_coll_allgather_fun(tmp, send_size, dtype, recv, send_size, dtype, comm);
51 memcpy(rbuff, recv, count * s_extent);
58 send_size = count / nprocs;
59 nbytes = send_size * s_extent;
60 r_offset = rank * nbytes;
62 recv = (void *) xbt_malloc(s_extent * send_size * nprocs);
64 mpi_coll_alltoall_fun(send, send_size, dtype, recv, send_size, dtype, comm);
66 memcpy((char *) rbuff + r_offset, recv, nbytes);
68 for (i = 1, s_offset = nbytes; i < nprocs; i++, s_offset = i * nbytes)
69 smpi_op_apply(op, (char *) recv + s_offset, (char *) rbuff + r_offset,
72 mpi_coll_allgather_fun((char *) rbuff + r_offset, send_size, dtype, rbuff, send_size,