From: Augustin Degomme Date: Mon, 3 Dec 2012 16:00:37 +0000 (+0100) Subject: remove sender's side data from mpi_send in the receiver's side for detached send X-Git-Tag: v3_9_rc1~86^2~199 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/bc630c996548bb09c7af6c098fa1b0a39bd8a08b remove sender's side data from mpi_send in the receiver's side for detached send fixes a leak. --- diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index 6fef22aa04..2c05fb619d 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -267,6 +267,9 @@ smx_action_t SIMIX_comm_new(e_smx_comm_type_t type) /* set communication */ act->comm.type = type; act->comm.refcount = 1; + act->comm.src_data=NULL; + act->comm.dst_data=NULL; + #ifdef HAVE_LATENCY_BOUND_TRACKING //initialize with unknown value @@ -302,7 +305,7 @@ void SIMIX_comm_destroy(smx_action_t action) } action->comm.refcount--; if (action->comm.refcount > 0) - return; + return; XBT_DEBUG("Really free communication %p; refcount is now %d", action, action->comm.refcount); @@ -516,7 +519,7 @@ smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv, --smx_total_comms; // this creation was a pure waste other_action->state = SIMIX_READY; other_action->comm.type = SIMIX_COMM_READY; - // other_action->comm.refcount--; + //other_action->comm.refcount--; } xbt_fifo_push(dst_proc->comms, other_action); } diff --git a/src/smpi/private.h b/src/smpi/private.h index 0898994e1b..2a59ec5b2d 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -22,7 +22,7 @@ typedef struct s_smpi_process_data *smpi_process_data_t; #define NON_PERSISTENT 0x2 #define SEND 0x4 #define RECV 0x8 - +#define RECV_DELETE 0x10 // this struct is here to handle the problem of non-contignous data // for each such structure these function should be implemented (vector diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index 18914fa128..0345cbbf03 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -272,10 +272,13 @@ void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src, void smpi_mpi_send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request; + MPI_Request request = + build_request(buf, count, datatype, smpi_comm_rank(comm), dst, tag, + comm, NON_PERSISTENT | SEND | RECV_DELETE); - request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm); + smpi_mpi_start(request); smpi_mpi_wait(&request, MPI_STATUS_IGNORE); + } void smpi_mpi_sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, @@ -337,7 +340,24 @@ static void finish_wait(MPI_Request * request, MPI_Status * status) if(req->detached == 0) free(req->buf); } + + if(req->flags & NON_PERSISTENT) { + if(req->action && + (req->action->state == SIMIX_DONE)) + { + MPI_Request sender_request = (MPI_Request)SIMIX_comm_get_src_data(req->action); + if((sender_request!=MPI_REQUEST_NULL) && + ( sender_request->detached ) && + ( sender_request->flags & RECV_DELETE)) + { + //we are in a receiver's wait from a detached send + //we have to clean the sender's side request here.... but only if done by a send, not an isend + //the request lives senderside for an isend. As detached is currently for send + isend, we use RECV_DELETE to separate them + //FIXME : see if just removing detached status for isend is also good + smpi_mpi_request_free(&sender_request); + } + } smpi_mpi_request_free(request); } else { req->action = NULL;