]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Give the MPI::MinMaxAvg members of Timer more descriptive names. 4905/head
authorDavid Wells <wellsd2@rpi.edu>
Thu, 17 Aug 2017 23:31:09 +0000 (19:31 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Sun, 20 Aug 2017 18:20:19 +0000 (14:20 -0400)
include/deal.II/base/timer.h
source/base/timer.cc

index eee3a667d23f90def983244ac5cbb16e7b74a355..2861185d1882a8f59c6fa65ae2bfeedfcce4df63 100644 (file)
@@ -96,30 +96,67 @@ public:
   /**
    * Return a reference to the data structure with global timing information
    * for the last lap. Filled after calling stop().
+   *
+   * @deprecated Use Timer::get_last_lap_data() instead, which returns a
+   * reference to the same structure.
+   */
+  const Utilities::MPI::MinMaxAvg &get_data() const DEAL_II_DEPRECATED;
+
+  /**
+   * Return a reference to the data structure containing timing information
+   * across all MPI processes in the given communicator about the last
+   * lap. Filled after calling stop().
    */
-  const Utilities::MPI::MinMaxAvg &get_data() const;
+  const Utilities::MPI::MinMaxAvg &get_last_lap_data() const;
 
   /**
    * Return a reference to the data structure with global timing information
-   * for the total run.
-   * Filled after calling stop().
+   * for the total run. Filled after calling stop().
+   *
+   * @deprecated Use Timer::get_accumulated_wall_time_data() instead, which
+   * returns a reference the same structure.
    */
-  const Utilities::MPI::MinMaxAvg &get_total_data() const;
+  const Utilities::MPI::MinMaxAvg &get_total_data() const DEAL_II_DEPRECATED;
+
+  /**
+   * Return a reference to the data structure with global timing information
+   * for the total run. Filled after calling stop().
+   */
+  const Utilities::MPI::MinMaxAvg &get_accumulated_wall_time_data() const;
 
   /**
    * Prints the data returned by get_data(), i.e. for the last lap,
    * to the given stream.
+   *
+   * @deprecated Use Timer::print_last_lap_data() instead, which prints the
+   * same information.
+   */
+  template <class StreamType>
+  void print_data(StreamType &stream) const DEAL_II_DEPRECATED;
+
+  /**
+   * Print the data returned by Timer::get_last_lap_data() to the given
+   * stream.
    */
   template <class StreamType>
-  void print_data(StreamType &stream) const;
+  void print_last_lap_data(StreamType &stream) const;
 
   /**
    * Prints the data returned by get_total_data(), i.e. for the total run,
    * to the given stream.
+   *
+   * @deprecated Use Timer::print_accumulated_wall_time_data() instead, which
+   * prints the same information.
    */
   template <class StreamType>
-  void print_total_data(StreamType &stream) const;
+  void print_total_data(StreamType &stream) const DEAL_II_DEPRECATED;
 
+  /**
+   * Print the data returned by Timer::get_accumulated_wall_time_data() to the
+   * given stream.
+   */
+  template <class StreamType>
+  void print_accumulated_wall_time_data(StreamType &stream) const;
 
   /**
    * Re-start the timer at the point where it was stopped. This way a
@@ -240,12 +277,11 @@ private:
   bool sync_wall_time;
 
   /**
-   * A structure for parallel wall time measurement that includes the minimum
-   * time recorded among all processes, the maximum time as well as the
-   * average time defined as the sum of all individual times divided by the
-   * number of MPI processes in the MPI_Comm for the last lap.
+   * A structure for parallel wall time measurement that includes the minimum,
+   * maximum, and average over all processors known to the MPI communicator of
+   * the last lap time.
    */
-  Utilities::MPI::MinMaxAvg mpi_data;
+  Utilities::MPI::MinMaxAvg last_lap_data;
 
   /**
    * A structure for parallel wall time measurement that includes the minimum
@@ -253,7 +289,7 @@ private:
    * average time defined as the sum of all individual times divided by the
    * number of MPI processes in the MPI_Comm for the total run time.
    */
-  Utilities::MPI::MinMaxAvg mpi_total_data;
+  Utilities::MPI::MinMaxAvg accumulated_wall_time_data;
 };
 
 
@@ -748,7 +784,16 @@ inline
 const Utilities::MPI::MinMaxAvg &
 Timer::get_data() const
 {
-  return mpi_data;
+  return last_lap_data;
+}
+
+
+
+inline
+const Utilities::MPI::MinMaxAvg &
+Timer::get_last_lap_data() const
+{
+  return last_lap_data;
 }
 
 
@@ -757,7 +802,16 @@ inline
 const Utilities::MPI::MinMaxAvg &
 Timer::get_total_data() const
 {
-  return mpi_total_data;
+  return accumulated_wall_time_data;
+}
+
+
+
+inline
+const Utilities::MPI::MinMaxAvg &
+Timer::get_accumulated_wall_time_data() const
+{
+  return accumulated_wall_time_data;
 }
 
 
