From: Arnaud Giersch Date: Mon, 28 Oct 2013 14:33:41 +0000 (+0100) Subject: Add calls to smpi_bench_{end,begin} in PMPI_Wtime. X-Git-Tag: v3_10_rc1~59 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f7d3e337e64b54125c8a990a99583383a6bf9780?hp=c9cf8f50d09dca349fbbab82ca078cc9ae6890e5 Add calls to smpi_bench_{end,begin} in PMPI_Wtime. 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. --- diff --git a/ChangeLog b/ChangeLog index f86e0e4f2e..a46e0eb1be 100644 --- 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) diff --git a/src/smpi/private.h b/src/smpi/private.h index 3d5ded9701..18049de4d5 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -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); diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index 70f5bbbdc8..915a5a543e 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -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; } diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.c index 0892c28bfe..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; }