Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add calls to smpi_bench_{end,begin} in PMPI_Wtime.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Mon, 28 Oct 2013 14:33:41 +0000 (15:33 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Mon, 28 Oct 2013 15:15:58 +0000 (16:15 +0100)
Without this change, doing something like the following always
gives a duration of zero:

    ...
    start = MPI_Wtime();
    // big computation...
    end = MPI_Wtime();
    duration = end - start;
    ...

Make sure that no calls to smpi_bench are made when process is not
between init and finalize, nor during sample blocks.

ChangeLog
src/smpi/private.h
src/smpi/smpi_bench.c
src/smpi/smpi_pmpi.c

index f86e0e4..a46e0eb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,8 +34,9 @@ SimGrid (3.10pre1) unstable; urgency=low
    Reduce
  * Add a --cfg:tracing/smpi/internals option, to trace internal communications
    happening inside a collective SMPI call.
- * Fix the behavior of complex data types handling
- * replace MPICH-1 test suite by the one from MPICH 3.0.4. Can be built using
+ * Fix the behavior of complex data types handling.
+ * Make MPI_Wtime another synchronization point to take computations into account.
+ * Replace MPICH-1 test suite by the one from MPICH 3.0.4. Can be built using
    enable_smpi_MPICH3_testsuite flag in cmake. Run with ctest.
  * Add all missing Fortran bindings, SMPI should work with Fortran 90
    (no privatization of global variables yet)
index 3d5ded9..18049de 100644 (file)
@@ -285,6 +285,7 @@ int smpi_coll_basic_alltoallv(void *sendbuf, int *sendcounts,
                               MPI_Comm comm);
 
 // utilities
+extern int smpi_sample_is_running;
 void smpi_bench_destroy(void);
 void smpi_bench_begin(void);
 void smpi_bench_end(void);
index 70f5bbb..915a5a5 100644 (file)
@@ -220,6 +220,8 @@ typedef struct {
   int benching;     /* 1: we are benchmarking; 0: we have enough data, no bench anymore */
 } local_data_t;
 
+int smpi_sample_is_running = 0;
+
 static char *sample_location(int global, const char *file, int line) {
   if (global) {
     return bprintf("%s:%d", file, line);
@@ -247,6 +249,8 @@ void smpi_sample_1(int global, const char *file, int line, int iters, double thr
   local_data_t *data;
 
   smpi_bench_end();     /* Take time from previous, unrelated computation into account */
+  smpi_sample_is_running++;
+
   if (!samples)
     samples = xbt_dict_new_homogeneous(free);
 
@@ -301,6 +305,7 @@ int smpi_sample_2(int global, const char *file, int line)
         data->count, data->iters, data->relstderr, data->threshold, data->mean);
     smpi_execute(data->mean);
 
+    smpi_sample_is_running--;
     smpi_bench_begin(); // prepare to capture future, unrelated computations
     return 0;
   }
index 0892c28..0d93e9c 100644 (file)
@@ -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;
 }