From f1711862efa6acb2ce97cff16efd8ac4e86c9735 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Thu, 18 Apr 2013 18:45:56 +0000 Subject: [PATCH] fix TimerOutput wall_time in parallel not being synchronized as one expects. git-svn-id: https://svn.dealii.org/trunk@29333 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 7 +++++++ deal.II/include/deal.II/base/timer.h | 2 ++ deal.II/source/base/timer.cc | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 7884f7c326..99f39f441c 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -64,6 +64,13 @@ this function.
    +
  1. Fixed: TimerOutput constructed with an MPI_COMM in wall_time + mode now constructs synchronized Timer objects. This gives reliable + parallel benchmark timings. +
    + (Timo Heister, 2013/04/18) +
  2. +
  3. New: The step-49 tutorial program now also has a discussion on what to do once you have a coarse mesh and want to refine it.
    diff --git a/deal.II/include/deal.II/base/timer.h b/deal.II/include/deal.II/base/timer.h index 9450b20a6d..d9f36d9b7e 100644 --- a/deal.II/include/deal.II/base/timer.h +++ b/deal.II/include/deal.II/base/timer.h @@ -409,6 +409,8 @@ public: */ void enter_section (const std::string §ion_name); + //TODO: make some of these functions DEPRECATED (I would keep enter/exit_section) + /** * Leave a section. If no name is given, * the last section that was entered is diff --git a/deal.II/source/base/timer.cc b/deal.II/source/base/timer.cc index a1be012b22..2c0b9cf2f9 100644 --- a/deal.II/source/base/timer.cc +++ b/deal.II/source/base/timer.cc @@ -350,6 +350,14 @@ TimerOutput::enter_subsection (const std::string §ion_name) if (sections.find (section_name) == sections.end()) { +#ifdef DEAL_II_WITH_MPI + if (mpi_communicator != MPI_COMM_SELF) + { + sections[section_name].timer = Timer(mpi_communicator, true); + } +#endif + + sections[section_name].total_cpu_time = 0; sections[section_name].total_wall_time = 0; sections[section_name].n_calls = 0; -- 2.39.5