X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/18e13a976a3f6f1d695de22d17c3b91befdba176..394a9cd893e93ee04bf4a8f6ff4ad5a8697a0e82:/src/smpi/smpi_base.c diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index 333c590c91..05a391a4b2 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -48,8 +48,9 @@ MPI_Request smpi_mpi_isend(void* buf, int count, MPI_Datatype datatype, int dst, request->tag = tag; request->size = smpi_datatype_size(datatype) * count; request->complete = 0; + request->data = request; smpi_process_post_send(comm, request); - request->pair = SIMIX_network_isend(request->rdv, request->size, -1.0, buf, request->size, request); + request->pair = SIMIX_network_isend(request->rdv, request->size, -1.0, buf, request->size, NULL); return request; } @@ -63,6 +64,7 @@ MPI_Request smpi_mpi_irecv(void* buf, int count, MPI_Datatype datatype, int src, request->tag = tag; request->size = smpi_datatype_size(datatype) * count; request->complete = 0; + request->data = MPI_REQUEST_NULL; smpi_process_post_recv(request); request->pair = SIMIX_network_irecv(request->rdv, buf, &request->size); return request; @@ -96,7 +98,7 @@ void smpi_mpi_sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int } static void finish_wait(MPI_Request* request, MPI_Status* status) { - MPI_Request data = (MPI_Request)SIMIX_communication_get_data((*request)->pair); + MPI_Request data = (*request)->data; xbt_assert0(data != MPI_REQUEST_NULL, "Erroneous situation"); if(status != MPI_STATUS_IGNORE) { @@ -120,16 +122,18 @@ static void finish_wait(MPI_Request* request, MPI_Status* status) { // receiver cleans everything xbt_free(data); } + SIMIX_rdv_destroy((*request)->rdv); xbt_free(*request); } *request = MPI_REQUEST_NULL; } int smpi_mpi_test(MPI_Request* request, MPI_Status* status) { - MPI_Request data = (MPI_Request)SIMIX_communication_get_data((*request)->pair); + MPI_Request data = (*request)->data; int flag = data && data->complete == 1; if(flag) { + SIMIX_communication_destroy((*request)->pair); finish_wait(request, status); } return flag; @@ -143,8 +147,9 @@ int smpi_mpi_testany(int count, MPI_Request requests[], int* index, MPI_Status* flag = 0; for(i = 0; i < count; i++) { if(requests[i] != MPI_REQUEST_NULL) { - data = (MPI_Request)SIMIX_communication_get_data(requests[i]->pair); + data = requests[i]->data; if(data != MPI_REQUEST_NULL && data->complete == 1) { + SIMIX_communication_destroy(requests[i]->pair); finish_wait(&requests[i], status); *index = i; flag = 1; @@ -156,13 +161,15 @@ int smpi_mpi_testany(int count, MPI_Request requests[], int* index, MPI_Status* } void smpi_mpi_wait(MPI_Request* request, MPI_Status* status) { - MPI_Request data = (MPI_Request)SIMIX_communication_get_data((*request)->pair); + MPI_Request data = (*request)->data; DEBUG6("wait for request %p (%p: %p) [src = %d, dst = %d, tag = %d]", *request, (*request)->pair, data, (*request)->src, (*request)->dst, (*request)->tag); // data is null if receiver waits before sender enters the rdv if(data == MPI_REQUEST_NULL || data->complete == 0) { SIMIX_network_wait((*request)->pair, -1.0); + } else { + SIMIX_communication_destroy((*request)->pair); } finish_wait(request, status); } @@ -178,9 +185,10 @@ int smpi_mpi_waitany(int count, MPI_Request requests[], MPI_Status* status) { // First check for already completed requests for(i = 0; i < count; i++) { if(requests[i] != MPI_REQUEST_NULL) { - data = (MPI_Request)SIMIX_communication_get_data(requests[i]->pair); + data = requests[i]->data; if(data != MPI_REQUEST_NULL && data->complete == 1) { index = i; + SIMIX_communication_destroy(requests[index]->pair); // always succeeds (but cleans the simix layer) break; } } @@ -238,10 +246,11 @@ int smpi_mpi_waitsome(int incount, MPI_Request requests[], int* indices, MPI_Sta int i, count; count = 0; - for(i = 0; i < count; i++) { + for(i = 0; i < incount; i++) { if(requests[i] != MPI_REQUEST_NULL) { - data = (MPI_Request)SIMIX_communication_get_data(requests[i]->pair); + data = requests[i]->data; if(data != MPI_REQUEST_NULL && data->complete == 1) { + SIMIX_communication_destroy(requests[i]->pair); finish_wait(&requests[i], status != MPI_STATUS_IGNORE ? &status[i] : MPI_STATUS_IGNORE); indices[count] = i; count++;