Skip to content

Commit 5fabe48

Browse files
committed
Merge pull request open-mpi#625 from hppritcha/topic/patch_pml_ob1_isend
Topic/patch pml ob1 isend
2 parents 5c9b192 + e2e6592 commit 5fabe48

File tree

5 files changed

+77
-44
lines changed

5 files changed

+77
-44
lines changed

ompi/mca/pml/ob1/pml_ob1_component.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,18 @@ int mca_pml_ob1_component_fini(void)
292292
return OMPI_SUCCESS; /* never selected.. return success.. */
293293
mca_pml_ob1.enabled = false; /* not anymore */
294294

295+
/* return the static receive/send requests to the respective free list and
296+
* let the free list handle destruction. */
297+
if( NULL != mca_pml_ob1_recvreq ) {
298+
opal_free_list_return (&mca_pml_base_recv_requests, (opal_free_list_item_t *) mca_pml_ob1_recvreq);
299+
mca_pml_ob1_recvreq = NULL;
300+
}
301+
302+
if( NULL != mca_pml_ob1_sendreq ) {
303+
opal_free_list_return (&mca_pml_base_send_requests, (opal_free_list_item_t *) mca_pml_ob1_sendreq);
304+
mca_pml_ob1_sendreq = NULL;
305+
}
306+
295307
OBJ_DESTRUCT(&mca_pml_ob1.rdma_pending);
296308
OBJ_DESTRUCT(&mca_pml_ob1.pckt_pending);
297309
OBJ_DESTRUCT(&mca_pml_ob1.recv_pending);
@@ -304,15 +316,6 @@ int mca_pml_ob1_component_fini(void)
304316
OBJ_DESTRUCT(&mca_pml_ob1.lock);
305317
OBJ_DESTRUCT(&mca_pml_ob1.send_ranges);
306318

307-
if( NULL != mca_pml_ob1_recvreq ) {
308-
OBJ_DESTRUCT(mca_pml_ob1_recvreq);
309-
mca_pml_ob1_recvreq = NULL;
310-
}
311-
if( NULL != mca_pml_ob1_sendreq ) {
312-
OBJ_DESTRUCT(mca_pml_ob1_sendreq);
313-
mca_pml_ob1_sendreq = NULL;
314-
}
315-
316319
if( NULL != mca_pml_ob1.allocator ) {
317320
(void)mca_pml_ob1.allocator->alc_finalize(mca_pml_ob1.allocator);
318321
mca_pml_ob1.allocator = NULL;

ompi/mca/pml/ob1/pml_ob1_irecv.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2014 The University of Tennessee and The University
6+
* Copyright (c) 2004-2015 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
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) 2007-2014 Los Alamos National Security, LLC. All rights
13+
* Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights
1414
* reserved.
1515
* Copyright (c) 2010-2012 Oracle and/or its affiliates. All rights reserved.
1616
* Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
@@ -28,10 +28,14 @@
2828
#include "pml_ob1_recvfrag.h"
2929
#include "ompi/peruse/peruse-internal.h"
3030
#include "ompi/message/message.h"
31-
#if HAVE_ALLOCA_H
32-
#include <alloca.h>
33-
#endif /* HAVE_ALLOCA_H */
3431

32+
/**
33+
* Single usage request. As we allow recursive calls to recv
34+
* (from the request completion callback), we cannot rely on
35+
* using a global request. Thus, once a recv acquires ownership
36+
* this global request, it should set it to NULL to prevent
37+
* the reuse until the first user completes.
38+
*/
3539
mca_pml_ob1_recv_request_t *mca_pml_ob1_recvreq = NULL;
3640

