diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2008-01-23 17:03:00 +0000 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2008-01-23 17:03:00 +0000 |
commit | af1364a82d55d77abdbeaa5bcf53d2a7f356cd3d (patch) | |
tree | 005a2561c34b26081784bba7a2a85be2f4a85010 | |
parent | 01bac7e5a6a0bef32eaef89fd6fae96d28177523 (diff) |
CarpetLib: Update timer calibration
darcs-hash:20080123170345-dae7b-7de07dc88470c859a05b0334809d95aae0ae3fde.gz
-rw-r--r-- | Carpet/CarpetLib/src/timestat.cc | 26 |
1 files changed, 21 insertions, 5 deletions
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 <iostream> #include <sstream> +#include <sys/time.h> #include <unistd.h> #include <mpi.h> @@ -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; } |