Skip to content

Commit a43ab4c

Browse files
authored
Merge pull request #2417 from ggouaillardet/topic/v2.x/coll_base_comm_get_reqs_zero
v2.x: coll: fix coll_base_comm_get_reqs usage
2 parents 64d5539 + b044f20 commit a43ab4c

11 files changed

+63
-57
lines changed

ompi/mca/coll/base/coll_base_alltoall.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
4141
struct ompi_communicator_t *comm,
4242
mca_coll_base_module_t *module)
4343
{
44-
mca_coll_base_module_t *base_module = (mca_coll_base_module_t*) module;
4544
int i, j, size, rank, err = MPI_SUCCESS, line;
4645
OPAL_PTRDIFF_TYPE ext, gap;
47-
MPI_Request *preq, *reqs;
46+
ompi_request_t *req;
4847
char *tmp_buffer;
4948
size_t max_size;
5049

@@ -63,8 +62,6 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
6362
max_size = opal_datatype_span(&rdtype->super, rcount, &gap);
6463

6564
/* Initiate all send/recv to/from others. */
66-
reqs = coll_base_comm_get_reqs(base_module->base_data, 2);
67-
if( NULL == reqs ) { err = OMPI_ERR_OUT_OF_RESOURCE; line = __LINE__; goto error_hndl; }
6865

6966
/* Allocate a temporary buffer */
7067
tmp_buffer = calloc (max_size, 1);
@@ -77,8 +74,6 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
7774
/* in-place alltoall slow algorithm (but works) */
7875
for (i = 0 ; i < size ; ++i) {
7976
for (j = i+1 ; j < size ; ++j) {
80-
preq = reqs;
81-
8277
if (i == rank) {
8378
/* Copy the data into the temporary buffer */
8479
err = ompi_datatype_copy_content_same_ddt (rdtype, rcount, tmp_buffer,
@@ -87,12 +82,12 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
8782

8883
/* Exchange data with the peer */
8984
err = MCA_PML_CALL(irecv ((char *) rbuf + max_size * j, rcount, rdtype,
90-
j, MCA_COLL_BASE_TAG_ALLTOALL, comm, preq++));
85+
j, MCA_COLL_BASE_TAG_ALLTOALL, comm, &req));
9186
if (MPI_SUCCESS != err) { line = __LINE__; goto error_hndl; }
9287

93-
err = MCA_PML_CALL(isend ((char *) tmp_buffer, rcount, rdtype,
88+
err = MCA_PML_CALL(send ((char *) tmp_buffer, rcount, rdtype,
9489
j, MCA_COLL_BASE_TAG_ALLTOALL, MCA_PML_BASE_SEND_STANDARD,
95-
comm, preq++));
90+
comm));
9691
if (MPI_SUCCESS != err) { line = __LINE__; goto error_hndl; }
9792
} else if (j == rank) {
9893
/* Copy the data into the temporary buffer */
@@ -102,19 +97,19 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
10297

10398
/* Exchange data with the peer */
10499
err = MCA_PML_CALL(irecv ((char *) rbuf + max_size * i, rcount, rdtype,
105-
i, MCA_COLL_BASE_TAG_ALLTOALL, comm, preq++));
100+
i, MCA_COLL_BASE_TAG_ALLTOALL, comm, &req));
106101
if (MPI_SUCCESS != err) { line = __LINE__; goto error_hndl; }
107102

108-
err = MCA_PML_CALL(isend ((char *) tmp_buffer, rcount, rdtype,
103+
err = MCA_PML_CALL(send ((char *) tmp_buffer, rcount, rdtype,
109104
i, MCA_COLL_BASE_TAG_ALLTOALL, MCA_PML_BASE_SEND_STANDARD,
110-
comm, preq++));
105+
comm));
111106
if (MPI_SUCCESS != err) { line = __LINE__; goto error_hndl; }
112107
} else {
113108
continue;
114109
}
115110

