X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a7ad93d9cba4ca9bb370821fa98d09dabacbe875..8c60ee91d67edcaf50c9ffd5a2d0fab3227c77aa:/src/smpi/smpi_pmpi.c diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.c index cddc0206d4..0d93e9c38a 100644 --- a/src/smpi/smpi_pmpi.c +++ b/src/smpi/smpi_pmpi.c @@ -127,7 +127,13 @@ int PMPI_Abort(MPI_Comm comm, int errorcode) double PMPI_Wtime(void) { double time; - time = SIMIX_get_clock(); + if (smpi_process_initialized() && !smpi_process_finalized() && !smpi_sample_is_running) { + smpi_bench_end(); + time = SIMIX_get_clock(); + smpi_bench_begin(); + } else { + time = SIMIX_get_clock(); + } return time; } @@ -907,7 +913,7 @@ int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out) } int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst, - int tag, MPI_Comm comm, MPI_Request * request) + int tag, MPI_Comm comm, MPI_Request * request) { int retval = 0; @@ -923,12 +929,13 @@ int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst, retval = MPI_SUCCESS; } smpi_bench_begin(); - if(retval!=MPI_SUCCESS)*request=MPI_REQUEST_NULL; + if (retval != MPI_SUCCESS && request) + *request = MPI_REQUEST_NULL; return retval; } int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src, - int tag, MPI_Comm comm, MPI_Request * request) + int tag, MPI_Comm comm, MPI_Request * request) { int retval = 0; @@ -938,33 +945,37 @@ int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src, } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; } else if (src == MPI_PROC_NULL) { - retval = MPI_SUCCESS; + retval = MPI_SUCCESS; } else { *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm); retval = MPI_SUCCESS; } smpi_bench_begin(); - if(retval!=MPI_SUCCESS)*request=MPI_REQUEST_NULL; + if (retval != MPI_SUCCESS && request) + *request = MPI_REQUEST_NULL; return retval; } -int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) { +int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype, + int dst, int tag, MPI_Comm comm, MPI_Request* request) +{ int retval = 0; - smpi_bench_end(); - if (request == NULL) { - retval = MPI_ERR_ARG; - } else if (comm == MPI_COMM_NULL) { - retval = MPI_ERR_COMM; - } else if (dst == MPI_PROC_NULL) { - retval = MPI_SUCCESS; - } else { - *request = smpi_mpi_ssend_init(buf, count, datatype, dst, tag, comm); - retval = MPI_SUCCESS; - } - smpi_bench_begin(); - if(retval!=MPI_SUCCESS)*request=MPI_REQUEST_NULL; - return retval; + smpi_bench_end(); + if (request == NULL) { + retval = MPI_ERR_ARG; + } else if (comm == MPI_COMM_NULL) { + retval = MPI_ERR_COMM; + } else if (dst == MPI_PROC_NULL) { + retval = MPI_SUCCESS; + } else { + *request = smpi_mpi_ssend_init(buf, count, datatype, dst, tag, comm); + retval = MPI_SUCCESS; + } + smpi_bench_begin(); + if (retval != MPI_SUCCESS && request) + *request = MPI_REQUEST_NULL; + return retval; } int PMPI_Start(MPI_Request * request) @@ -1014,7 +1025,7 @@ int PMPI_Request_free(MPI_Request * request) } int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, - int tag, MPI_Comm comm, MPI_Request * request) + int tag, MPI_Comm comm, MPI_Request * request) { int retval = 0; @@ -1040,28 +1051,29 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, } else { #ifdef HAVE_TRACING - int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - int src_traced = smpi_group_index(smpi_comm_group(comm), src); - TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, count*smpi_datatype_size(datatype)); + int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; + int src_traced = smpi_group_index(smpi_comm_group(comm), src); + TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, count*smpi_datatype_size(datatype)); #endif *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm); retval = MPI_SUCCESS; #ifdef HAVE_TRACING - TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__); - (*request)->recv = 1; + TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__); + (*request)->recv = 1; #endif } smpi_bench_begin(); - if(retval!=MPI_SUCCESS)*request=MPI_REQUEST_NULL; + if (retval != MPI_SUCCESS && request) + *request = MPI_REQUEST_NULL; return retval; } int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, - int tag, MPI_Comm comm, MPI_Request * request) + int tag, MPI_Comm comm, MPI_Request * request) { int retval = 0; @@ -1086,29 +1098,32 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, } else { #ifdef HAVE_TRACING - int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_computing_out(rank); - int dst_traced = smpi_group_index(smpi_comm_group(comm), dst); - TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype)); - TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype)); + int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; + TRACE_smpi_computing_out(rank); + int dst_traced = smpi_group_index(smpi_comm_group(comm), dst); + TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype)); + TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype)); #endif *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm); retval = MPI_SUCCESS; #ifdef HAVE_TRACING - TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__); - (*request)->send = 1; - TRACE_smpi_computing_in(rank); + TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__); + (*request)->send = 1; + TRACE_smpi_computing_in(rank); #endif } smpi_bench_begin(); - if(retval!=MPI_SUCCESS)*request=MPI_REQUEST_NULL; + if (retval != MPI_SUCCESS && request) + *request = MPI_REQUEST_NULL; return retval; } -int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) { +int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, + int dst, int tag, MPI_Comm comm, MPI_Request* request) +{ int retval = 0; smpi_bench_end(); @@ -1132,25 +1147,26 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, M } else { #ifdef HAVE_TRACING - int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_computing_out(rank); - int dst_traced = smpi_group_index(smpi_comm_group(comm), dst); - TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype)); - TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype)); + int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; + TRACE_smpi_computing_out(rank); + int dst_traced = smpi_group_index(smpi_comm_group(comm), dst); + TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype)); + TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype)); #endif *request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm); retval = MPI_SUCCESS; #ifdef HAVE_TRACING - TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__); - (*request)->send = 1; - TRACE_smpi_computing_in(rank); + TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__); + (*request)->send = 1; + TRACE_smpi_computing_in(rank); #endif } smpi_bench_begin(); - if(retval!=MPI_SUCCESS)*request=MPI_REQUEST_NULL; + if (retval != MPI_SUCCESS && request) + *request = MPI_REQUEST_NULL; return retval; } @@ -1374,10 +1390,11 @@ int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status) int retval = 0; smpi_bench_end(); - if (*request == MPI_REQUEST_NULL || flag == NULL) { + if (request == NULL || flag == NULL) { retval = MPI_ERR_ARG; } else if (*request == MPI_REQUEST_NULL) { *flag= TRUE; + smpi_empty_status(status); retval = MPI_ERR_REQUEST; } else { *flag = smpi_mpi_test(request, status); @@ -1468,6 +1485,8 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status) smpi_bench_end(); + smpi_empty_status(status); + if (request == NULL) { retval = MPI_ERR_ARG; } else if (*request == MPI_REQUEST_NULL) { @@ -1475,32 +1494,32 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status) } else { #ifdef HAVE_TRACING - int rank = request && (*request)->comm != MPI_COMM_NULL + int rank = request && (*request)->comm != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_computing_out(rank); + TRACE_smpi_computing_out(rank); - int src_traced = (*request)->src; - int dst_traced = (*request)->dst; - MPI_Comm comm = (*request)->comm; - int is_wait_for_receive = (*request)->recv; - TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__,-1); + int src_traced = (*request)->src; + int dst_traced = (*request)->dst; + MPI_Comm comm = (*request)->comm; + int is_wait_for_receive = (*request)->recv; + TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__,-1); #endif smpi_mpi_wait(request, status); retval = MPI_SUCCESS; #ifdef HAVE_TRACING - //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE) - TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__); - if (is_wait_for_receive) { - if(src_traced==MPI_ANY_SOURCE) - src_traced = (status!=MPI_STATUS_IGNORE) ? - smpi_group_rank(smpi_comm_group(comm), status->MPI_SOURCE) : - src_traced; - TRACE_smpi_recv(rank, src_traced, dst_traced); - } - TRACE_smpi_computing_in(rank); + //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE) + TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__); + if (is_wait_for_receive) { + if(src_traced==MPI_ANY_SOURCE) + src_traced = (status!=MPI_STATUS_IGNORE) ? + smpi_group_rank(smpi_comm_group(comm), status->MPI_SOURCE) : + src_traced; + TRACE_smpi_recv(rank, src_traced, dst_traced); + } + TRACE_smpi_computing_in(rank); #endif }