ROSS
gtod.c
Go to the documentation of this file.
1 #include <ross.h>
2 
3 extern unsigned long long g_tw_clock_rate;
4 
5 static const tw_optdef clock_opts [] =
6 {
7  TWOPT_GROUP("ROSS Timing"),
8  TWOPT_ULONGLONG("clock-rate", g_tw_clock_rate, "CPU Clock Rate"),
9  TWOPT_END()
10 };
11 
13 {
14  return clock_opts;
15 }
16 
18 {
19 #ifdef ZERO_BASED
20  static volatile int inited = 0;
21  static volatile tw_clock base = 0;
22 #else
23  const tw_clock base = 0;
24 #endif
25 
26  const tw_clock scale = 1000000;
27  struct timeval tv;
28  gettimeofday(&tv,NULL);
29 
30 #ifdef ZERO_BASED
31  if(inited == 0) {
32  base = ((tw_clock) tv.tv_sec)*scale + (tw_clock) tv.tv_usec;
33  inited = 1;
34  }
35 #endif
36 
37  return
38  (((tw_clock) tv.tv_sec)*scale + (tw_clock) tv.tv_usec) - base;
39 }
40 
41 void
43 {
44  me->clock_time = 0;
46 }
47 
50 {
52  return me->clock_time;
53 }
const tw_optdef * tw_clock_setup(void)
Definition: gtod.c:12
static const tw_optdef clock_opts[]
Definition: gtod.c:5
unsigned long long g_tw_clock_rate
Definition: ross-global.c:98
Holds the entire PE state.
Definition: ross-types.h:375
#define TWOPT_ULONGLONG(n, v, h)
Definition: tw-opts.h:29
tw_clock tw_clock_read(void)
Definition: gtod.c:17
tw_clock clock_offset
Initial clock value for this PE.
Definition: ross-types.h:396
tw_clock clock_time
Most recent clock value for this PE.
Definition: ross-types.h:397
tw_clock tw_clock_now(tw_pe *me)
Definition: gtod.c:49
#define TWOPT_END()
Definition: tw-opts.h:35
uint64_t tw_clock
Definition: aarch64.h:4
#define TWOPT_GROUP(h)
Definition: tw-opts.h:27
void tw_clock_init(tw_pe *me)
Definition: gtod.c:42