From af1364a82d55d77abdbeaa5bcf53d2a7f356cd3d Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 23 Jan 2008 17:03:00 +0000 Subject: CarpetLib: Update timer calibration darcs-hash:20080123170345-dae7b-7de07dc88470c859a05b0334809d95aae0ae3fde.gz --- Carpet/CarpetLib/src/timestat.cc | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'Carpet/CarpetLib/src/timestat.cc') diff --git a/Carpet/CarpetLib/src/timestat.cc b/Carpet/CarpetLib/src/timestat.cc index 403dcbd75..cbccfe51b 100644 --- a/Carpet/CarpetLib/src/timestat.cc +++ b/Carpet/CarpetLib/src/timestat.cc @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -38,22 +39,37 @@ namespace CarpetLib { void calculate_cputick () { - // Make a few warmup measurements + // Make a few warm-up measurements getticks (); getticks (); getticks (); + +#if 0 + // Use usleep to calibrate the timer + for (int i=0; i<10; ++i) { + useconds_t const waittime = 1000 * 1000; + ticks const rstart = getticks (); + int const ierr = usleep (waittime); + ticks const rend = getticks (); + cputick = waittime / 1.0e6 / elapsed (rend, rstart); + if (not ierr) goto done; + } + CCTK_WARN (1, "Could not determine timer resolution"); + done:; +#endif + +#if 1 + // Use MPI_Wtime to calibrate the timer ticks const rstart = getticks (); double const wstart = MPI_Wtime (); - // int const ierr = usleep (1000 * 1000); while (MPI_Wtime() < wstart + 1.0) { // do nothing, just wait } ticks const rend = getticks (); double const wend = MPI_Wtime (); - // if (ierr) { - // CCTK_WARN (1, "Could not determine a reliable rdtsc timer resolution"); - // } cputick = (wend - wstart) / elapsed (rend, rstart); +#endif + have_cputick = true; } -- cgit v1.2.3