Skip to content

Commit 99d3035

Browse files
committed
coll: Don't allocate space for zero requests
Refs #2402 Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 725277b commit 99d3035

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

ompi/mca/coll/base/coll_base_alltoall.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,10 @@ int ompi_coll_base_alltoall_intra_linear_sync(const void *sbuf, int scount,
395395
total_reqs = (((max_outstanding_reqs > (size - 1)) ||
396396
(max_outstanding_reqs <= 0)) ?
397397
(size - 1) : (max_outstanding_reqs));
398-
reqs = coll_base_comm_get_reqs(module->base_data, 2 * total_reqs);
399-
if (NULL == reqs) { error = -1; line = __LINE__; goto error_hndl; }
398+
if (0 < total_reqs) {
399+
reqs = coll_base_comm_get_reqs(module->base_data, 2 * total_reqs);
400+
if (NULL == reqs) { error = -1; line = __LINE__; goto error_hndl; }
401+
}
400402

401403
prcv = (char *) rbuf;
402404
psnd = (char *) sbuf;

ompi/mca/coll/base/coll_base_bcast.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2012 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2012 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2016 Research Organization for Information Science
15+
* and Technology (RIST). All rights reserved.
1416
* $COPYRIGHT$
1517
*
1618
* Additional copyrights may follow
@@ -615,6 +617,8 @@ ompi_coll_base_bcast_intra_basic_linear(void *buff, int count,
615617

616618
OPAL_OUTPUT((ompi_coll_base_framework.framework_output,"ompi_coll_base_bcast_intra_basic_linear rank %d root %d", rank, root));
617619

620+
if (1 == size) return OMPI_SUCCESS;
621+
618622
/* Non-root receive the data. */
619623

620624
if (rank != root) {

ompi/mca/coll/basic/coll_basic_allreduce.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ mca_coll_basic_allreduce_inter(const void *sbuf, void *rbuf, int count,
108108
if (NULL == tmpbuf) { err = OMPI_ERR_OUT_OF_RESOURCE; line = __LINE__; goto exit; }
109109
pml_buffer = tmpbuf - gap;
110110

111-
reqs = coll_base_comm_get_reqs(module->base_data, rsize - 1);
112-
if( NULL == reqs ) { err = OMPI_ERR_OUT_OF_RESOURCE; line = __LINE__; goto exit; }
111+
if (rsize > 1) {
112+
reqs = coll_base_comm_get_reqs(module->base_data, rsize - 1);
113+
if( NULL == reqs ) { err = OMPI_ERR_OUT_OF_RESOURCE; line = __LINE__; goto exit; }
114+
}
113115

114116
/* Do a send-recv between the two root procs. to avoid deadlock */
115117
err = MCA_PML_CALL(irecv(rbuf, count, dtype, 0,

ompi/mca/coll/basic/coll_basic_neighbor_alltoallw.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* All rights reserved.
1313
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1414
* reserved.
15-
* Copyright (c) 2014-2015 Research Organization for Information Science
15+
* Copyright (c) 2014-2016 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* $COPYRIGHT$
1818
*
@@ -46,6 +46,8 @@ mca_coll_basic_neighbor_alltoallw_cart(const void *sbuf, const int scounts[], co
4646
int rc = MPI_SUCCESS, dim, i, nreqs;
4747
ompi_request_t **reqs, **preqs;
4848

49+
if (0 == cart->ndims) return OMPI_SUCCESS;
50+
4951
reqs = preqs = coll_base_comm_get_reqs( module->base_data, 4 * cart->ndims );
5052
if( NULL == reqs ) { return OMPI_ERR_OUT_OF_RESOURCE; }
5153

@@ -129,6 +131,8 @@ mca_coll_basic_neighbor_alltoallw_graph(const void *sbuf, const int scounts[], c
129131
const int *edges;
130132

131133
mca_topo_base_graph_neighbors_count (comm, rank, &degree);
134+
if (0 == degree) return OMPI_SUCCESS;
135+
132136
reqs = preqs = coll_base_comm_get_reqs( module->base_data, 2 * degree );
133137
if( NULL == reqs ) { return OMPI_ERR_OUT_OF_RESOURCE; }
134138

@@ -187,6 +191,8 @@ mca_coll_basic_neighbor_alltoallw_dist_graph(const void *sbuf, const int scounts
187191
inedges = dist_graph->in;
188192
outedges = dist_graph->out;
189193

194+
if (0 == indegree+outdegree) return OMPI_SUCCESS;
195+
190196
reqs = preqs = coll_base_comm_get_reqs( module->base_data, indegree + outdegree );
191197
if( NULL == reqs ) { return OMPI_ERR_OUT_OF_RESOURCE; }
192198

0 commit comments

Comments
 (0)