X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8a9af89e44c0f7f2f648d402e89a26799910ee31..40616078da72e823931c1fb884949054699ec39d:/src/smpi/colls/bcast/bcast-flattree.cpp diff --git a/src/smpi/colls/bcast/bcast-flattree.cpp b/src/smpi/colls/bcast/bcast-flattree.cpp new file mode 100644 index 0000000000..2a307f5f17 --- /dev/null +++ b/src/smpi/colls/bcast/bcast-flattree.cpp @@ -0,0 +1,43 @@ +/* Copyright (c) 2013-2014. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#include "../colls_private.h" + +int +smpi_coll_tuned_bcast_flattree(void *buff, int count, MPI_Datatype data_type, + int root, MPI_Comm comm) +{ + MPI_Request *req_ptr; + MPI_Request *reqs; + + int i, rank, num_procs; + int tag = COLL_TAG_BCAST; + + rank = comm->rank(); + num_procs = comm->size(); + + if (rank != root) { + Request::recv(buff, count, data_type, root, tag, comm, MPI_STATUS_IGNORE); + } + + else { + reqs = (MPI_Request *) xbt_malloc((num_procs - 1) * sizeof(MPI_Request)); + req_ptr = reqs; + + // Root sends data to all others + for (i = 0; i < num_procs; i++) { + if (i == rank) + continue; + *(req_ptr++) = Request::isend(buff, count, data_type, i, tag, comm); + } + + // wait on all requests + Request::waitall(num_procs - 1, reqs, MPI_STATUSES_IGNORE); + + free(reqs); + } + return MPI_SUCCESS; +}