From 054968556d1461592a6ab4789249b8fc86891193 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Thu, 2 May 2013 11:22:41 +0200 Subject: [PATCH] add an option smpi/iprobe, to inject sleeping time into a MPI_Iprobe call. Change the way this sleep is done, to increase it each time a MPI_Iprobe fails, to accelerate simulation --- src/simgrid/sg_config.c | 6 +++++- src/smpi/smpi_base.c | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/simgrid/sg_config.c b/src/simgrid/sg_config.c index 63f1a02f30..34baf68fae 100644 --- a/src/simgrid/sg_config.c +++ b/src/simgrid/sg_config.c @@ -759,7 +759,11 @@ void sg_config_init(int *argc, char **argv) xbt_cfgelm_string, NULL, 1, 1, NULL, NULL); xbt_cfg_setdefault_string(_sg_cfg_set, "smpi/or", "1:0:0:0:0"); - + double default_iprobe_time = 1e-4; + xbt_cfg_register(&_sg_cfg_set, "smpi/iprobe", + "Minimum time to inject inside a call to MPI_Iprobe", + xbt_cfgelm_double, &default_iprobe_time, 1, 1, NULL, + NULL); default_value = xbt_strdup("default"); xbt_cfg_register(&_sg_cfg_set, "smpi/allgather", "Which collective to use for allgather", diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index e0cfc66d28..330bcc940c 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -682,9 +682,6 @@ void smpi_mpi_probe(int source, int tag, MPI_Comm comm, MPI_Status* status){ while(flag==0){ smpi_mpi_iprobe(source, tag, comm, &flag, status); XBT_DEBUG("Busy Waiting on probing : %d", flag); - if(!flag) { - simcall_process_sleep(0.0001); - } } } @@ -692,6 +689,13 @@ void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* MPI_Request request =build_request(NULL, 0, MPI_CHAR, source, smpi_comm_rank(comm), tag, comm, NON_PERSISTENT | RECV); + //to avoid deadlock, we have to sleep some time here, or the timer won't advance and we will only do iprobe simcalls + double sleeptime= sg_cfg_get_double("smpi/iprobe"); + //multiplier to the sleeptime, to increase speed of execution, each failed iprobe will increase it + static int nsleeps = 1; + + simcall_process_sleep(sleeptime); + // behave like a receive, but don't do it smx_rdv_t mailbox; @@ -717,8 +721,12 @@ void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status->MPI_ERROR = MPI_SUCCESS; status->count = req->real_size; } + nsleeps=1;//reset the number of sleeps we will do next time + } + else { + *flag = 0; + nsleeps++; } - else *flag = 0; smpi_mpi_request_free(&request); return; -- 2.20.1