Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add time injection in MPI_Wtime and MPI_Test, to match what was done in iprobe
authorAugustin Degomme <augustin.degomme@imag.fr>
Wed, 16 Jul 2014 14:52:03 +0000 (16:52 +0200)
committerAugustin Degomme <augustin.degomme@imag.fr>
Wed, 16 Jul 2014 14:52:03 +0000 (16:52 +0200)
src/simgrid/sg_config.c
src/smpi/private.h
src/smpi/smpi_base.c
src/smpi/smpi_pmpi.c

index 65878a0..b33377e 100644 (file)
@@ -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_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);
     xbt_cfg_register(&_sg_cfg_set, "smpi/coll_selector",
                      "Which collective selector to use",
                      xbt_cfgelm_string, 1, 1, NULL, NULL);
index 9e57d52..4c682d7 100644 (file)
@@ -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);
 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);
 
 
 int is_datatype_valid(MPI_Datatype datatype);
 
index 38011e6..d5b2731 100644 (file)
@@ -185,6 +185,21 @@ static double smpi_or(double size)
   return current;
 }
 
   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)
 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)
   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)) {
   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);
       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;
       if (*request != MPI_REQUEST_NULL && !((*request)->flags & PERSISTENT))
       *request = MPI_REQUEST_NULL;
+    }else{
+      nsleeps++;
     }
   }
   return flag;
     }
   }
   return flag;
@@ -712,6 +737,12 @@ int smpi_mpi_testany(int count, MPI_Request requests[], int *index,
     }
   }
   if(size > 0) {
     }
   }
   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) {
     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;
       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
     }
   }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;
 
   //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;
 
   // behave like a receive, but don't do it
   smx_rdv_t mailbox;
index b278f07..8659ec4 100644 (file)
@@ -127,15 +127,7 @@ int PMPI_Abort(MPI_Comm comm, int errorcode)
 
 double PMPI_Wtime(void)
 {
 
 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;
 }
 
 extern double sg_maxmin_precision;