Skip to content

Commit fc776e3

Browse files
committed
coll: code cleanup
- instead of coll_base_comm_get_reqs(2) for irecv/isend, use only one request allocated in the stack and do a irecv/send - instead of ompi_request_wait_all(2), simpy ompi_request_wait Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 99d3035 commit fc776e3

File tree

4 files changed

+27
-52
lines changed

4 files changed

+27
-52
lines changed

ompi/mca/coll/base/coll_base_alltoall.c

Lines changed: 8 additions & 14 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-
ompi_request_t **preq, **reqs;
46+
ompi_request_t *req;
4847
char *allocated_buffer = NULL, *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
allocated_buffer = calloc (max_size, 1);
@@ -75,8 +72,6 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
7572
/* in-place alltoall slow algorithm (but works) */
7673
for (i = 0 ; i < size ; ++i) {
7774
for (j = i+1 ; j < size ; ++j) {
78-
preq = reqs;
79-
8075
if (i == rank) {
8176
/* Copy the data into the temporary buffer */
8277
err = ompi_datatype_copy_content_same_ddt (rdtype, rcount, tmp_buffer,
@@ -85,12 +80,12 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
8580

8681
/* Exchange data with the peer */
8782
err = MCA_PML_CALL(irecv ((char *) rbuf + max_size * j, rcount, rdtype,
88-
j, MCA_COLL_BASE_TAG_ALLTOALL, comm, preq++));
83+
j, MCA_COLL_BASE_TAG_ALLTOALL, comm, &req));
8984
if (MPI_SUCCESS != err) { line = __LINE__; goto error_hndl; }
9085

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

10196
/* Exchange data with the peer */
10297
err = MCA_PML_CALL(irecv ((char *) rbuf + max_size * i, rcount, rdtype,
103-
i, MCA_COLL_BASE_TAG_ALLTOALL, comm, preq++));
98+
i, MCA_COLL_BASE_TAG_ALLTOALL, comm, &req));
10499
if (MPI_SUCCESS != err) { line = __LINE__; goto error_hndl; }
105100

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

114109
/* Wait for the requests to complete */
115-
err = ompi_request_wait_all (2, reqs, MPI_STATUSES_IGNORE);
110+
err = ompi_request_wait ( &req, MPI_STATUSES_IGNORE);
116111
if (MPI_SUCCESS != err) { line = __LINE__; goto error_hndl; }
117112
}
118113
}
@@ -127,7 +122,6 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
127122
"%s:%4d\tError occurred %d, rank %2d", __FILE__, line, err,
128123
rank));
129124
(void)line; // silence compiler warning
130-
ompi_coll_base_free_reqs(reqs, 2);
131125
}
132126

133127
/* All done */

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 = 0;
@@ -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_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_alltoallw.c

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* Copyright (c) 2013 FUJITSU LIMITED. All rights reserved.
17-
* Copyright (c) 2014-2015 Research Organization for Information Science
17+
* Copyright (c) 2014-2016 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
1919
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
2020
* $COPYRIGHT$
@@ -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-
ompi_request_t **preq, **reqs = NULL;
45+
ompi_request_t *req;
4646
char *tmp_buffer, *save_buffer = NULL;
4747
ptrdiff_t ext, gap = 0;
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

0 commit comments

Comments
 (0)