aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/timestat.cc
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2007-03-12 16:08:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2007-03-12 16:08:00 +0000
commit524c3731f2496ed67ba7e3c364fe9c2d32c456b4 (patch)
tree4d96e2f1729a2b356f4621b657afc05e94c0d9c8 /Carpet/CarpetLib/src/timestat.cc
parentebee4f847dfd6405b0e711424bac4e58af5b2ec5 (diff)
CarpetLib: Simplify timer interface
Remove some parameters which are not necessary: CarpetLib::print_timestats CarpetLib::timestat_disable Allow the value -1 as well as 0 to disable output for timers and memory statistics. darcs-hash:20070312160854-dae7b-6c60bf0c64a5cac03da97595bb30bb2b47568165.gz
Diffstat (limited to 'Carpet/CarpetLib/src/timestat.cc')
-rw-r--r--Carpet/CarpetLib/src/timestat.cc31
1 files changed, 17 insertions, 14 deletions
diff --git a/Carpet/CarpetLib/src/timestat.cc b/Carpet/CarpetLib/src/timestat.cc
index 358ef94ee..58f28bc18 100644
--- a/Carpet/CarpetLib/src/timestat.cc
+++ b/Carpet/CarpetLib/src/timestat.cc
@@ -32,6 +32,14 @@ namespace CarpetLib {
+ // The timer type
+ enum timer_type {
+ timer_unset, timer_MPI_Wtime, timer_rdtsc, timer_rtc, timer_none
+ };
+ static timer_type timer = timer_unset;
+
+
+
// A faster timing routine for i386 processors:
// Read the Intel CPU time stamp counter
static
@@ -44,11 +52,11 @@ namespace CarpetLib {
// Test for i386 (should use autoconf instead)
#if defined(__i386__) || defined(__x86_64__)
// Serialise using cpuid
- // (This is only strictly necessary on some systems)
+ // (This is strictly necessary only on some systems)
__asm__ __volatile__("cpuid" : : );
- // Using "=A" does not work on x86_64, where it uses rax instead
+ // Using "=A" does not work on x86_64, where this uses rax instead
// of (edx,eax)
- // unsigned long long int val;
+ // unsigned long long val;
// __asm__ __volatile__("rdtsc" : "=A" (val) : );
unsigned long eax, edx;
asm volatile ("rdtsc" : "=a" (eax), "=d" (edx));
@@ -68,9 +76,9 @@ namespace CarpetLib {
init_rdtsc ()
{
// Make three warmup measurements
- volatile double const rdummy1 = rdtsc ();
- volatile double const rdummy2 = rdtsc ();
- volatile double const rdummy3 = rdtsc ();
+ double const rdummy1 = rdtsc ();
+ double const rdummy2 = rdtsc ();
+ double const rdummy3 = rdtsc ();
double const rstart = rdtsc ();
double const wstart = MPI_Wtime ();
int const ierr = usleep (1000 * 1000);
@@ -113,10 +121,6 @@ namespace CarpetLib {
call_timer ()
{
DECLARE_CCTK_PARAMETERS;
- enum timer_type {
- timer_unset, timer_MPI_Wtime, timer_rdtsc, timer_rtc, timer_none
- };
- static timer_type timer = timer_unset;
if (timer == timer_unset) {
if (CCTK_EQUALS (timestat_timer, "MPI_Wtime")) {
timer = timer_MPI_Wtime;
@@ -269,7 +273,7 @@ namespace CarpetLib {
Timer::start ()
{
DECLARE_CCTK_PARAMETERS;
- if (timestat_disable) return;
+ if (timer == timer_none) return;
assert (not running);
running = true;
starttime = call_timer ();
@@ -282,7 +286,7 @@ namespace CarpetLib {
Timer::stop (double const b)
{
DECLARE_CCTK_PARAMETERS;
- if (timestat_disable) return;
+ if (timer == timer_none) return;
assert (running);
running = false;
double const endtime = call_timer ();
@@ -356,8 +360,7 @@ namespace CarpetLib {
DECLARE_CCTK_ARGUMENTS;
DECLARE_CCTK_PARAMETERS;
- if (print_timestats or
- (print_timestats_every and
+ if ((print_timestats_every > 0 and
cctk_iteration % print_timestats_every == 0))
{
ostringstream filenamebuf;