@@ -767,7 +821,17 @@ inline
 void
 Timer::print_data(StreamType &stream) const
 {
-  const Utilities::MPI::MinMaxAvg statistic = get_data();
+  print_last_lap_data(stream);
+}
+
+
+
+template <class StreamType>
+inline
+void
+Timer::print_last_lap_data(StreamType &stream) const
+{
+  const Utilities::MPI::MinMaxAvg statistic = get_last_lap_data();
   stream << statistic.max << " wall,"
          << " max @" << statistic.max_index << ", min=" << statistic.min << " @"
          << statistic.min_index << ", avg=" << statistic.avg << std::endl;
@@ -780,7 +844,17 @@ inline
 void
 Timer::print_total_data(StreamType &stream) const
 {
-  const Utilities::MPI::MinMaxAvg statistic = get_total_data();
+  print_accumulated_wall_time_data(stream);
+}
+
+
+
+template <class StreamType>
+inline
+void
+Timer::print_accumulated_wall_time_data(StreamType &stream) const
+{
+  const Utilities::MPI::MinMaxAvg statistic = get_accumulated_wall_time_data();
   stream << statistic.max << " wall,"
          << " max @" << statistic.max_index << ", min=" << statistic.min << " @"
          << statistic.min_index << ", avg=" << statistic.avg << std::endl;
index cb7ed3f84935b3f1f5434c0f7ca5d05e1d218960..72994ee64fdac55b35a5065195f50e56ff7dc6db 100644 (file)
@@ -57,10 +57,10 @@ Timer::Timer(MPI_Comm mpi_communicator,
   mpi_communicator (mpi_communicator),
   sync_wall_time(sync_wall_time_)
 {
-  mpi_data.sum = mpi_data.min = mpi_data.max = mpi_data.avg = numbers::signaling_nan<double>();
-  mpi_data.min_index = mpi_data.max_index = numbers::invalid_unsigned_int;
-  mpi_total_data.sum = mpi_total_data.min = mpi_total_data.max = mpi_total_data.avg = 0.;
-  mpi_total_data.min_index = mpi_total_data.max_index = 0;
+  last_lap_data.sum = last_lap_data.min = last_lap_data.max = last_lap_data.avg = numbers::signaling_nan<double>();
+  last_lap_data.min_index = last_lap_data.max_index = numbers::invalid_unsigned_int;
+  accumulated_wall_time_data.sum = accumulated_wall_time_data.min = accumulated_wall_time_data.max = accumulated_wall_time_data.avg = 0.;
+  accumulated_wall_time_data.min_index = accumulated_wall_time_data.max_index = 0;
 
   start();
 }
@@ -157,18 +157,18 @@ double Timer::stop ()
 #  error "Unsupported platform. Porting not finished."
 #endif
 
-      this->mpi_data = Utilities::MPI::min_max_avg (last_lap_time,
-                                                    mpi_communicator);
-      if (sync_wall_time && Utilities::MPI::job_supports_mpi())
+      last_lap_data = Utilities::MPI::min_max_avg (last_lap_time,
+                                                   mpi_communicator);
+      if (sync_wall_time)
         {
-          last_lap_time = this->mpi_data.max;
+          last_lap_time = last_lap_data.max;
           last_lap_cpu_time = Utilities::MPI::min_max_avg (last_lap_cpu_time,
                                                            mpi_communicator).max;
         }
       accumulated_wall_time += last_lap_time;
       accumulated_cpu_time += last_lap_cpu_time;
-      this->mpi_total_data = Utilities::MPI::min_max_avg (accumulated_wall_time,
-                                                          mpi_communicator);
+      accumulated_wall_time_data = Utilities::MPI::min_max_avg (accumulated_wall_time,
+                                                                mpi_communicator);
     }
   return accumulated_cpu_time;
 }
@@ -263,10 +263,10 @@ void Timer::reset ()
   accumulated_cpu_time = 0.;
   accumulated_wall_time = 0.;
   running         = false;
-  mpi_data.sum = mpi_data.min = mpi_data.max = mpi_data.avg = numbers::signaling_nan<double>();
-  mpi_data.min_index = mpi_data.max_index = numbers::invalid_unsigned_int;
-  mpi_total_data.sum = mpi_total_data.min = mpi_total_data.max = mpi_total_data.avg = 0.;
-  mpi_total_data.min_index = mpi_total_data.max_index = 0;
+  last_lap_data.sum = last_lap_data.min = last_lap_data.max = last_lap_data.avg = numbers::signaling_nan<double>();
+  last_lap_data.min_index = last_lap_data.max_index = numbers::invalid_unsigned_int;
+  accumulated_wall_time_data.sum = accumulated_wall_time_data.min = accumulated_wall_time_data.max = accumulated_wall_time_data.avg = 0.;
+  accumulated_wall_time_data.min_index = accumulated_wall_time_data.max_index = 0;
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.