X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/befbbbe1fbb31663a8f91e24ce12df271cf4ae79..5089a0a98b27f5eeee62321dff4f025f1648f025:/src/smpi/colls/bcast/bcast-ompi-split-bintree.cpp diff --git a/src/smpi/colls/bcast/bcast-ompi-split-bintree.cpp b/src/smpi/colls/bcast/bcast-ompi-split-bintree.cpp index e2a095851c..b4e7de5ccb 100644 --- a/src/smpi/colls/bcast/bcast-ompi-split-bintree.cpp +++ b/src/smpi/colls/bcast/bcast-ompi-split-bintree.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. +/* Copyright (c) 2013-2019. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -55,18 +55,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include "../colls_private.h" - #include "../coll_tuned_topo.h" - #define MAXTREEFANOUT 32 -namespace simgrid{ -namespace smpi{ - -int -Coll_bcast_ompi_split_bintree::bcast ( void* buffer, - int count, - MPI_Datatype datatype, - int root, - MPI_Comm comm) +#include "../coll_tuned_topo.hpp" +#include "../colls_private.hpp" +#define MAXTREEFANOUT 32 +namespace simgrid { +namespace smpi { + +int bcast__ompi_split_bintree( void* buffer, + int count, + MPI_Datatype datatype, + int root, + MPI_Comm comm) { unsigned int segsize ; int rank, size; @@ -98,7 +97,7 @@ Coll_bcast_ompi_split_bintree::bcast ( void* buffer, else segsize = 1024 << 3; - XBT_DEBUG("ompi_coll_tuned_bcast_intra_split_bintree rank %d root %d ss %5d", rank, root, segsize); + XBT_DEBUG("ompi_coll_tuned_bcast_intra_split_bintree rank %d root %d ss %5u", rank, root, segsize); if (size == 1) { return MPI_SUCCESS; @@ -136,8 +135,7 @@ Coll_bcast_ompi_split_bintree::bcast ( void* buffer, (segsize > counts[0] * type_size) || (segsize > counts[1] * type_size) ) { /* call linear version here ! */ - return (Coll_bcast_SMP_linear::bcast ( buffer, count, datatype, - root, comm)); + return bcast__SMP_linear( buffer, count, datatype, root, comm); } type_extent = datatype->get_extent(); @@ -185,43 +183,38 @@ Coll_bcast_ompi_split_bintree::bcast ( void* buffer, /* intermediate nodes code */ else if( tree->tree_nextsize > 0 ) { - /* Intermediate nodes: - * It will receive segments only from one half of the data. - * Which one is determined by whether the node belongs to the "left" or "right" - * subtree. Topoloby building function builds binary tree such that - * odd "shifted ranks" ((rank + size - root)%size) are on the left subtree, - * and even on the right subtree. - * - * Create the pipeline. We first post the first receive, then in the loop we - * post the next receive and after that wait for the previous receive to complete - * and we disseminating the data to all children. - */ - sendcount[lr] = segcount[lr]; - base_req=Request::irecv(tmpbuf[lr], sendcount[lr], datatype, - tree->tree_prev, COLL_TAG_BCAST, - comm); + /* Intermediate nodes: + * It will receive segments only from one half of the data. + * Which one is determined by whether the node belongs to the "left" or "right" + * subtree. Topology building function builds binary tree such that + * odd "shifted ranks" ((rank + size - root)%size) are on the left subtree, + * and even on the right subtree. + * + * Create the pipeline. We first post the first receive, then in the loop we + * post the next receive and after that wait for the previous receive to complete + * and we disseminating the data to all children. + */ + sendcount[lr] = segcount[lr]; + base_req = Request::irecv(tmpbuf[lr], sendcount[lr], datatype, tree->tree_prev, COLL_TAG_BCAST, comm); + + for (segindex = 1; segindex < num_segments[lr]; segindex++) { + /* determine how many elements to expect in this round */ + if (segindex == (num_segments[lr] - 1)) + sendcount[lr] = counts[lr] - segindex * segcount[lr]; + /* post new irecv */ + new_req = Request::irecv(tmpbuf[lr] + realsegsize[lr], sendcount[lr], datatype, tree->tree_prev, COLL_TAG_BCAST, + comm); + + /* wait for and forward current segment */ + Request::waitall(1, &base_req, MPI_STATUSES_IGNORE); + for (i = 0; i < tree->tree_nextsize; i++) { /* send data to children (segcount[lr]) */ + Request::send(tmpbuf[lr], segcount[lr], datatype, tree->tree_next[i], COLL_TAG_BCAST, comm); + } /* end of for each child */ - for( segindex = 1; segindex < num_segments[lr]; segindex++ ) { - /* determine how many elements to expect in this round */ - if( segindex == (num_segments[lr] - 1)) - sendcount[lr] = counts[lr] - segindex*segcount[lr]; - /* post new irecv */ - new_req = Request::irecv( tmpbuf[lr] + realsegsize[lr], sendcount[lr], - datatype, tree->tree_prev, COLL_TAG_BCAST, - comm); - - /* wait for and forward current segment */ - Request::waitall( 1, &base_req, MPI_STATUSES_IGNORE ); - for( i = 0; i < tree->tree_nextsize; i++ ) { /* send data to children (segcount[lr]) */ - Request::send( tmpbuf[lr], segcount[lr], datatype, - tree->tree_next[i], COLL_TAG_BCAST, - comm); - } /* end of for each child */ - - /* upate the base request */ - base_req = new_req; - /* go to the next buffer (ie. the one corresponding to the next recv) */ - tmpbuf[lr] += realsegsize[lr]; + /* upate the base request */ + base_req = new_req; + /* go to the next buffer (ie. the one corresponding to the next recv) */ + tmpbuf[lr] += realsegsize[lr]; } /* end of for segindex */ /* wait for the last segment and forward current segment */ @@ -296,7 +289,7 @@ Coll_bcast_ompi_split_bintree::bcast ( void* buffer, comm, MPI_STATUS_IGNORE); } } - xbt_free(tree); + ompi_coll_tuned_topo_destroy_tree(&tree); return (MPI_SUCCESS);