/* bgl/bgp timers */ void metric_read_bgtimers(int tid, int idx, double values[]) { #ifdef TAU_BGL static double bgl_clockspeed = 0.0; if (bgl_clockspeed == 0.0) { BGLPersonality mybgl; rts_get_personality(&mybgl, sizeof(BGLPersonality)); bgl_clockspeed = 1.0e6 / (double)BGLPersonality_clockHz(&mybgl); } values[idx] = (rts_get_timebase() * bgl_clockspeed); #endif /* TAU_BGL */ #ifdef TAU_BGP #ifdef BGP_TIMERS static double bgp_clockspeed = 0.0; if (bgp_clockspeed == 0.0) { _BGP_Personality_t mybgp; Kernel_GetPersonality(&mybgp, sizeof(_BGP_Personality_t)); bgp_clockspeed = 1.0 / (double)BGP_Personality_clockMHz(&mybgp); } values[idx] = (_bgp_GetTimeBase() * bgp_clockspeed); #else /* TAU_BGPTIMERS */ printf("TAU: Error: You must specify -BGPTIMERS at configure time\n"); values[idx] = 0; #endif /* TAU_BGPTIMERS */ #endif /* TAU_BGP */ }
/* local or global wall-clock time */ uint64_t vt_pform_wtime() { #if TIMER == TIMER_RTS_GET_TIMEBASE return (uint64_t)rts_get_timebase(); #elif TIMER == TIMER_PAPI_REAL_CYC return vt_metric_real_cyc(); #elif TIMER == TIMER_PAPI_REAL_USEC return vt_metric_real_usec() - vt_time_base; #endif }
// returns time in nanoseconds. timing_t get_time_ns () { static double ns_per_cycle; static int set_ns = 0; if (!set_ns) { set_ns = 1; ns_per_cycle = get_ns_per_cycle(); } return (timing_t)(ns_per_cycle * rts_get_timebase()); }
double bsp_rdtsc() { static double bgl_clockspeed = 0.0; if (bgl_clockspeed == 0.0) { BGLPersonality mybgl; rts_get_personality(&mybgl, sizeof(BGLPersonality)); bgl_clockspeed = 1.0e6/(double)BGLPersonality_clockHz(&mybgl); } return (rts_get_timebase() * bgl_clockspeed); }
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; }
double bgl_wtime() { return ( rts_get_timebase() * clockspeed ); }
/* local or global wall-clock time in seconds */ double elg_pform_wtime() { return ( rts_get_timebase() * elg_clockspeed ); }