void util_read_real_time(void *it) { /* fortran out: integer*4:: it(4) * raw values - not yet scaled to real time */ read_real_time( (struct timebasestruct*) it, TIMEBASE_SZ ); }
static void _MD_AixIntervalInit(void) { timebasestruct_t real_time; read_real_time(&real_time, TIMEBASE_SZ); (void)time_base_to_time(&real_time, TIMEBASE_SZ); _aix_baseline_epoch = real_time.tb_high; } /* _MD_AixIntervalInit */
/* platform specific initialization */ void vt_pform_init() { int pid = getpid(); char exec_proc[512]; int hostid_retries; #if TIMER == TIMER_SWITCH_CLOCK int i; for (i=0; i<NUMRETRY; i++) { if ( (vt_swclk = swclockInit()) != 0 ) break; } #elif TIMER == TIMER_POWER_REALTIME timebasestruct_t t; read_real_time(&t, TIMEBASE_SZ); time_base_to_time(&t, TIMEBASE_SZ); vt_time_base = t.tb_high - (t.tb_high & 0xFFFF); #elif TIMER == TIMER_PAPI_REAL_USEC vt_time_base = vt_metric_real_usec(); #endif /* get full path of executable */ snprintf(exec_proc, sizeof (exec_proc), VT_PROCDIR"%d/object/a.out", pid); vt_exec = strdup(exec_proc); /* get unique numeric SMP-node identifier */ hostid_retries = 0; while( !vt_node_id && (hostid_retries++ < VT_MAX_GETHOSTID_RETRIES) ) { vt_node_id = gethostid(); } if (!vt_node_id) vt_error_msg("Maximum retries (%i) for gethostid exceeded!", VT_MAX_GETHOSTID_RETRIES); }
BOOL PALAPI QueryPerformanceCounter( OUT LARGE_INTEGER *lpPerformanceCount ) { BOOL retval = TRUE; PERF_ENTRY(QueryPerformanceCounter); ENTRY("QueryPerformanceCounter()\n"); #if HAVE_CLOCK_MONOTONIC { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { ASSERT("clock_gettime(CLOCK_MONOTONIC) failed; errno is %d (%s)\n", errno, strerror(errno)); retval = FALSE; goto EXIT; } lpPerformanceCount->QuadPart = (LONGLONG)ts.tv_sec * (LONGLONG)tccSecondsToNanoSeconds + (LONGLONG)ts.tv_nsec; } #elif HAVE_GETHRTIME { lpPerformanceCount->QuadPart = (LONGLONG)gethrtime(); } #elif HAVE_READ_REAL_TIME { timebasestruct_t tb; read_real_time(&tb, TIMEBASE_SZ); if (time_base_to_time(&tb, TIMEBASE_SZ) != 0) { ASSERT("time_base_to_time() failed; errno is %d (%s)\n", errno, strerror(errno)); retval = FALSE; goto EXIT; } lpPerformanceCount->QuadPart = (LONGLONG)tb.tb_high * (LONGLONG)tccSecondsToNanoSeconds + (LONGLONG)tb.tb_low; } #else { struct timeval tv; if (gettimeofday(&tv, NULL) == -1) { ASSERT("gettimeofday() failed; errno is %d (%s)\n", errno, strerror(errno)); retval = FALSE; goto EXIT; } lpPerformanceCount->QuadPart = (LONGLONG)tv.tv_sec * (LONGLONG)tccSecondsToMicroSeconds + (LONGLONG)tv.tv_usec; } #endif // HAVE_CLOCK_MONOTONIC EXIT: LOGEXIT("QueryPerformanceCounter\n"); PERF_EXIT(QueryPerformanceCounter); return retval; }
double LATL::Timer::Clock() { double t; timebasestruct_t T; read_real_time(&T,TIMEBASE_SZ); time_base_to_time(&T,TIMEBASE_SZ); t=(double)(T.tb_low)*1.0e-03+(double)(T.tb_high)*1.0e+6; return t; }
PRIntervalTime _MD_AixGetInterval(void) { PRIntn rv; PRUint64 temp; timebasestruct_t real_time; read_real_time(&real_time, TIMEBASE_SZ); (void)time_base_to_time(&real_time, TIMEBASE_SZ); /* tb_high is in seconds, tb_low in 10(-9)seconds */ temp = 1000000000ULL * (PRUint64)(real_time.tb_high - _aix_baseline_epoch); temp += (PRUint64)real_time.tb_low; /* everything's 10(-9) seconds */ temp >>= 16; /* now it's something way different */ return (PRIntervalTime)temp; } /* _MD_AixGetInterval */
/* platform specific initialization */ void elg_pform_init() { #ifdef USE_SWITCH_CLOCK int i; for (i=0; i<NUMRETRY; i++) { if ( (elg_swclk = swclockInit()) != 0 ) break; } #else timebasestruct_t t; read_real_time(&t, TIMEBASE_SZ); time_base_to_time(&t, TIMEBASE_SZ); elg_time_base = t.tb_high - (t.tb_high & 0xFFFF); #endif }
double wtime(void) { struct timebasestruct TB; static int first_call; static double tb_factor; double tb_top,tb_bot; if (first_call == 0) { first_call = 1; tb_top = (double) _system_configuration.Xint; tb_bot = (double) _system_configuration.Xfrac; tb_factor = tb_top/tb_bot; } read_real_time(&TB, TIMEBASE_SZ); return ( tb_factor * ( 4.294967296*((double) TB.tb_high) + 1.0e-9*((double) TB.tb_low) ) ); }
/* local or global wall-clock time in seconds */ double elg_pform_wtime() { #ifdef USE_SWITCH_CLOCK int i; double t; for (i=0; i<NUMRETRY; i++) { if ( (t = swclockReadSec(elg_swclk)) != -1.0 ) return t; } return -1.0; #else timebasestruct_t t; read_real_time(&t, TIMEBASE_SZ); time_base_to_time(&t, TIMEBASE_SZ); return (t.tb_high - elg_time_base) + (t.tb_low * 1.0e-9); #endif }
/*++ Function: GetTickCount64 Returns a 64-bit tick count with a millisecond resolution. It tries its best to return monotonically increasing counts and avoid being affected by changes to the system clock (either due to drift or due to explicit changes to system time). --*/ PALAPI ULONGLONG GetTickCount64() { ULONGLONG retval = 0; #if HAVE_CLOCK_MONOTONIC { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { ASSERT("clock_gettime(CLOCK_MONOTONIC) failed; errno is %d (%s)\n", errno, strerror(errno)); goto EXIT; } retval = (ts.tv_sec * tccSecondsToMillieSeconds)+(ts.tv_nsec / tccMillieSecondsToNanoSeconds); } #elif HAVE_GETHRTIME { retval = (ULONGLONG)(gethrtime() / tccMillieSecondsToNanoSeconds); } #elif HAVE_READ_REAL_TIME { timebasestruct_t tb; read_real_time(&tb, TIMEBASE_SZ); if (time_base_to_time(&tb, TIMEBASE_SZ) != 0) { ASSERT("time_base_to_time() failed; errno is %d (%s)\n", errno, strerror(errno)); goto EXIT; } retval = (tb.tb_high * tccSecondsToMillieSeconds)+(tb.tb_low / tccMillieSecondsToNanoSeconds); } #else { struct timeval tv; if (gettimeofday(&tv, NULL) == -1) { ASSERT("gettimeofday() failed; errno is %d (%s)\n", errno, strerror(errno)); goto EXIT; } retval = (tv.tv_sec * tccSecondsToMillieSeconds) + (tv.tv_usec / tccMillieSecondsToMicroSeconds); } #endif // HAVE_CLOCK_MONOTONIC EXIT: return retval; }
PetscLogDouble PetscReadRealTime(void) { timebasestruct_t t; PetscLogDouble time; PetscFunctionBegin; /* read in the register values */ read_real_time(&t,TIMEBASE_SZ); /* * Call the conversion routines unconditionally, to ensure * that both values are in seconds and nanoseconds regardless * of the hardware platform. */ time_base_to_time(&t,TIMEBASE_SZ); time = t.tb_high + t.tb_low*1.0e-9; PetscFunctionReturn(time); }
/* local or global wall-clock time */ uint64_t vt_pform_wtime() { #if TIMER == TIMER_SWITCH_CLOCK int i; int64_t t; for (i=0; i<NUMRETRY; i++) { if ( (t = swclockRead(vt_swclk)) != -1 ) return t; } return 0; #elif TIMER == TIMER_POWER_REALTIME timebasestruct_t t; read_real_time(&t, TIMEBASE_SZ); time_base_to_time(&t, TIMEBASE_SZ); return ((t.tb_high - vt_time_base) * 1e9) + t.tb_low; #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 }