11/*
22 * Copyright (C) Mellanox Technologies Ltd. 2001-2015. ALL RIGHTS RESERVED.
3- * Copyright (c) 2016 The University of Tennessee and The University
3+ * Copyright (c) 2016-2021 The University of Tennessee and The University
44 * of Tennessee Research Foundation. All rights
55 * reserved.
66 * $COPYRIGHT$
@@ -149,6 +149,12 @@ static inline void mca_pml_ucx_request_reset(ompi_request_t *req)
149149 req -> req_complete = REQUEST_PENDING ;
150150}
151151
152+ /* Use when setting a request's status field.
153+ * Note that a new function 'mca_mpl_ucx_set_send_status_public' shall
154+ * be created and used instead if updating a publicly visible status becomes
155+ * necessary (i.e., the status argument in an user-visible procedure), see the
156+ * recv_status case below for rationale.
157+ */
152158__opal_attribute_always_inline__
153159static inline void mca_pml_ucx_set_send_status (ompi_status_public_t * mpi_status ,
154160 ucs_status_t status )
@@ -163,6 +169,11 @@ static inline void mca_pml_ucx_set_send_status(ompi_status_public_t* mpi_status,
163169 }
164170}
165171
172+ /* Use when setting a request's status field.
173+ * Note that the next function 'mca_mpl_ucx_set_recv_status_public' shall
174+ * be used instead when updating a publicly visible status (i.e., the
175+ * status argument in an user-visible procedure).
176+ */
166177static inline int mca_pml_ucx_set_recv_status (ompi_status_public_t * mpi_status ,
167178 ucs_status_t ucp_status ,
168179 const ucp_tag_recv_info_t * info )
@@ -178,6 +189,10 @@ static inline int mca_pml_ucx_set_recv_status(ompi_status_public_t* mpi_status,
178189 mpi_status -> _ucount = info -> length ;
179190 } else if (ucp_status == UCS_ERR_MESSAGE_TRUNCATED ) {
180191 mpi_status -> MPI_ERROR = MPI_ERR_TRUNCATE ;
192+ mpi_status -> MPI_SOURCE = PML_UCX_TAG_GET_SOURCE (tag );
193+ mpi_status -> MPI_TAG = PML_UCX_TAG_GET_MPI_TAG (tag );
194+ mpi_status -> _cancelled = false;
195+ mpi_status -> _ucount = info -> length ;
181196 } else if (ucp_status == UCS_ERR_CANCELED ) {
182197 mpi_status -> MPI_ERROR = MPI_SUCCESS ;
183198 mpi_status -> _cancelled = true;
@@ -188,16 +203,41 @@ static inline int mca_pml_ucx_set_recv_status(ompi_status_public_t* mpi_status,
188203 return mpi_status -> MPI_ERROR ;
189204}
190205
191- static inline int mca_pml_ucx_set_recv_status_safe (ompi_status_public_t * mpi_status ,
206+ /* Use when setting a publicly visible status (i.e., the status argument in an
207+ * user-visible procedure).
208+ * Except in procedures that return MPI_ERR_IN_STATUS, the MPI_ERROR
209+ * field of a status object shall never be modified
210+ * See MPI-1.1 doc, sec 3.2.5, p.22
211+ */
212+ static inline int mca_pml_ucx_set_recv_status_public (ompi_status_public_t * mpi_status ,
192213 ucs_status_t ucp_status ,
193214 const ucp_tag_recv_info_t * info )
194215{
195216 if (mpi_status != MPI_STATUS_IGNORE ) {
196- return mca_pml_ucx_set_recv_status (mpi_status , ucp_status , info );
197- } else if (OPAL_LIKELY (ucp_status == UCS_OK ) || (ucp_status == UCS_ERR_CANCELED )) {
198- return UCS_OK ;
217+ if (OPAL_LIKELY (ucp_status == UCS_OK )) {
218+ uint64_t tag = info -> sender_tag ;
219+ mpi_status -> MPI_SOURCE = PML_UCX_TAG_GET_SOURCE (tag );
220+ mpi_status -> MPI_TAG = PML_UCX_TAG_GET_MPI_TAG (tag );
221+ mpi_status -> _cancelled = false;
222+ mpi_status -> _ucount = info -> length ;
223+ return MPI_SUCCESS ;
224+ } else if (ucp_status == UCS_ERR_MESSAGE_TRUNCATED ) {
225+ uint64_t tag = info -> sender_tag ;
226+ mpi_status -> MPI_SOURCE = PML_UCX_TAG_GET_SOURCE (tag );
227+ mpi_status -> MPI_TAG = PML_UCX_TAG_GET_MPI_TAG (tag );
228+ mpi_status -> _cancelled = false;
229+ mpi_status -> _ucount = info -> length ;
230+ return MPI_ERR_TRUNCATE ;
231+ } else if (ucp_status == UCS_ERR_CANCELED ) {
232+ mpi_status -> _cancelled = true;
233+ return MPI_SUCCESS ;
234+ } else {
235+ return MPI_ERR_INTERN ;
236+ }
199237 } else if (ucp_status == UCS_ERR_MESSAGE_TRUNCATED ) {
200238 return MPI_ERR_TRUNCATE ;
239+ } else if (OPAL_LIKELY (ucp_status == UCS_OK ) || (ucp_status == UCS_ERR_CANCELED )) {
240+ return MPI_SUCCESS ;
201241 }
202242
203243 return MPI_ERR_INTERN ;
0 commit comments