3741
int mca_pml_ob1_irecv_init(void *addr,
@@ -97,19 +101,16 @@ int mca_pml_ob1_recv(void *addr,
97101
mca_pml_ob1_recv_request_t *recvreq = NULL;
98102
int rc;
99103

100-
#if !OPAL_ENABLE_MULTI_THREADS
104+
#if !OMPI_ENABLE_THREAD_MULTIPLE
101105
recvreq = mca_pml_ob1_recvreq;
106+
mca_pml_ob1_recvreq = NULL;
102107
if( OPAL_UNLIKELY(NULL == recvreq) )
103-
#endif /* !OPAL_ENABLE_MULTI_THREADS */
108+
#endif /* !OMPI_ENABLE_THREAD_MULTIPLE */
104109
{
105110
MCA_PML_OB1_RECV_REQUEST_ALLOC(recvreq);
106111
if (NULL == recvreq)
107112
return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
108-
#if !OPAL_ENABLE_MULTI_THREADS
109-
mca_pml_ob1_recvreq = recvreq;
110-
#endif /* !OPAL_ENABLE_MULTI_THREADS */
111113
}
112-
OBJ_CONSTRUCT(recvreq, mca_pml_ob1_recv_request_t);
113114

114115
MCA_PML_OB1_RECV_REQUEST_INIT(recvreq, addr, count, datatype,
115116
src, tag, comm, false);
@@ -126,8 +127,17 @@ int mca_pml_ob1_recv(void *addr,
126127
}
127128

128129
rc = recvreq->req_recv.req_base.req_ompi.req_status.MPI_ERROR;
129-
MCA_PML_BASE_RECV_REQUEST_FINI(&recvreq->req_recv);
130-
OBJ_DESTRUCT(recvreq);
130+
131+
#if OMPI_ENABLE_THREAD_MULTIPLE
132+
MCA_PML_OB1_RECV_REQUEST_RETURN(recvreq);
133+
#else
134+
if( NULL != mca_pml_ob1_recvreq ) {
135+
MCA_PML_OB1_RECV_REQUEST_RETURN(recvreq);
136+
} else {
137+
mca_pml_ob1_recv_request_fini (recvreq);
138+
mca_pml_ob1_recvreq = recvreq;
139+
}
140+
#endif
131141

132142
return rc;
133143
}

ompi/mca/pml/ob1/pml_ob1_isend.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@
2828
#include "pml_ob1_sendreq.h"
2929
#include "pml_ob1_recvreq.h"
3030
#include "ompi/peruse/peruse-internal.h"
31-
#if HAVE_ALLOCA_H
32-
#include <alloca.h>
33-
#endif /* HAVE_ALLOCA_H */
3431

32+
/**
33+
* Single usage request. As we allow recursive calls (as an
34+
* example from the request completion callback), we cannot rely
35+
* on using a global request. Thus, once a send acquires ownership
36+
* of this global request, it should set it to NULL to prevent
37+
* the reuse until the first user completes.
38+
*/
3539
mca_pml_ob1_send_request_t *mca_pml_ob1_sendreq = NULL;
3640

3741
int mca_pml_ob1_isend_init(const void *buf,
@@ -220,19 +224,16 @@ int mca_pml_ob1_send(const void *buf,
220224
}
221225
}
222226

223-
#if !OPAL_ENABLE_MULTI_THREADS
227+
#if !OMPI_ENABLE_THREAD_MULTIPLE
224228
sendreq = mca_pml_ob1_sendreq;
229+
mca_pml_ob1_sendreq = NULL;
225230
if( OPAL_UNLIKELY(NULL == sendreq) )
226-
#endif /* !OPAL_ENABLE_MULTI_THREADS */
231+
#endif /* !OMPI_ENABLE_THREAD_MULTIPLE */
227232
{
228233
MCA_PML_OB1_SEND_REQUEST_ALLOC(comm, dst, sendreq);
229234
if (NULL == sendreq)
230235
return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
231-
#if !OPAL_ENABLE_MULTI_THREADS
232-
mca_pml_ob1_sendreq = sendreq;
233-
#endif /* !OPAL_ENABLE_MULTI_THREADS */
234236
}
235-
OBJ_CONSTRUCT(sendreq, mca_pml_ob1_send_request_t);
236237
sendreq->req_send.req_base.req_proc = dst_proc;
237238
sendreq->rdma_frag = NULL;
238239

@@ -252,9 +253,18 @@ int mca_pml_ob1_send(const void *buf,
252253
ompi_request_wait_completion(&sendreq->req_send.req_base.req_ompi);
253254

254255
rc = sendreq->req_send.req_base.req_ompi.req_status.MPI_ERROR;
255-
MCA_PML_BASE_SEND_REQUEST_FINI(&sendreq->req_send);
256256
}
257-
OBJ_DESTRUCT(sendreq);
257+
258+
#if OMPI_ENABLE_THREAD_MULTIPLE
259+
MCA_PML_OB1_SEND_REQUEST_RETURN(sendreq);
260+
#else
261+
if( NULL != mca_pml_ob1_sendreq ) {
262+
MCA_PML_OB1_SEND_REQUEST_RETURN(sendreq);
263+
} else {
264+
mca_pml_ob1_send_request_fini (sendreq);
265+
mca_pml_ob1_sendreq = sendreq;
266+
}
267+
#endif
258268

259269
return rc;
260270
}