116111
/* Wait for the requests to complete */
117-
err = ompi_request_wait_all (2, reqs, MPI_STATUSES_IGNORE);
112+
err = ompi_request_wait ( &req, MPI_STATUSES_IGNORE);
118113
if (MPI_SUCCESS != err) { line = __LINE__; goto error_hndl; }
119114
}
120115
}
@@ -127,7 +122,7 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
127122
OPAL_OUTPUT((ompi_coll_base_framework.framework_output,
128123
"%s:%4d\tError occurred %d, rank %2d", __FILE__, line, err,
129124
rank));
130-
ompi_coll_base_free_reqs(reqs, 2);
125+
(void)line; // silence compiler warning
131126
}
132127

133128
/* All done */
@@ -393,8 +388,10 @@ int ompi_coll_base_alltoall_intra_linear_sync(const void *sbuf, int scount,
393388
total_reqs = (((max_outstanding_reqs > (size - 1)) ||
394389
(max_outstanding_reqs <= 0)) ?
395390
(size - 1) : (max_outstanding_reqs));
396-
reqs = coll_base_comm_get_reqs(module->base_data, 2 * total_reqs);
397-
if (NULL == reqs) { error = -1; line = __LINE__; goto error_hndl; }
391+
if (0 < total_reqs) {
392+
reqs = coll_base_comm_get_reqs(module->base_data, 2 * total_reqs);
393+
if (NULL == reqs) { error = -1; line = __LINE__; goto error_hndl; }
394+
}
398395

399396
prcv = (char *) rbuf;
400397
psnd = (char *) sbuf;

ompi/mca/coll/base/coll_base_alltoallv.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
4242
struct ompi_communicator_t *comm,
4343
mca_coll_base_module_t *module)
4444
{
45-
mca_coll_base_module_t *base_module = (mca_coll_base_module_t*) module;
4645
int i, j, size, rank, err=MPI_SUCCESS;
47-
ompi_request_t **preq, **reqs;
46+
ompi_request_t *req;
4847
char *allocated_buffer, *tmp_buffer;
4948
size_t max_size, rdtype_size;
5049
OPAL_PTRDIFF_TYPE ext, gap;
@@ -76,14 +75,9 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
7675
tmp_buffer = allocated_buffer - gap;
7776

7877
/* Initiate all send/recv to/from others. */
79-
reqs = preq = coll_base_comm_get_reqs(base_module->base_data, 2);
80-
if( NULL == reqs ) { err = OMPI_ERR_OUT_OF_RESOURCE; goto error_hndl; }
81-
8278
/* in-place alltoallv slow algorithm (but works) */
8379
for (i = 0 ; i < size ; ++i) {
8480
for (j = i+1 ; j < size ; ++j) {
85-
preq = reqs;
86-
8781
if (i == rank && rcounts[j]) {
8882
/* Copy the data into the temporary buffer */
8983
err = ompi_datatype_copy_content_same_ddt (rdtype, rcounts[j],
@@ -92,12 +86,12 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
9286

9387
/* Exchange data with the peer */
9488
err = MCA_PML_CALL(irecv ((char *) rbuf + rdisps[j] * ext, rcounts[j], rdtype,
95-
j, MCA_COLL_BASE_TAG_ALLTOALLV, comm, preq++));
89+
j, MCA_COLL_BASE_TAG_ALLTOALLV, comm, &req));
9690
if (MPI_SUCCESS != err) { goto error_hndl; }
9791

98-
err = MCA_PML_CALL(isend ((void *) tmp_buffer, rcounts[j], rdtype,
92+
err = MCA_PML_CALL(send ((void *) tmp_buffer, rcounts[j], rdtype,
9993
j, MCA_COLL_BASE_TAG_ALLTOALLV, MCA_PML_BASE_SEND_STANDARD,
100-
comm, preq++));
94+
comm));
10195
if (MPI_SUCCESS != err) { goto error_hndl; }
10296
} else if (j == rank && rcounts[i]) {
10397
/* Copy the data into the temporary buffer */
@@ -107,29 +101,26 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
107101

108102
/* Exchange data with the peer */
109103
err = MCA_PML_CALL(irecv ((char *) rbuf + rdisps[i] * ext, rcounts[i], rdtype,
110-
i, MCA_COLL_BASE_TAG_ALLTOALLV, comm, preq++));
104+
i, MCA_COLL_BASE_TAG_ALLTOALLV, comm, &req));
111105
if (MPI_SUCCESS != err) { goto error_hndl; }
112106

113-
err = MCA_PML_CALL(isend ((void *) tmp_buffer, rcounts[i], rdtype,
107+
err = MCA_PML_CALL(send ((void *) tmp_buffer, rcounts[i], rdtype,
114108
i, MCA_COLL_BASE_TAG_ALLTOALLV, MCA_PML_BASE_SEND_STANDARD,
115-
comm, preq++));
109+
comm));
116110
if (MPI_SUCCESS != err) { goto error_hndl; }
117111
} else {
118112
continue;
119113
}
120114

