+
+
#include "private.h"
+#include "smpi_coll_private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi, smpi,
"Logging specific to SMPI (mpi)");
/**
* MPI_Bcast
**/
+
+/**
+ * flat bcast
+ **/
+int flat_tree_bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm);
+int flat_tree_bcast(void *buf, int count, MPI_Datatype datatype, int root,
+ MPI_Comm comm)
+{
+ int rank;
+ int retval = MPI_SUCCESS;
+ smpi_mpi_request_t request;
+
+ rank = smpi_mpi_comm_rank(comm);
+ if (rank == root) {
+ retval = smpi_create_request(buf, count, datatype, root,
+ (root + 1) % comm->size, 0, comm, &request);
+ request->forward = comm->size - 1;
+ smpi_mpi_isend(request);
+ } else {
+ retval = smpi_create_request(buf, count, datatype, MPI_ANY_SOURCE, rank,
+ 0, comm, &request);
+ smpi_mpi_irecv(request);
+ }
+
+ smpi_mpi_wait(request, MPI_STATUS_IGNORE);
+ xbt_mallocator_release(smpi_global->request_mallocator, request);
+
+ return(retval);
+
+}
+
+/**
+ * Bcast user entry point
+ **/
int SMPI_MPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root,
MPI_Comm comm)
{
int retval = MPI_SUCCESS;
- int rank;
- smpi_mpi_request_t request;
smpi_bench_end();
- rank = smpi_mpi_comm_rank(comm);
-
- if (rank == root) {
- retval = smpi_create_request(buf, count, datatype, root,
- (root + 1) % comm->size, 0, comm, &request);
- request->forward = comm->size - 1;
- smpi_mpi_isend(request);
- } else {
- retval = smpi_create_request(buf, count, datatype, MPI_ANY_SOURCE, rank,
- 0, comm, &request);
- smpi_mpi_irecv(request);
- }
-
- smpi_mpi_wait(request, MPI_STATUS_IGNORE);
- xbt_mallocator_release(smpi_global->request_mallocator, request);
+ //retval = flat_tree_bcast(buf, count, datatype, root, comm);
+ retval = binomial_tree_bcast(buf, count, datatype, root, comm);
smpi_bench_begin();
return retval;
}
+/**
+ * MPI_Allreduce
+ *
+ * Same as MPI_REDUCE except that the result appears in the receive buffer of all the group members.
+ **/
+int SMPI_MPI_Allreduce( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
+ MPI_Op op, MPI_Comm comm );
+int SMPI_MPI_Allreduce( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
+ MPI_Op op, MPI_Comm comm )
+{
+ int retval = MPI_SUCCESS;
+ int root=0; // arbitrary choice
+
+ smpi_bench_end();
+
+ retval = SMPI_MPI_Reduce( sendbuf, recvbuf, count, datatype, op, root, comm);
+ if (MPI_SUCCESS != retval)
+ return(retval);
+ retval = SMPI_MPI_Bcast( recvbuf, count, datatype, root, comm);
+
+ smpi_bench_begin();
+ return( retval );
+}
+
+
+
+
+
// used by comm_split to sort ranks based on key values
int smpi_compare_rankkeys(const void *a, const void *b);
int smpi_compare_rankkeys(const void *a, const void *b)