ompi/mca/pml/ob1/pml_ob1_recvreq.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,21 @@ do { \
128128
ompi_request_complete( &(recvreq->req_recv.req_base.req_ompi), true ); \
129129
} while (0)
130130

131+
static inline void mca_pml_ob1_recv_request_fini (mca_pml_ob1_recv_request_t *recvreq)
132+
{
133+
MCA_PML_BASE_RECV_REQUEST_FINI(&recvreq->req_recv);
134+
if ((recvreq)->local_handle) {
135+
mca_bml_base_deregister_mem (recvreq->rdma_bml, recvreq->local_handle);
136+
recvreq->local_handle = NULL;
137+
}
138+
}
139+
131140
/*
132141
* Free the PML receive request
133142
*/
134143
#define MCA_PML_OB1_RECV_REQUEST_RETURN(recvreq) \
135144
{ \
136-
MCA_PML_BASE_RECV_REQUEST_FINI(&(recvreq)->req_recv); \
137-
if ((recvreq)->local_handle) { \
138-
mca_bml_base_deregister_mem ((recvreq)->rdma_bml, (recvreq)->local_handle); \
139-
(recvreq)->local_handle = NULL; \
140-
} \
145+
mca_pml_ob1_recv_request_fini (recvreq); \
141146
opal_free_list_return (&mca_pml_base_recv_requests, \
142147
(opal_free_list_item_t*)(recvreq)); \
143148
}

ompi/mca/pml/ob1/pml_ob1_sendreq.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,23 @@ do {
215215
&(sendreq->req_send.req_base), PERUSE_SEND); \
216216
} while(0)
217217

218+
static inline void mca_pml_ob1_send_request_fini (mca_pml_ob1_send_request_t *sendreq)
219+
{
220+
/* Let the base handle the reference counts */
221+
MCA_PML_BASE_SEND_REQUEST_FINI((&(sendreq)->req_send));
222+
if (sendreq->rdma_frag) {
223+
MCA_PML_OB1_RDMA_FRAG_RETURN (sendreq->rdma_frag);
224+
sendreq->rdma_frag = NULL;
225+
}
226+
}
227+
218228
/*
219229
* Release resources associated with a request
220230
*/
221231

222232
#define MCA_PML_OB1_SEND_REQUEST_RETURN(sendreq) \
223233
do { \
224-
/* Let the base handle the reference counts */ \
225-
MCA_PML_BASE_SEND_REQUEST_FINI((&(sendreq)->req_send)); \
226-
if (sendreq->rdma_frag) { \
227-
MCA_PML_OB1_RDMA_FRAG_RETURN (sendreq->rdma_frag); \
228-
sendreq->rdma_frag = NULL; \
229-
} \
234+
mca_pml_ob1_send_request_fini (sendreq); \
230235
opal_free_list_return ( &mca_pml_base_send_requests, \
231236
(opal_free_list_item_t*)sendreq); \
232237
} while(0)

0 commit comments

Comments
 (0)