From 67b70bb47a0a9bfc8cd04dbd7348cde793d1bb63 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Fri, 12 Jun 2015 16:16:53 -0400 Subject: [PATCH] Add multi-threaded support. --- ompi/mca/pml/ob1/pml_ob1_irecv.c | 20 +++++++++++++------- ompi/mca/pml/ob1/pml_ob1_isend.c | 21 +++++++++++++-------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/ompi/mca/pml/ob1/pml_ob1_irecv.c b/ompi/mca/pml/ob1/pml_ob1_irecv.c index d06fe09c10..5efa089757 100644 --- a/ompi/mca/pml/ob1/pml_ob1_irecv.c +++ b/ompi/mca/pml/ob1/pml_ob1_irecv.c @@ -94,15 +94,21 @@ int mca_pml_ob1_recv(void *addr, struct ompi_communicator_t *comm, ompi_status_public_t * status) { - mca_pml_ob1_recv_request_t *recvreq = mca_pml_ob1_recvreq; + mca_pml_ob1_recv_request_t *recvreq = NULL; int rc; - if( NULL == recvreq ) { - MCA_PML_OB1_RECV_REQUEST_ALLOC(recvreq); - if (NULL == recvreq) - return OMPI_ERR_TEMP_OUT_OF_RESOURCE; - mca_pml_ob1_recvreq = recvreq; - } +#if !OPAL_ENABLE_MULTI_THREADS + recvreq = mca_pml_ob1_recvreq; + if( OPAL_UNLIKELY(NULL == recvreq) ) +#endif /* !OPAL_ENABLE_MULTI_THREADS */ + { + MCA_PML_OB1_RECV_REQUEST_ALLOC(recvreq); + if (NULL == recvreq) + return OMPI_ERR_TEMP_OUT_OF_RESOURCE; +#if !OPAL_ENABLE_MULTI_THREADS + mca_pml_ob1_recvreq = recvreq; +#endif /* !OPAL_ENABLE_MULTI_THREADS */ + } OBJ_CONSTRUCT(recvreq, mca_pml_ob1_recv_request_t); MCA_PML_OB1_RECV_REQUEST_INIT(recvreq, addr, count, datatype, diff --git a/ompi/mca/pml/ob1/pml_ob1_isend.c b/ompi/mca/pml/ob1/pml_ob1_isend.c index 3093e70bb8..982eb1a2df 100644 --- a/ompi/mca/pml/ob1/pml_ob1_isend.c +++ b/ompi/mca/pml/ob1/pml_ob1_isend.c @@ -183,7 +183,7 @@ int mca_pml_ob1_send(void *buf, ompi_proc_t *dst_proc = ompi_comm_peer_lookup (comm, dst); mca_bml_base_endpoint_t* endpoint = (mca_bml_base_endpoint_t*) dst_proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_BML]; - mca_pml_ob1_send_request_t *sendreq = mca_pml_ob1_sendreq; + mca_pml_ob1_send_request_t *sendreq = NULL; int16_t seqn; int rc; @@ -220,13 +220,18 @@ int mca_pml_ob1_send(void *buf, } } - if( NULL == sendreq ) { - MCA_PML_OB1_SEND_REQUEST_ALLOC(comm, dst, sendreq); - if (NULL == sendreq) - return OMPI_ERR_TEMP_OUT_OF_RESOURCE; - mca_pml_ob1_sendreq = sendreq; - } - +#if !OPAL_ENABLE_MULTI_THREADS + sendreq = mca_pml_ob1_sendreq; + if( OPAL_UNLIKELY(NULL == sendreq) ) +#endif /* !OPAL_ENABLE_MULTI_THREADS */ + { + MCA_PML_OB1_SEND_REQUEST_ALLOC(comm, dst, sendreq); + if (NULL == sendreq) + return OMPI_ERR_TEMP_OUT_OF_RESOURCE; +#if !OPAL_ENABLE_MULTI_THREADS + mca_pml_ob1_sendreq = sendreq; +#endif /* !OPAL_ENABLE_MULTI_THREADS */ + } OBJ_CONSTRUCT(sendreq, mca_pml_ob1_send_request_t); sendreq->req_send.req_base.req_proc = dst_proc; sendreq->rdma_frag = NULL;