libflame
revision_anchor
|
Functions | |
double | FLA_Clock_helper (void) |
double | FLA_Clock () |
void | detect_clocks (void) |
void | rdtsc (unsigned int *high, unsigned int *low) |
Variables | |
double | gtod_ref_time_sec = 0.0 |
void detect_clocks | ( | void | ) |
References rdtsc().
{ FILE *infile; char buffer[256], *p; #ifdef __i386__ unsigned int high, low; #endif if ( clocks == 0.0 ) { p = (char *)NULL; infile = fopen("/proc/cpuinfo", "r"); while (fgets(buffer, sizeof(buffer), infile)) { if (!strncmp("cpu MHz", buffer, 6)) { p = strchr(buffer, ':') + 1; break; } } clocks = 1.e6 * atof(p); #ifdef __i386__ rdtsc(&high, &low); initialclockoffset = high; #endif } }
double FLA_Clock | ( | void | ) |
References FLA_Clock_helper().
Referenced by FLASH_Queue_begin(), FLASH_Queue_end(), and FLASH_Queue_exec().
{ return FLA_Clock_helper(); }
double FLA_Clock_helper | ( | void | ) |
References gtod_ref_time_sec.
Referenced by FLA_Clock().
{ #ifdef FLA_ENABLE_TIDSP double the_time; the_time = 0.0; #else #ifdef FLA_PORTABLE_TIMER_IS_CLOCK_GETTIME double the_time, norm_sec; struct timespec tsp; clock_gettime( CLOCK_REALTIME, &tsp ); // If this is the first invocation of through FLA_Clock(), then initialize // the "reference time" global variable to the seconds field of the tv // struct. if ( gtod_ref_time_sec == 0.0 ) gtod_ref_time_sec = ( double ) tsp.tv_sec; // Normalize the seconds field of the tv struct so that it is relative to the // "reference time" that was recorded during the first invocation of // FLA_Clock(). norm_sec = ( double ) tsp.tv_sec - gtod_ref_time_sec; // Compute the number of seconds since the reference time. the_time = norm_sec + tsp.tv_nsec * 1.0e-9; #else #ifdef FLA_PORTABLE_TIMER_IS_GETTIMEOFDAY double the_time, norm_sec; struct timeval tv; gettimeofday( &tv, NULL ); // If this is the first invocation of through FLA_Clock(), then initialize // the "reference time" global variable to the seconds field of the tv // struct. if ( gtod_ref_time_sec == 0.0 ) gtod_ref_time_sec = ( double ) tv.tv_sec; // Normalize the seconds field of the tv struct so that it is relative to the // "reference time" that was recorded during the first invocation of // FLA_Clock(). norm_sec = ( double ) tv.tv_sec - gtod_ref_time_sec; // Compute the number of seconds since the reference time. the_time = norm_sec + tv.tv_usec * 1.0e-6; #else //#ifdef FLA_PORTABLE_TIMER_IS_UNKNOWN the_time = 0.0; #endif #endif #endif return the_time; }
void rdtsc | ( | unsigned int * | high, |
unsigned int * | low | ||
) | [inline] |
Referenced by detect_clocks().
{ asm("rdtsc" : "=a" (*low), "=d"(*high): : "cc"); }
double gtod_ref_time_sec = 0.0 |
Referenced by FLA_Clock_helper().