From 3a7efaf4d949dca8dd9a7dc4831eabd51d91785d Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Tue, 18 Oct 2005 19:20:48 +0000 Subject: [PATCH] fix for reduce and allreduce for an unsymmetric case This commit was SVN r7802. --- ompi/mca/coll/hierarch/coll_hierarch.c | 14 +++-- .../coll/hierarch/coll_hierarch_allreduce.c | 51 ++++++++++--------- ompi/mca/coll/hierarch/coll_hierarch_reduce.c | 48 +++++++++-------- 3 files changed, 64 insertions(+), 49 deletions(-) diff --git a/ompi/mca/coll/hierarch/coll_hierarch.c b/ompi/mca/coll/hierarch/coll_hierarch.c index daabc9938d..df73301904 100644 --- a/ompi/mca/coll/hierarch/coll_hierarch.c +++ b/ompi/mca/coll/hierarch/coll_hierarch.c @@ -171,8 +171,8 @@ mca_coll_hierarch_comm_query(struct ompi_communicator_t *comm, int *priority, size = ompi_comm_size(comm); - if ( size == 1 ) { - /* No need for hierarchical collectives . */ + if ( size < 3 ) { + /* No need for hierarchical collectives for 1 or 2 procs. */ return NULL; } @@ -550,10 +550,18 @@ struct ompi_communicator_t* mca_coll_hierarch_get_llcomm (int root, continue; } - if (llead->offset >= offset ) { + if (llead->offset == offset ) { found = 1; break; } +#if 0 + else if () { + /* the offset of root = maxoffset of this color and + * the offset on llead is larger then offset of root. + * then we can also use this llead structure + */ + } +#endif } if ( !found ) { diff --git a/ompi/mca/coll/hierarch/coll_hierarch_allreduce.c b/ompi/mca/coll/hierarch/coll_hierarch_allreduce.c index 4a6d3af236..320a0701d3 100644 --- a/ompi/mca/coll/hierarch/coll_hierarch_allreduce.c +++ b/ompi/mca/coll/hierarch/coll_hierarch_allreduce.c @@ -61,35 +61,38 @@ int mca_coll_hierarch_allreduce_intra(void *sbuf, void *rbuf, int count, llcomm = mca_coll_hierarch_get_llcomm ( root, data, &llroot, &lroot); if ( MPI_COMM_NULL != lcomm ) { - lrank = ompi_comm_rank (lcomm); - if ( lrank == lroot ) { - ompi_ddt_get_extent(dtype, &lb, &extent); - ompi_ddt_get_true_extent(dtype, &true_lb, &true_extent); - - tbuf = malloc(true_extent + (count - 1) * extent); - if (NULL == tbuf) { - return OMPI_ERR_OUT_OF_RESOURCE; - } - tmpbuf = tbuf - lb; - } - - if ( MPI_IN_PLACE != sbuf ) { - ret = lcomm->c_coll.coll_reduce (sbuf, tmpbuf, count, dtype, - op, lroot, lcomm); - } - else { - ret = lcomm->c_coll.coll_reduce (rbuf, tmpbuf, count, dtype, - op, lroot, lcomm); - } - if ( OMPI_SUCCESS != ret ) { - goto exit; - } + ompi_ddt_get_extent(dtype, &lb, &extent); + ompi_ddt_get_true_extent(dtype, &true_lb, &true_extent); + + tbuf = malloc(true_extent + (count - 1) * extent); + if (NULL == tbuf) { + return OMPI_ERR_OUT_OF_RESOURCE; + } + tmpbuf = tbuf - lb; + + if ( MPI_IN_PLACE != sbuf ) { + ret = lcomm->c_coll.coll_reduce (sbuf, tmpbuf, count, dtype, + op, lroot, lcomm); + } + else { + ret = lcomm->c_coll.coll_reduce (rbuf, tmpbuf, count, dtype, + op, lroot, lcomm); + } + if ( OMPI_SUCCESS != ret ) { + goto exit; + } } if ( MPI_UNDEFINED != llroot ) { + if ( MPI_COMM_NULL != lcomm ) { ret = llcomm->c_coll.coll_allreduce (tmpbuf, rbuf, count, dtype, op, llcomm); - } + } + else { + ret = llcomm->c_coll.coll_allreduce (sbuf, rbuf, count, dtype, + op, llcomm); + } + } if ( MPI_COMM_NULL != lcomm ) { ret = lcomm->c_coll.coll_bcast(rbuf, count, dtype, lroot, lcomm ); diff --git a/ompi/mca/coll/hierarch/coll_hierarch_reduce.c b/ompi/mca/coll/hierarch/coll_hierarch_reduce.c index 9a2124a8df..a11b45496f 100644 --- a/ompi/mca/coll/hierarch/coll_hierarch_reduce.c +++ b/ompi/mca/coll/hierarch/coll_hierarch_reduce.c @@ -60,34 +60,38 @@ int mca_coll_hierarch_reduce_intra(void *sbuf, void *rbuf, int count, llcomm = mca_coll_hierarch_get_llcomm ( root, data, &llroot, &lroot); if ( MPI_COMM_NULL != lcomm ) { - lrank = ompi_comm_rank (lcomm); - if ( lrank == lroot ) { - ompi_ddt_get_extent(dtype, &lb, &extent); - ompi_ddt_get_true_extent(dtype, &true_lb, &true_extent); + ompi_ddt_get_extent(dtype, &lb, &extent); + ompi_ddt_get_true_extent(dtype, &true_lb, &true_extent); + + tbuf = malloc(true_extent + (count - 1) * extent); + if (NULL == tbuf) { + return OMPI_ERR_OUT_OF_RESOURCE; + } + tmpbuf = tbuf - lb; + - tbuf = malloc(true_extent + (count - 1) * extent); - if (NULL == tbuf) { - return OMPI_ERR_OUT_OF_RESOURCE; - } - tmpbuf = tbuf - lb; - } - - if ( MPI_IN_PLACE != sbuf ) { - ret = lcomm->c_coll.coll_reduce (sbuf, tmpbuf, count, dtype, - op, lroot, lcomm); - } - else { - ret = lcomm->c_coll.coll_reduce (rbuf, tmpbuf, count, dtype, - op, lroot, lcomm); - } - if ( OMPI_SUCCESS != ret ) { - goto exit; - } + if ( MPI_IN_PLACE != sbuf ) { + ret = lcomm->c_coll.coll_reduce (sbuf, tmpbuf, count, dtype, + op, lroot, lcomm); + } + else { + ret = lcomm->c_coll.coll_reduce (rbuf, tmpbuf, count, dtype, + op, lroot, lcomm); + } + if ( OMPI_SUCCESS != ret ) { + goto exit; + } } if ( MPI_UNDEFINED != llroot ) { + if ( MPI_COMM_NULL != lcomm ) { ret = llcomm->c_coll.coll_reduce (tmpbuf, rbuf, count, dtype, op, llroot, llcomm); + } + else { + ret = llcomm->c_coll.coll_reduce (sbuf, rbuf, count, dtype, + op, llroot, llcomm); + } } exit: