From dbedfcda69c9325eae962725532b2f2bf9da59fa Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Thu, 24 Feb 2005 20:05:12 +0000 Subject: [PATCH] next step: a first version of how a non-segmented hierarchical bcast might look like with the current data structures This commit was SVN r4531. --- src/mca/coll/hierarch/coll_hierarch.c | 8 +-- src/mca/coll/hierarch/coll_hierarch.h | 1 + src/mca/coll/hierarch/coll_hierarch_bcast.c | 55 ++++++++++++++++++--- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/src/mca/coll/hierarch/coll_hierarch.c b/src/mca/coll/hierarch/coll_hierarch.c index 9637e08e7c..c55df45f87 100644 --- a/src/mca/coll/hierarch/coll_hierarch.c +++ b/src/mca/coll/hierarch/coll_hierarch.c @@ -201,6 +201,7 @@ mca_coll_hierarch_module_init(struct ompi_communicator_t *comm) if ( NULL == data->hier_reqs ) { goto exit; } + data->hier_am_lleader=0; /* false */ /* determine how many local leader there are and who they are */ colorarr = (int *) comm->c_coll_selected_data; @@ -228,8 +229,10 @@ mca_coll_hierarch_module_init(struct ompi_communicator_t *comm) data->hier_my_lleader = c; } c++; + if ( llr[c] == rank ) { + data->hier_am_lleader = 1; + } } - } data->hier_num_lleaders = c-1; @@ -365,9 +368,6 @@ mca_coll_hierarch_checkfor_component ( struct ompi_communicator_t *comm, } } - /* Here we might introduce later on an allreduce step to determine, - whether we agree on the result or not */ - *ncount = counter; /* true */ /* Print the final result */ if ( counter == 1 ) { diff --git a/src/mca/coll/hierarch/coll_hierarch.h b/src/mca/coll/hierarch/coll_hierarch.h index 2c88971076..12f5954056 100644 --- a/src/mca/coll/hierarch/coll_hierarch.h +++ b/src/mca/coll/hierarch/coll_hierarch.h @@ -44,6 +44,7 @@ extern int mca_coll_hierarch_verbose; int hier_num_lleaders; /* number of local leaders */ int *hier_lleaders; /* list of local leaders */ int hier_my_lleader; /* pos. of my lleader in hier_lleaders */ + int hier_am_lleader; /* am I an lleader? */ int hier_num_reqs; /* num. of requests */ ompi_request_t **hier_reqs; /* list of requests */ }; diff --git a/src/mca/coll/hierarch/coll_hierarch_bcast.c b/src/mca/coll/hierarch/coll_hierarch_bcast.c index ce21f9e989..6e8bf99df1 100644 --- a/src/mca/coll/hierarch/coll_hierarch_bcast.c +++ b/src/mca/coll/hierarch/coll_hierarch_bcast.c @@ -20,6 +20,7 @@ #include "util/output.h" #include "mca/coll/coll.h" #include "mca/coll/base/base.h" +#include "mca/coll/base/coll_tags.h" #include "coll_hierarch.h" @@ -31,10 +32,52 @@ * Returns: - MPI_SUCCESS or error code */ int mca_coll_hierarch_bcast_intra(void *buff, int count, - struct ompi_datatype_t *datatype, int root, - struct ompi_communicator_t *comm) + struct ompi_datatype_t *datatype, int root, + struct ompi_communicator_t *comm) { - ompi_output_verbose(10, mca_coll_base_output, "In hierarch bcast_intra"); - return comm->c_coll_basic_module->coll_bcast(buff, count, datatype, - root, comm); -} + struct mca_coll_base_comm_t *data=NULL; + struct ompi_communicator_t *llcomm=NULL; + int i, rank, ret; + + rank = ompi_comm_rank ( comm ); + data = comm->c_coll_selected_data; + llcomm = data->hier_llcomm; + + /* trivial linear distribution of the data to all local leaders. + need something significantly better */ + if ( rank == root ) { + for (i=0; i< data->hier_num_lleaders; i++) { + if ( data->hier_lleaders[i] == data->hier_my_lleader ) { + data->hier_reqs[i] = MPI_REQUEST_NULL; + continue; + } + ret = mca_pml.pml_isend (buff, count, datatype, data->hier_lleaders[i], + MCA_COLL_BASE_TAG_BCAST, + MCA_PML_BASE_SEND_STANDARD, + comm, &(data->hier_reqs[i])); + if ( OMPI_SUCCESS != ret ) { + return ret; + } + } + ret = ompi_request_wait_all ( data->hier_num_lleaders, data->hier_reqs, + MPI_STATUSES_IGNORE); + if ( OMPI_SUCCESS != ret ) { + return ret; + } + } + else if ( data->hier_am_lleader ) { + ret = mca_pml.pml_recv ( buff, count, datatype, root, + MCA_COLL_BASE_TAG_BCAST, comm, + MPI_STATUS_IGNORE ); + if ( OMPI_SUCCESS != ret ) { + return ret; + } + } + + if ( MPI_COMM_NULL != llcomm ) { + ret = llcomm->c_coll.coll_bcast(buff, count, datatype, + data->hier_my_lleader, llcomm ); + } + + return ret; + }