From: David Wells Date: Thu, 17 Aug 2017 23:11:53 +0000 (-0400) Subject: Enable MPI timer features when MPI is not present. X-Git-Tag: v9.0.0-rc1~1201^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96cb9b704ebad3aa5d396679611fe67a6da4eb0f;p=dealii.git Enable MPI timer features when MPI is not present. All of the relevant functions have redefinitions in the case that MPI is not available. --- diff --git a/include/deal.II/base/timer.h b/include/deal.II/base/timer.h index 1c766e6278..6a6c671b70 100644 --- a/include/deal.II/base/timer.h +++ b/include/deal.II/base/timer.h @@ -22,10 +22,6 @@ #include #include -#ifdef DEAL_II_WITH_MPI -# include -#endif - #include #include #include @@ -81,7 +77,6 @@ public: */ Timer (); -#ifdef DEAL_II_WITH_MPI /** * Constructor that takes an MPI communicator as input. A timer constructed * this way will sum up the CPU times over all processors in the MPI network @@ -94,8 +89,6 @@ public: * only works if you stop() the timer before querying for the wall time. The * time for the MPI operations are not included in the timing but may slow * down your program. - * - * This constructor is only available if deal.II is compiled with MPI support. */ Timer (MPI_Comm mpi_communicator, const bool sync_wall_time = false); @@ -127,7 +120,6 @@ public: template void print_total_data(StreamType &stream) const; -#endif /** * Re-start the timer at the point where it was stopped. This way a @@ -242,7 +234,6 @@ private: */ MPI_Comm mpi_communicator; -#ifdef DEAL_II_WITH_MPI /** * Store whether the wall time is synchronized between machines. */ @@ -263,7 +254,6 @@ private: * number of MPI processes in the MPI_Comm for the total run time. */ Utilities::MPI::MinMaxAvg mpi_total_data; -#endif }; @@ -556,7 +546,6 @@ public: const enum OutputFrequency output_frequency, const enum OutputType output_type); -#ifdef DEAL_II_WITH_MPI /** * Constructor that takes an MPI communicator as input. A timer constructed * this way will sum up the CPU times over all processors in the MPI network @@ -613,11 +602,6 @@ public: const enum OutputFrequency output_frequency, const enum OutputType output_type); - - - -#endif - /** * Destructor. Calls print_summary() in case the option for writing the * summary output is set. @@ -760,8 +744,6 @@ void Timer::restart () -#ifdef DEAL_II_WITH_MPI - inline const Utilities::MPI::MinMaxAvg & Timer::get_data() const @@ -804,8 +786,6 @@ Timer::print_total_data(StreamType &stream) const << statistic.min_index << ", avg=" << statistic.avg << std::endl; } -#endif - inline diff --git a/source/base/timer.cc b/source/base/timer.cc index e6e4348206..0b3cc34f6e 100644 --- a/source/base/timer.cc +++ b/source/base/timer.cc @@ -67,9 +67,6 @@ Timer::Timer() -// in case we use an MPI compiler, use -// the communicator given from input -#ifdef DEAL_II_WITH_MPI Timer::Timer(MPI_Comm mpi_communicator, const bool sync_wall_time_) : @@ -83,16 +80,13 @@ Timer::Timer(MPI_Comm mpi_communicator, mpi_communicator (mpi_communicator), sync_wall_time(sync_wall_time_) { -#ifdef DEAL_II_WITH_MPI 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; -#endif start(); } -#endif @@ -130,8 +124,7 @@ namespace void Timer::start () { - running = true; - + running = true; #ifdef DEAL_II_WITH_MPI if (sync_wall_time) { @@ -187,7 +180,6 @@ double Timer::stop () # error Unsupported platform. Porting not finished. #endif -#ifdef DEAL_II_WITH_MPI this->mpi_data = Utilities::MPI::min_max_avg (last_lap_time, mpi_communicator); if (sync_wall_time && Utilities::MPI::job_supports_mpi()) @@ -200,10 +192,6 @@ double Timer::stop () accumulated_cpu_time += last_lap_cpu_time; this->mpi_total_data = Utilities::MPI::min_max_avg (accumulated_wall_time, mpi_communicator); -#else - accumulated_wall_time += last_lap_time; - accumulated_cpu_time += last_lap_cpu_time; -#endif } return accumulated_cpu_time; } @@ -298,12 +286,10 @@ void Timer::reset () accumulated_cpu_time = 0.; accumulated_wall_time = 0.; running = false; -#ifdef DEAL_II_WITH_MPI 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; -#endif } @@ -317,10 +303,8 @@ TimerOutput::TimerOutput (std::ostream &stream, output_frequency (output_frequency), output_type (output_type), out_stream (stream, true), - output_is_enabled (true) -#ifdef DEAL_II_WITH_MPI - , mpi_communicator (MPI_COMM_SELF) -#endif + output_is_enabled (true), + mpi_communicator (MPI_COMM_SELF) {} @@ -332,14 +316,11 @@ TimerOutput::TimerOutput (ConditionalOStream &stream, output_frequency (output_frequency), output_type (output_type), out_stream (stream), - output_is_enabled (true) -#ifdef DEAL_II_WITH_MPI - , mpi_communicator (MPI_COMM_SELF) -#endif + output_is_enabled (true), + mpi_communicator (MPI_COMM_SELF) {} -#ifdef DEAL_II_WITH_MPI TimerOutput::TimerOutput (MPI_Comm mpi_communicator, std::ostream &stream, @@ -367,7 +348,6 @@ TimerOutput::TimerOutput (MPI_Comm mpi_communicator, mpi_communicator (mpi_communicator) {} -#endif TimerOutput::~TimerOutput() @@ -402,7 +382,6 @@ 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) { // create a new timer for this section. the second argument @@ -414,7 +393,6 @@ TimerOutput::enter_subsection (const std::string §ion_name) // among all processes inside mpi_communicator. sections[section_name].timer = Timer(mpi_communicator, true); } -#endif sections[section_name].total_cpu_time = 0;