From f0afe3829328211c20b50d3f25558e2daa0433c5 Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Thu, 17 Aug 2006 16:30:03 +0000 Subject: [PATCH] * Need to retain / release datatype and communicator so that the MPI layer handles can be freed before communication completes. This commit was SVN r11248. --- ompi/mca/pml/cm/pml_cm_recvreq.h | 20 ++++++++++++++++---- ompi/mca/pml/cm/pml_cm_sendreq.h | 16 +++++++++++----- ompi/mca/pml/cm/pml_cm_start.c | 4 ++-- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/ompi/mca/pml/cm/pml_cm_recvreq.h b/ompi/mca/pml/cm/pml_cm_recvreq.h index 4d4b318e00..067697b7ba 100644 --- a/ompi/mca/pml/cm/pml_cm_recvreq.h +++ b/ompi/mca/pml/cm/pml_cm_recvreq.h @@ -25,6 +25,8 @@ struct mca_pml_cm_thin_recv_request_t { mca_pml_cm_request_t req_base; + struct ompi_communicator_t *req_comm; /**< communicator pointer */ + struct ompi_datatype_t *req_datatype; /**< pointer to data type */ mca_mtl_request_t req_mtl; /**< the mtl specific memory */ }; typedef struct mca_pml_cm_thin_recv_request_t mca_pml_cm_thin_recv_request_t; @@ -92,6 +94,10 @@ do { \ OMPI_REQUEST_INIT(&(request)->req_base.req_ompi, false); \ (request)->req_base.req_pml_complete = false; \ (request)->req_base.req_free_called = false; \ + request->req_comm = comm; \ + request->req_datatype = datatype; \ + OBJ_RETAIN(comm); \ + OBJ_RETAIN(datatype); \ \ if( MPI_ANY_SOURCE == src ) { \ ompi_proc = ompi_proc_local_proc; \ @@ -127,6 +133,8 @@ do { \ request->req_datatype = datatype; \ request->req_addr = addr; \ request->req_count = count; \ + OBJ_RETAIN(comm); \ + OBJ_RETAIN(datatype); \ \ if( MPI_ANY_SOURCE == src ) { \ ompi_proc = ompi_proc_local_proc; \ @@ -261,8 +269,10 @@ do { \ /** * Free the PML receive request */ -#define MCA_PML_CM_HVY_RECV_REQUEST_RETURN(recvreq) \ -{ \ +#define MCA_PML_CM_HVY_RECV_REQUEST_RETURN(recvreq) \ +{ \ + OBJ_RELEASE((recvreq)->req_comm); \ + OBJ_RELEASE((recvreq)->req_datatype); \ OMPI_REQUEST_FINI(&(recvreq)->req_base.req_ompi); \ ompi_convertor_cleanup( &((recvreq)->req_base.req_convertor) ); \ OMPI_FREE_LIST_RETURN( &ompi_pml_cm.cm_hvy_recv_requests, \ @@ -272,8 +282,10 @@ do { \ /** * Free the PML receive request */ -#define MCA_PML_CM_THIN_RECV_REQUEST_RETURN(recvreq) \ -{ \ +#define MCA_PML_CM_THIN_RECV_REQUEST_RETURN(recvreq) \ +{ \ + OBJ_RELEASE((recvreq)->req_comm); \ + OBJ_RELEASE((recvreq)->req_datatype); \ OMPI_REQUEST_FINI(&(recvreq)->req_base.req_ompi); \ ompi_convertor_cleanup( &((recvreq)->req_base.req_convertor) ); \ OMPI_FREE_LIST_RETURN( &ompi_pml_cm.cm_thin_recv_requests, \ diff --git a/ompi/mca/pml/cm/pml_cm_sendreq.h b/ompi/mca/pml/cm/pml_cm_sendreq.h index b6536eac88..7d3752c775 100644 --- a/ompi/mca/pml/cm/pml_cm_sendreq.h +++ b/ompi/mca/pml/cm/pml_cm_sendreq.h @@ -28,6 +28,8 @@ struct mca_pml_cm_send_request_t { mca_pml_cm_request_t req_base; mca_pml_base_send_mode_t req_send_mode; + struct ompi_communicator_t *req_comm; /**< communicator pointer */ + struct ompi_datatype_t *req_datatype; /**< pointer to data type */ }; typedef struct mca_pml_cm_send_request_t mca_pml_cm_send_request_t; OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_pml_cm_send_request_t); @@ -48,8 +50,6 @@ struct mca_pml_cm_hvy_send_request_t { size_t req_count; /**< count of user datatype elements */ int32_t req_peer; /**< peer process - rank w/in this communicator */ int32_t req_tag; /**< user defined tag */ - struct ompi_communicator_t *req_comm; /**< communicator pointer */ - struct ompi_datatype_t *req_datatype; /**< pointer to data type */ void *req_buff; /**< pointer to send buffer - may not be application buffer */ bool req_blocking; mca_mtl_request_t req_mtl; /**< the mtl specific memory */ @@ -106,6 +106,10 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_pml_cm_hvy_send_request_t); buf, \ count) \ { \ + OBJ_RETAIN(comm); \ + OBJ_RETAIN(datatype); \ + req_send->req_comm = comm; \ + req_send->req_datatype = datatype; \ ompi_convertor_copy_and_prepare_for_send( \ ompi_proc->proc_convertor, \ datatype, \ @@ -136,10 +140,8 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_pml_cm_hvy_send_request_t); do { \ OMPI_REQUEST_INIT(&(sendreq->req_send.req_base.req_ompi), \ persistent); \ - sendreq->req_comm = comm; \ sendreq->req_tag = tag; \ sendreq->req_peer = dst; \ - sendreq->req_datatype = datatype; \ sendreq->req_addr = buf; \ sendreq->req_count = count; \ MCA_PML_CM_SEND_REQUEST_INIT_COMMON( \ @@ -258,7 +260,7 @@ do { \ } \ if (OMPI_SUCCESS == ret) { \ ret = OMPI_MTL_CALL(isend(ompi_mtl, \ - sendreq->req_comm, \ + sendreq->req_send.req_comm, \ sendreq->req_peer, \ sendreq->req_tag, \ &sendreq->req_send.req_base.req_convertor, \ @@ -315,6 +317,8 @@ do { \ #define MCA_PML_CM_HVY_SEND_REQUEST_RETURN(sendreq) \ { \ /* Let the base handle the reference counts */ \ + OBJ_RELEASE(sendreq->req_send.req_datatype); \ + OBJ_RELEASE(sendreq->req_send.req_comm); \ OMPI_REQUEST_FINI(&sendreq->req_send.req_base.req_ompi); \ ompi_convertor_cleanup( &(sendreq->req_send.req_base.req_convertor) ); \ OMPI_FREE_LIST_RETURN( \ @@ -353,6 +357,8 @@ do { \ #define MCA_PML_CM_THIN_SEND_REQUEST_RETURN(sendreq) \ { \ /* Let the base handle the reference counts */ \ + OBJ_RELEASE(sendreq->req_send.req_datatype); \ + OBJ_RELEASE(sendreq->req_send.req_comm); \ OMPI_REQUEST_FINI(&sendreq->req_send.req_base.req_ompi); \ ompi_convertor_cleanup( &(sendreq->req_send.req_base.req_convertor) ); \ OMPI_FREE_LIST_RETURN( \ diff --git a/ompi/mca/pml/cm/pml_cm_start.c b/ompi/mca/pml/cm/pml_cm_start.c index eab0f23e40..fc0739faca 100644 --- a/ompi/mca/pml/cm/pml_cm_start.c +++ b/ompi/mca/pml/cm/pml_cm_start.c @@ -75,11 +75,11 @@ mca_pml_cm_start(size_t count, ompi_request_t** requests) rc = mca_pml_cm_isend_init( sendreq->req_addr, sendreq->req_count, - sendreq->req_datatype, + sendreq->req_send.req_datatype, sendreq->req_peer, sendreq->req_tag, sendreq->req_send.req_send_mode, - sendreq->req_comm, + sendreq->req_send.req_comm, &request); break; }