Skip to content

Commit 535358e

Browse files
authored
Merge pull request #8897 from ggouaillardet/topic/v4.1.x/sendrecv_replace_big
v4.1.x: Fix handling of large data in MPI_Sendrecv_replace
2 parents e6b751e + 35b0a1f commit 535358e

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

ompi/mpi/c/sendrecv_replace.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2010-2012 Oracle and/or its affiliates. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
14-
* and Technology (RIST). All rights reserved.
13+
* Copyright (c) 2015-2021 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1616
* $COPYRIGHT$
1717
*
@@ -47,6 +47,7 @@ int MPI_Sendrecv_replace(void * buf, int count, MPI_Datatype datatype,
4747
MPI_Comm comm, MPI_Status *status)
4848

4949
{
50+
ompi_request_t* req;
5051
int rc = MPI_SUCCESS;
5152

5253
SPC_RECORD(OMPI_SPC_SENDRECV_REPLACE, 1);
@@ -100,19 +101,18 @@ int MPI_Sendrecv_replace(void * buf, int count, MPI_Datatype datatype,
100101
struct iovec iov = { .iov_base = packed_data, .iov_len = sizeof(packed_data) };
101102
size_t packed_size, max_data;
102103
uint32_t iov_count;
103-
ompi_status_public_t recv_status;
104104
ompi_proc_t* proc = ompi_comm_peer_lookup(comm, dest);
105105
if(proc == NULL) {
106106
rc = MPI_ERR_RANK;
107107
OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);
108108
}
109109

110-
/* initialize convertor to unpack recv buffer */
110+
/* initialize convertor to pack send buffer */
111111
OBJ_CONSTRUCT(&convertor, opal_convertor_t);
112112
opal_convertor_copy_and_prepare_for_send( proc->super.proc_convertor, &(datatype->super),
113113
count, buf, 0, &convertor );
114114

115-
/* setup a buffer for recv */
115+
/* setup a temporary buffer to send */
116116
opal_convertor_get_packed_size( &convertor, &packed_size );
117117
if( packed_size > sizeof(packed_data) ) {
118118
rc = PMPI_Alloc_mem(packed_size, MPI_INFO_NULL, &iov.iov_base);
@@ -124,18 +124,26 @@ int MPI_Sendrecv_replace(void * buf, int count, MPI_Datatype datatype,
124124
}
125125
max_data = packed_size;
126126
iov_count = 1;
127-
rc = opal_convertor_pack(&convertor, &iov, &iov_count, &max_data);
128-
129-
/* recv into temporary buffer */
130-
rc = PMPI_Sendrecv( iov.iov_base, packed_size, MPI_PACKED, dest, sendtag, buf, count,
131-
datatype, source, recvtag, comm, &recv_status );
127+
(void)opal_convertor_pack(&convertor, &iov, &iov_count, &max_data);
132128

133-
cleanup_and_return:
134-
/* return status to user */
135-
if(status != MPI_STATUS_IGNORE) {
136-
*status = recv_status;
129+
/* receive into the buffer */
130+
rc = MCA_PML_CALL(irecv(buf, count, datatype,
131+
source, recvtag, comm, &req));
132+
if(OMPI_SUCCESS != rc) {
133+
goto cleanup_and_return;
134+
}
135+
136+
/* send from the temporary buffer */
137+
rc = MCA_PML_CALL(send(iov.iov_base, packed_size, MPI_PACKED, dest,
138+
sendtag, MCA_PML_BASE_SEND_STANDARD, comm));
139+
if(OMPI_SUCCESS != rc) {
140+
goto cleanup_and_return;
137141
}
138142

143+
rc = ompi_request_wait(&req, status);
144+
145+
cleanup_and_return:
146+
139147
/* release resources */
140148
if(packed_size > sizeof(packed_data)) {
141149
PMPI_Free_mem(iov.iov_base);

0 commit comments

Comments
 (0)