121115
/* Wait for the requests to complete */
122-
err = ompi_request_wait_all (2, reqs, MPI_STATUSES_IGNORE);
116+
err = ompi_request_wait (&req, MPI_STATUSES_IGNORE);
123117
if (MPI_SUCCESS != err) { goto error_hndl; }
124118
}
125119
}
126120

127121
error_hndl:
128122
/* Free the temporary buffer */
129123
free (allocated_buffer);
130-
if( MPI_SUCCESS != err ) {
131-
ompi_coll_base_free_reqs(reqs, 2 );
132-
}
133124

134125
/* All done */
135126
return err;

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
@@ -610,6 +612,8 @@ ompi_coll_base_bcast_intra_basic_linear(void *buff, int count,
610612

611613
OPAL_OUTPUT((ompi_coll_base_framework.framework_output,"ompi_coll_base_bcast_intra_basic_linear rank %d root %d", rank, root));
612614

615+
if (1 == size) return OMPI_SUCCESS;
616+
613617
/* Non-root receive the data. */
614618

615619
if (rank != root) {

ompi/mca/coll/base/coll_base_reduce.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ int ompi_coll_base_reduce_generic( const void* sendbuf, void* recvbuf, int origi
168168
if there are no requests reqs[inbi ^1] will be
169169
MPI_REQUEST_NULL. */
170170
/* wait on data from last child for previous segment */
171-
ret = ompi_request_wait_all( 1, &reqs[inbi ^ 1],
172-
MPI_STATUSES_IGNORE );
171+
ret = ompi_request_wait(&reqs[inbi ^ 1],
172+
MPI_STATUSES_IGNORE );
173173
if (ret != MPI_SUCCESS) { line = __LINE__; goto error_hndl; }
174174
local_op_buffer = inbuf[inbi ^ 1];
175175
if( i > 0 ) {

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_alltoallw.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con
4242
mca_coll_base_module_t *module)
4343
{
4444
int i, j, size, rank, err = MPI_SUCCESS, max_size;
45-
MPI_Request *preq, *reqs = NULL;
45+
ompi_request_t *req;
4646
char *tmp_buffer, *save_buffer = NULL;
4747
ptrdiff_t ext, gap;
4848

@@ -70,9 +70,6 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con
7070
}
7171
tmp_buffer -= gap;
7272

73-
reqs = coll_base_comm_get_reqs( module->base_data, 2);
74-
if( NULL == reqs ) { err = OMPI_ERR_OUT_OF_RESOURCE; goto error_hndl; }
75-
7673
/* in-place alltoallw slow algorithm (but works) */
7774
for (i = 0 ; i < size ; ++i) {
7875
size_t msg_size_i;
@@ -84,8 +81,6 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con
8481
msg_size_j *= rcounts[j];
8582

8683
/* Initiate all send/recv to/from others. */
87-
preq = reqs;
88-
8984
if (i == rank && msg_size_j != 0) {
9085
/* Copy the data into the temporary buffer */
9186
err = ompi_datatype_copy_content_same_ddt (rdtypes[j], rcounts[j],
@@ -94,12 +89,12 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con
9489

9590
/* Exchange data with the peer */
9691
err = MCA_PML_CALL(irecv ((char *) rbuf + rdisps[j], rcounts[j], rdtypes[j],
97-
j, MCA_COLL_BASE_TAG_ALLTOALLW, comm, preq++));
92+
j, MCA_COLL_BASE_TAG_ALLTOALLW, comm, &req));
9893
if (MPI_SUCCESS != err) { goto error_hndl; }
9994

100-
err = MCA_PML_CALL(isend ((void *) tmp_buffer, rcounts[j], rdtypes[j],
95+
err = MCA_PML_CALL(send ((void *) tmp_buffer, rcounts[j], rdtypes[j],
10196
j, MCA_COLL_BASE_TAG_ALLTOALLW, MCA_PML_BASE_SEND_STANDARD,
102-
comm, preq++));
97+
comm));
10398
if (MPI_SUCCESS != err) { goto error_hndl; }
10499
} else if (j == rank && msg_size_i != 0) {
105100
/* Copy the data into the temporary buffer */
@@ -109,31 +104,26 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con
109104

110105
/* Exchange data with the peer */
111106
err = MCA_PML_CALL(irecv ((char *) rbuf + rdisps[i], rcounts[i], rdtypes[i],
112-
i, MCA_COLL_BASE_TAG_ALLTOALLW, comm, preq++));
107+
i, MCA_COLL_BASE_TAG_ALLTOALLW, comm, &req));
113108
if (MPI_SUCCESS != err) { goto error_hndl; }
114109

115-
err = MCA_PML_CALL(isend ((void *) tmp_buffer, rcounts[i], rdtypes[i],
110+
err = MCA_PML_CALL(send ((void *) tmp_buffer, rcounts[i], rdtypes[i],
116111
i, MCA_COLL_BASE_TAG_ALLTOALLW, MCA_PML_BASE_SEND_STANDARD,
117-
comm, preq++));
112+
comm));
118113
if (MPI_SUCCESS != err) { goto error_hndl; }
119114
} else {
120115
continue;
121116
}
122117

123118
/* Wait for the requests to complete */
124-
err = ompi_request_wait_all (2, reqs, MPI_STATUSES_IGNORE);
119+
err = ompi_request_wait (&req, MPI_STATUSES_IGNORE);
125120
if (MPI_SUCCESS != err) { goto error_hndl; }
126121
}
127122
}
128123

