From: Augustin Degomme Date: Wed, 16 Jul 2014 14:52:03 +0000 (+0200) Subject: add time injection in MPI_Wtime and MPI_Test, to match what was done in iprobe X-Git-Tag: v3_12~896^2~4 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/2fceed3c80499f2f85403411daa47b5f0457df92 add time injection in MPI_Wtime and MPI_Test, to match what was done in iprobe --- diff --git a/src/simgrid/sg_config.c b/src/simgrid/sg_config.c index 65878a0af4..b33377e24c 100644 --- a/src/simgrid/sg_config.c +++ b/src/simgrid/sg_config.c @@ -842,6 +842,16 @@ void sg_config_init(int *argc, char **argv) xbt_cfgelm_double, 1, 1, NULL, NULL); xbt_cfg_setdefault_double(_sg_cfg_set, "smpi/iprobe", 1e-4); + xbt_cfg_register(&_sg_cfg_set, "smpi/test", + "Minimum time to inject inside a call to MPI_Test", + xbt_cfgelm_double, 1, 1, NULL, NULL); + xbt_cfg_setdefault_double(_sg_cfg_set, "smpi/test", 1e-4); + + xbt_cfg_register(&_sg_cfg_set, "smpi/wtime", + "Minimum time to inject inside a call to MPI_Wtime", + xbt_cfgelm_double, 1, 1, NULL, NULL); + xbt_cfg_setdefault_double(_sg_cfg_set, "smpi/wtime", 3e-8); + xbt_cfg_register(&_sg_cfg_set, "smpi/coll_selector", "Which collective selector to use", xbt_cfgelm_string, 1, 1, NULL, NULL); diff --git a/src/smpi/private.h b/src/smpi/private.h index 9e57d523f1..4c682d746a 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -174,6 +174,7 @@ void print_request(const char *message, MPI_Request request); int smpi_enabled(void); void smpi_global_init(void); void smpi_global_destroy(void); +double smpi_wtime(void); int is_datatype_valid(MPI_Datatype datatype); diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index 38011e60e7..d5b27318e6 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -185,6 +185,21 @@ static double smpi_or(double size) return current; } +double smpi_wtime(){ + double time; + if (smpi_process_initialized() && !smpi_process_finalized() && !smpi_process_get_sampling()) { + smpi_bench_end(); + time = SIMIX_get_clock(); + //to avoid deadlocks if called too many times + double sleeptime= sg_cfg_get_double("smpi/wtime"); + simcall_process_sleep(sleeptime); + smpi_bench_begin(); + } else { + time = SIMIX_get_clock(); + } + return time; +} + static MPI_Request build_request(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags) @@ -677,6 +692,13 @@ int smpi_mpi_test(MPI_Request * request, MPI_Status * status) { int flag; //assume that request is not MPI_REQUEST_NULL (filtered in PMPI_Test or smpi_mpi_testall before) + + //to avoid deadlocks + double sleeptime= sg_cfg_get_double("smpi/test"); + //multiplier to the sleeptime, to increase speed of execution, each failed test will increase it + static int nsleeps = 1; + simcall_process_sleep(nsleeps*sleeptime); + smpi_empty_status(status); flag = 1; if (!((*request)->flags & PREPARED)) { @@ -684,8 +706,11 @@ int smpi_mpi_test(MPI_Request * request, MPI_Status * status) { flag = simcall_comm_test((*request)->action); if (flag) { finish_wait(request, status); + nsleeps=1;//reset the number of sleeps we will do next time if (*request != MPI_REQUEST_NULL && !((*request)->flags & PERSISTENT)) *request = MPI_REQUEST_NULL; + }else{ + nsleeps++; } } return flag; @@ -712,6 +737,12 @@ int smpi_mpi_testany(int count, MPI_Request requests[], int *index, } } if(size > 0) { + //to avoid deadlocks + double sleeptime= sg_cfg_get_double("smpi/test"); + //multiplier to the sleeptime, to increase speed of execution, each failed testany will increase it + static int nsleeps = 1; + simcall_process_sleep(nsleeps*sleeptime); + i = simcall_comm_testany(comms); // not MPI_UNDEFINED, as this is a simix return code if(i != -1) { @@ -720,6 +751,9 @@ int smpi_mpi_testany(int count, MPI_Request requests[], int *index, if (requests[*index] != MPI_REQUEST_NULL && (requests[*index]->flags & NON_PERSISTENT)) requests[*index] = MPI_REQUEST_NULL; flag = 1; + nsleeps=1; + }else{ + nsleeps++; } }else{ //all requests are null or inactive, return true @@ -777,7 +811,7 @@ void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* //multiplier to the sleeptime, to increase speed of execution, each failed iprobe will increase it static int nsleeps = 1; - simcall_process_sleep(sleeptime); + simcall_process_sleep(nsleeps*sleeptime); // behave like a receive, but don't do it smx_rdv_t mailbox; diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.c index b278f07936..8659ec4047 100644 --- a/src/smpi/smpi_pmpi.c +++ b/src/smpi/smpi_pmpi.c @@ -127,15 +127,7 @@ int PMPI_Abort(MPI_Comm comm, int errorcode) double PMPI_Wtime(void) { - double time; - if (smpi_process_initialized() && !smpi_process_finalized() && !smpi_process_get_sampling()) { - smpi_bench_end(); - time = SIMIX_get_clock(); - smpi_bench_begin(); - } else { - time = SIMIX_get_clock(); - } - return time; + return smpi_wtime(); } extern double sg_maxmin_precision;