aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/timestat.cc
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2008-01-23 17:03:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2008-01-23 17:03:00 +0000
commit78ed0174dbb8ba572d379415616261b4ce66b1e2 (patch)
tree005a2561c34b26081784bba7a2a85be2f4a85010 /Carpet/CarpetLib/src/timestat.cc
parent76b9e7803c77b3dfc9ae20fa127003436f79cbf0 (diff)
CarpetLib: Update timer calibration
darcs-hash:20080123170345-dae7b-7de07dc88470c859a05b0334809d95aae0ae3fde.gz
Diffstat (limited to 'Carpet/CarpetLib/src/timestat.cc')
-rw-r--r--Carpet/CarpetLib/src/timestat.cc26
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;
}