129124
error_hndl:
130125
/* Free the temporary buffer */
131126
free (save_buffer);
132-
if( MPI_SUCCESS != err ) { /* Free the requests. */
133-
if( NULL != reqs ) {
134-
ompi_coll_base_free_reqs(reqs, 2);
135-
}
136-
}
137127

138128
/* All done */
139129

ompi/mca/coll/basic/coll_basic_neighbor_allgather.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ mca_coll_basic_neighbor_allgather_cart(const void *sbuf, int scount,
4848
ptrdiff_t lb, extent;
4949
int rc = MPI_SUCCESS, dim, nreqs;
5050

51+
if( 0 == cart->ndims ) return OMPI_SUCCESS;
52+
5153
ompi_datatype_get_extent(rdtype, &lb, &extent);
5254

5355
reqs = preqs = coll_base_comm_get_reqs( module->base_data, 4 * cart->ndims );
@@ -129,6 +131,7 @@ mca_coll_basic_neighbor_allgather_graph(const void *sbuf, int scount,
129131
int rc = MPI_SUCCESS, neighbor;
130132

131133
mca_topo_base_graph_neighbors_count (comm, rank, &degree);
134+
if( 0 == degree) return OMPI_SUCCESS;
132135

133136
edges = graph->edges;
134137
if (rank > 0) {
@@ -181,6 +184,7 @@ mca_coll_basic_neighbor_allgather_dist_graph(const void *sbuf, int scount,
181184

182185
indegree = dist_graph->indegree;
183186
outdegree = dist_graph->outdegree;
187+
if( 0 == (indegree + outdegree) ) return OMPI_SUCCESS;
184188

185189
inedges = dist_graph->in;
186190
outedges = dist_graph->out;

ompi/mca/coll/basic/coll_basic_neighbor_allgatherv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ mca_coll_basic_neighbor_allgatherv_cart(const void *sbuf, int scount, struct omp
4747
ptrdiff_t lb, extent;
4848
int rc = MPI_SUCCESS, dim, i, nreqs;
4949

50+
if( 0 == cart->ndims ) return OMPI_SUCCESS;
51+
5052
ompi_datatype_get_extent(rdtype, &lb, &extent);
5153

5254
reqs = preqs = coll_base_comm_get_reqs( module->base_data, 4 * cart->ndims);
@@ -116,6 +118,7 @@ mca_coll_basic_neighbor_allgatherv_graph(const void *sbuf, int scount, struct om
116118
ptrdiff_t lb, extent;
117119

118120
mca_topo_base_graph_neighbors_count (comm, rank, &degree);
121+
if( 0 == degree ) return OMPI_SUCCESS;
119122

120123
edges = graph->edges;
121124
if (rank > 0) {
@@ -166,6 +169,7 @@ mca_coll_basic_neighbor_allgatherv_dist_graph(const void *sbuf, int scount, stru
166169

167170
indegree = dist_graph->indegree;
168171
outdegree = dist_graph->outdegree;
172+
if( 0 == (indegree + outdegree) ) return OMPI_SUCCESS;
169173

170174
inedges = dist_graph->in;
171175
outedges = dist_graph->out;

ompi/mca/coll/basic/coll_basic_neighbor_alltoall.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ mca_coll_basic_neighbor_alltoall_cart(const void *sbuf, int scount, struct ompi_
4646
ptrdiff_t lb, rdextent, sdextent;
4747
int rc = MPI_SUCCESS, dim, nreqs;
4848

49+
if( 0 == cart->ndims ) return OMPI_SUCCESS;
50+
4951
ompi_datatype_get_extent(rdtype, &lb, &rdextent);
5052
ompi_datatype_get_extent(sdtype, &lb, &sdextent);
5153
reqs = preqs = coll_base_comm_get_reqs( module->base_data, 4 * cart->ndims);
@@ -146,6 +148,7 @@ mca_coll_basic_neighbor_alltoall_graph(const void *sbuf, int scount, struct ompi
146148
const int *edges;
147149

148150
mca_topo_base_graph_neighbors_count (comm, rank, &degree);
151+
if( 0 == degree ) return OMPI_SUCCESS;
149152

150153
edges = graph->edges;
151154
if (rank > 0) {
@@ -205,6 +208,7 @@ mca_coll_basic_neighbor_alltoall_dist_graph(const void *sbuf, int scount,struct
205208

206209
indegree = dist_graph->indegree;
207210
outdegree = dist_graph->outdegree;
211+
if( 0 == (indegree + outdegree) ) return OMPI_SUCCESS;
208212

209213
inedges = dist_graph->in;
210214
outedges = dist_graph->out;

ompi/mca/coll/basic/coll_basic_neighbor_alltoallv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ mca_coll_basic_neighbor_alltoallv_cart(const void *sbuf, const int scounts[], co
4747
ptrdiff_t lb, rdextent, sdextent;
4848
ompi_request_t **reqs, **preqs;
4949

50+
if( 0 == cart->ndims ) return OMPI_SUCCESS;
51+
5052
ompi_datatype_get_extent(rdtype, &lb, &rdextent);
5153
ompi_datatype_get_extent(sdtype, &lb, &sdextent);
5254
reqs = preqs = coll_base_comm_get_reqs( module->base_data, 4 * cart->ndims );
@@ -133,6 +135,7 @@ mca_coll_basic_neighbor_alltoallv_graph(const void *sbuf, const int scounts[], c
133135
const int *edges;
134136

135137
mca_topo_base_graph_neighbors_count (comm, rank, &degree);
138+
if( 0 == degree ) return OMPI_SUCCESS;
136139

137140
edges = graph->edges;
138141
if (rank > 0) {
@@ -191,6 +194,7 @@ mca_coll_basic_neighbor_alltoallv_dist_graph(const void *sbuf, const int scounts
191194

192195
indegree = dist_graph->indegree;
193196
outdegree = dist_graph->outdegree;
197+
if( 0 == (indegree + outdegree) ) return OMPI_SUCCESS;
194198

195199
inedges = dist_graph->in;
196200
outedges = dist_graph->out;

0 commit comments

Comments
 (0)