|
18 | 18 | #ifndef PML_CM_H
|
19 | 19 | #define PML_CM_H
|
20 | 20 |
|
21 |
| -#ifdef HAVE_ALLOCA_H |
22 |
| -#include <alloca.h> |
23 |
| -#endif |
24 |
| - |
25 | 21 | #include "ompi_config.h"
|
26 | 22 | #include "ompi/request/request.h"
|
27 | 23 | #include "ompi/mca/pml/pml.h"
|
@@ -144,73 +140,42 @@ mca_pml_cm_recv(void *addr,
|
144 | 140 | {
|
145 | 141 | int ret;
|
146 | 142 | uint32_t flags = 0;
|
| 143 | + mca_pml_cm_thin_recv_request_t *recvreq; |
| 144 | + |
| 145 | + MCA_PML_CM_THIN_RECV_REQUEST_ALLOC(recvreq); |
| 146 | + if (OPAL_UNLIKELY(NULL == recvreq)) |
| 147 | + return OMPI_ERR_OUT_OF_RESOURCE; |
| 148 | + |
147 | 149 | #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
|
148 |
| - ompi_proc_t *ompi_proc; |
| 150 | + ompi_proc_t *ompi_proc = NULL; |
149 | 151 | #endif
|
150 |
| - opal_convertor_t convertor; |
151 |
| - mca_pml_cm_request_t req; |
152 |
| - mca_mtl_request_t *req_mtl = |
153 |
| - alloca(sizeof(mca_mtl_request_t) + ompi_mtl->mtl_request_size); |
154 |
| - |
155 |
| - OBJ_CONSTRUCT(&convertor, opal_convertor_t); |
156 |
| - req_mtl->ompi_req = &req.req_ompi; |
157 |
| - req_mtl->completion_callback = mca_pml_cm_recv_fast_completion; |
158 |
| - |
159 |
| - req.req_pml_type = MCA_PML_CM_REQUEST_RECV_THIN; |
160 |
| - req.req_free_called = false; |
161 |
| - req.req_ompi.req_complete = false; |
162 |
| - req.req_ompi.req_complete_cb = NULL; |
163 |
| - req.req_ompi.req_state = OMPI_REQUEST_ACTIVE; |
164 |
| - req.req_ompi.req_status.MPI_TAG = OMPI_ANY_TAG; |
165 |
| - req.req_ompi.req_status.MPI_ERROR = OMPI_SUCCESS; |
166 |
| - req.req_ompi.req_status._cancelled = 0; |
167 | 152 |
|
168 |
| -#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT |
169 |
| - if( MPI_ANY_SOURCE == src ) { |
170 |
| - ompi_proc = ompi_proc_local_proc; |
171 |
| - } else { |
172 |
| - ompi_proc = ompi_comm_peer_lookup( comm, src ); |
173 |
| - } |
| 153 | + MCA_PML_CM_THIN_RECV_REQUEST_INIT(recvreq, |
| 154 | + ompi_proc, |
| 155 | + comm, |
| 156 | + src, |
| 157 | + datatype, |
| 158 | + addr, |
| 159 | + count, |
| 160 | + flags); |
174 | 161 |
|
175 |
| - MCA_PML_CM_SWITCH_ACCELERATOR_CONVERTOR_OFF(flags, datatype, count); |
176 |
| - |
177 |
| - opal_convertor_copy_and_prepare_for_recv( |
178 |
| - ompi_proc->super.proc_convertor, |
179 |
| - &(datatype->super), |
180 |
| - count, |
181 |
| - addr, |
182 |
| - flags, |
183 |
| - &convertor ); |
184 |
| -#else |
185 |
| - MCA_PML_CM_SWITCH_ACCELERATOR_CONVERTOR_OFF(flags, datatype, count); |
186 |
| - |
187 |
| - opal_convertor_copy_and_prepare_for_recv( |
188 |
| - ompi_mpi_local_convertor, |
189 |
| - &(datatype->super), |
190 |
| - count, |
191 |
| - addr, |
192 |
| - flags, |
193 |
| - &convertor ); |
194 |
| -#endif |
| 162 | + recvreq->req_mtl.completion_callback = mca_pml_cm_recv_fast_completion; |
| 163 | + assert(NULL == recvreq->req_base.req_ompi.req_complete_cb); |
195 | 164 |
|
196 |
| - ret = OMPI_MTL_CALL(irecv(ompi_mtl, |
197 |
| - comm, |
198 |
| - src, |
199 |
| - tag, |
200 |
| - &convertor, |
201 |
| - req_mtl)); |
202 |
| - if( OPAL_UNLIKELY(OMPI_SUCCESS != ret) ) { |
203 |
| - OBJ_DESTRUCT(&convertor); |
| 165 | + MCA_PML_CM_THIN_RECV_REQUEST_START(recvreq, comm, tag, src, ret); |
| 166 | + if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) { |
| 167 | + MCA_PML_CM_THIN_RECV_REQUEST_RETURN(recvreq); |
204 | 168 | return ret;
|
205 | 169 | }
|
206 | 170 |
|
207 |
| - ompi_request_wait_completion(&req.req_ompi); |
| 171 | + ompi_request_wait_completion(&recvreq->req_base.req_ompi); |
208 | 172 |
|
209 | 173 | if (MPI_STATUS_IGNORE != status) {
|
210 |
| - OMPI_COPY_STATUS(status, req.req_ompi.req_status, false); |
| 174 | + OMPI_COPY_STATUS(status, recvreq->req_base.req_ompi.req_status, false); |
211 | 175 | }
|
212 |
| - ret = req.req_ompi.req_status.MPI_ERROR; |
213 |
| - OBJ_DESTRUCT(&convertor); |
| 176 | + |
| 177 | + ret = recvreq->req_base.req_ompi.req_status.MPI_ERROR; |
| 178 | + ompi_request_free((ompi_request_t **) &recvreq); |
214 | 179 | return ret;
|
215 | 180 | }
|
216 | 181 |
|
|
0 commit comments