libflame revision_anchor
Functions | Variables
FLA_Clock.c File Reference

(r)

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
 

Function Documentation

◆ detect_clocks()

void detect_clocks ( void  )
208{
209 FILE *infile;
210 char buffer[256], *p;
211#ifdef __i386__
212 unsigned int high, low;
213#endif
214
215 if ( clocks == 0.0 )
216 {
217 p = (char *)NULL;
218 infile = fopen("/proc/cpuinfo", "r");
219 while (fgets(buffer, sizeof(buffer), infile))
220 {
221 if (!strncmp("cpu MHz", buffer, 6))
222 {
223 p = strchr(buffer, ':') + 1;
224 break;
225 }
226 }
227 clocks = 1.e6 * atof(p);
228#ifdef __i386__
229 rdtsc(&high, &low);
230 initialclockoffset = high;
231#endif
232 }
233}
int i
Definition bl1_axmyv2.c:145

References i.

◆ FLA_Clock()

double FLA_Clock ( void  )
21{
22 return FLA_Clock_helper();
23}
double FLA_Clock_helper(void)
Definition FLA_Clock.c:40

References FLA_Clock_helper().

Referenced by FLASH_Queue_begin(), FLASH_Queue_end(), and FLASH_Queue_exec().

◆ FLA_Clock_helper()

double FLA_Clock_helper ( void  )
41{
42#ifdef FLA_ENABLE_TIDSP
43 double the_time;
44 the_time = 0.0;
45#else
46#ifdef FLA_PORTABLE_TIMER_IS_CLOCK_GETTIME
47 double the_time, norm_sec;
48 struct timespec tsp;
49
51
52 // If this is the first invocation of through FLA_Clock(), then initialize
53 // the "reference time" global variable to the seconds field of the tv
54 // struct.
55 if ( gtod_ref_time_sec == 0.0 ) gtod_ref_time_sec = ( double ) tsp.tv_sec;
56
57 // Normalize the seconds field of the tv struct so that it is relative to the
58 // "reference time" that was recorded during the first invocation of
59 // FLA_Clock().
60 norm_sec = ( double ) tsp.tv_sec - gtod_ref_time_sec;
61
62 // Compute the number of seconds since the reference time.
63 the_time = norm_sec + tsp.tv_nsec * 1.0e-9;
64
65#else
66#ifdef FLA_PORTABLE_TIMER_IS_GETTIMEOFDAY
67
68 double the_time, norm_sec;
69 struct timeval tv;
70
71 gettimeofday( &tv, NULL );
72
73 // If this is the first invocation of through FLA_Clock(), then initialize
74 // the "reference time" global variable to the seconds field of the tv
75 // struct.
76 if ( gtod_ref_time_sec == 0.0 ) gtod_ref_time_sec = ( double ) tv.tv_sec;
77
78 // Normalize the seconds field of the tv struct so that it is relative to the
79 // "reference time" that was recorded during the first invocation of
80 // FLA_Clock().
81 norm_sec = ( double ) tv.tv_sec - gtod_ref_time_sec;
82
83 // Compute the number of seconds since the reference time.
84 the_time = norm_sec + tv.tv_usec * 1.0e-6;
85
86#else //#ifdef FLA_PORTABLE_TIMER_IS_UNKNOWN
87
88 the_time = 0.0;
89
90#endif
91#endif
92#endif
93
94 return the_time;
95}
double gtod_ref_time_sec
Definition FLA_Clock.c:34

References gtod_ref_time_sec, and i.

Referenced by FLA_Clock().

◆ rdtsc()

void rdtsc ( unsigned int high,
unsigned int low 
)
inline
147{
148 asm("rdtsc" : "=a" (*low), "=d"(*high): : "cc");
149}

Variable Documentation

◆ gtod_ref_time_sec

double gtod_ref_time_sec = 0.0

Referenced by FLA_Clock_helper().