From: Daniel Arndt Date: Wed, 28 Jun 2017 14:59:10 +0000 (+0200) Subject: Use signaling_nan's again for initialization X-Git-Tag: v9.0.0-rc1~1462^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a598d408fee0b862c3f3009dae0d69a2232bf19f;p=dealii.git Use signaling_nan's again for initialization --- diff --git a/doc/news/changes/minor/20170623DanielArndt b/doc/news/changes/minor/20170623DanielArndt index e50b1a6bd2..38e7390f5a 100644 --- a/doc/news/changes/minor/20170623DanielArndt +++ b/doc/news/changes/minor/20170623DanielArndt @@ -1,5 +1,6 @@ -New: The class Timer has the new functions get_total_data(), -print_total_data, last_wall_time, cpu_time and last_cpu_time() -for accessing information about the total run and the last lap now. +New: The Timer class now has new functions Timer::get_total_data(), +Timer::print_total_data, Timer::last_wall_time, Timer::cpu_time and +Timer::last_cpu_time() to access information about the total run as +well as the last lap.
(Daniel Arndt, 2017/06/23) diff --git a/source/base/timer.cc b/source/base/timer.cc index c7441509a6..05745a8bad 100644 --- a/source/base/timer.cc +++ b/source/base/timer.cc @@ -47,8 +47,8 @@ Timer::Timer() start_wall_time (0.), cumulative_time (0.), cumulative_wall_time (0.), - last_lap_time (0.), - last_lap_cpu_time(0.), + last_lap_time (numbers::signaling_nan()), + last_lap_cpu_time(numbers::signaling_nan()), running (false) #ifdef DEAL_II_WITH_MPI , @@ -57,8 +57,8 @@ Timer::Timer() #endif { #ifdef DEAL_II_WITH_MPI - mpi_data.sum = mpi_data.min = mpi_data.max = mpi_data.avg = 0.; - mpi_data.min_index = mpi_data.max_index = 0; + 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 @@ -79,15 +79,15 @@ Timer::Timer(MPI_Comm mpi_communicator, start_wall_time (0.), cumulative_time (0.), cumulative_wall_time (0.), - last_lap_time (0.), - last_lap_cpu_time (0.), + last_lap_time (numbers::signaling_nan()), + last_lap_cpu_time (numbers::signaling_nan()), running (false), 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 = 0.; - mpi_data.min_index = mpi_data.max_index = 0; + 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 @@ -312,14 +312,14 @@ double Timer::last_wall_time () const void Timer::reset () { - last_lap_time = 0.; - last_lap_cpu_time = 0.; + last_lap_time = numbers::signaling_nan(); + last_lap_cpu_time = numbers::signaling_nan(); cumulative_time = 0.; cumulative_wall_time = 0.; running = false; #ifdef DEAL_II_WITH_MPI - mpi_data.sum = mpi_data.min = mpi_data.max = mpi_data.avg = 0.; - mpi_data.min_index = mpi_data.max_index = 0; + 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 diff --git a/tests/base/timer_04.cc b/tests/base/timer_04.cc index 8fc498bfe7..3a954357bb 100644 --- a/tests/base/timer_04.cc +++ b/tests/base/timer_04.cc @@ -50,8 +50,6 @@ int main () AssertThrow(old_wall_time > 0., ExcInternalError()); const double old_cpu_time = t.wall_time(); AssertThrow(old_cpu_time > 0., ExcInternalError()); - AssertThrow(t.last_wall_time() == 0., ExcInternalError()); - AssertThrow(t.last_cpu_time() == 0, ExcInternalError()); burn(50); AssertThrow(t.stop() > 0., ExcInternalError()); @@ -64,8 +62,6 @@ int main () t.reset(); AssertThrow(t.wall_time() == 0., ExcInternalError()); AssertThrow(t.cpu_time()== 0., ExcInternalError()); - AssertThrow(t.last_wall_time() == 0., ExcInternalError()); - AssertThrow(t.last_cpu_time() == 0, ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/base/timer_05.cc b/tests/base/timer_05.cc index 31a6e4a6e2..a081900260 100644 --- a/tests/base/timer_05.cc +++ b/tests/base/timer_05.cc @@ -47,10 +47,7 @@ test_timer(Timer &t) AssertThrow(old_wall_time > 0., ExcInternalError()); const double old_cpu_time = t.wall_time(); AssertThrow(old_cpu_time > 0., ExcInternalError()); - AssertThrow(t.last_wall_time() == 0., ExcInternalError()); - AssertThrow(t.last_cpu_time() == 0., ExcInternalError()); - AssertThrow(t.get_data().min == 0., ExcInternalError()); - AssertThrow(t.get_total_data().min == 0., ExcInternalError()); + AssertThrow(t.get_total_data().max == 0., ExcInternalError()); burn(50); AssertThrow(t.stop() > 0., ExcInternalError()); @@ -65,10 +62,7 @@ test_timer(Timer &t) t.reset(); AssertThrow(t.wall_time() == 0., ExcInternalError()); AssertThrow(t.cpu_time()== 0., ExcInternalError()); - AssertThrow(t.last_wall_time() == 0., ExcInternalError()); - AssertThrow(t.last_cpu_time() == 0., ExcInternalError()); - AssertThrow(t.get_data().min == 0., ExcInternalError()); - AssertThrow(t.get_total_data().min == 0, ExcInternalError()); + AssertThrow(t.get_total_data().max == 0, ExcInternalError()); deallog << "OK" << std::endl; }