From: David Wells Date: Thu, 17 Aug 2017 23:31:09 +0000 (-0400) Subject: Give the MPI::MinMaxAvg members of Timer more descriptive names. X-Git-Tag: v9.0.0-rc1~1201^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a184149e546cf39cd760ce707696b8fe857f455;p=dealii.git Give the MPI::MinMaxAvg members of Timer more descriptive names. --- diff --git a/include/deal.II/base/timer.h b/include/deal.II/base/timer.h index eee3a667d2..2861185d18 100644 --- a/include/deal.II/base/timer.h +++ b/include/deal.II/base/timer.h @@ -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 + void print_data(StreamType &stream) const DEAL_II_DEPRECATED; + + /** + * Print the data returned by Timer::get_last_lap_data() to the given + * stream. */ template - 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 - 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 + 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 +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 +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; diff --git a/source/base/timer.cc b/source/base/timer.cc index cb7ed3f849..72994ee64f 100644 --- a/source/base/timer.cc +++ b/source/base/timer.cc @@ -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(); - 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(); + 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(); - 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(); + 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; }