Skip to content

Commit

Permalink
add support for the BGQ to the gettime function
Browse files Browse the repository at this point in the history
  • Loading branch information
kostrzewa committed Jul 23, 2012
1 parent 0e56210 commit 79a2e94
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gettime.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,38 @@
double gettime(void) {
double t;
#if (defined BGL && !defined BGP)

const double clockspeed=1.0e-6/700.0;
t = rts_get_timebase() * clockspeed;

#elif defined MPI

t = MPI_Wtime();

/* clock_gettime is detected on BGL/BGP but it is an unsupported system call so we can't use it! */
#elif (defined HAVE_CLOCK_GETTIME && !defined BGL)

struct timespec ts;

/* on the BGQ the monotonic clock is directly connected to the hardware counters
and reports process CPU time, that is not a good measurement for threaded applications */
# ifdef BGQ
clock_gettime(CLOCK_REALTIME,&ts);
# else
clock_gettime(CLOCK_MONOTONIC,&ts);
# endif
t = ts.tv_sec + 1.0e-9*ts.tv_nsec;

#else
/* This number is completely unreliable because the operating system and other processes
make the clock tick too. This is especially true with multiple threads where the number
of clock ticks will be multiplied by roughly the number of threads, but not quite, making
the measurement useless! */

t = (double)clock()/(CLOCKS_PER_SEC);

#endif

return t;
}

0 comments on commit 79a2e94

Please sign in to comment.