This code assume commutative and associative reduce operator (MPI_SUM, MPI_MAX, etc).
*/
-#ifndef MPICH2
-extern void *MPIR_ToPointer();
-
-struct MPIR_OP {
- MPI_User_function *op;
- int commute, permanent;
-};
-
-#else
-extern MPI_User_function *MPIR_Op_table[];
-#endif
-
/*
This fucntion performs all-reduce operation as follow. ** in a pipeline fashion **
1) binomial_tree reduce inside each SMP node
{
int comm_size, rank;
void *tmp_buf;
- int tag = 50;
+ int tag = COLL_TAG_ALLREDUCE;
int mask, src, dst;
MPI_Status status;
int num_core = NUM_CORE;
- MPI_User_function *uop;
-#ifndef MPICH2
- struct MPIR_OP *op_ptr = MPIR_ToPointer(op);
- uop = (MPI_User_function *) op_ptr->op;
-#else
- uop = MPIR_Op_table[op % 16 - 1];
-#endif
-
comm_size = smpi_comm_size(comm);
rank = smpi_comm_rank(comm);
MPI_Aint extent;
if (src < comm_size) {
recv_offset = phase * pcount * extent;
smpi_mpi_recv(tmp_buf, pcount, dtype, src, tag, comm, &status);
- (*uop) (tmp_buf, (char *)recv_buf + recv_offset, &pcount, &dtype);
+ smpi_op_apply(op, tmp_buf, (char *)recv_buf + recv_offset, &pcount, &dtype);
}
} else {
send_offset = phase * pcount * extent;
if (src < comm_size) {
recv_offset = (phase - 1) * pcount * extent;
smpi_mpi_recv(tmp_buf, pcount, dtype, src, tag, comm, &status);
- (*uop) (tmp_buf, (char *)recv_buf + recv_offset, &pcount, &dtype);
+ smpi_op_apply(op, tmp_buf, (char *)recv_buf + recv_offset, &pcount, &dtype);
}
} else {
dst = (inter_rank & (~mask)) * num_core;