This source file includes following definitions.
- get_ts_gettimeofday
- get_ts_cycle
- get_ts_usec
1
2
3
4
5
6
7
8
9
10
11
12 #include "opal_config.h"
13
14 #include <stdlib.h>
15 #include <stdarg.h>
16 #include <stdio.h>
17 #include <unistd.h>
18
19 #include <string.h>
20
21 #include <errno.h>
22 #ifdef HAVE_SYS_TYPES_H
23 #include <sys/types.h>
24 #endif
25 #ifdef HAVE_SYS_TIME_H
26 #include <sys/time.h>
27 #endif
28 #ifdef HAVE_SYS_RESOURCE_H
29 #include <sys/resource.h>
30 #endif
31
32 #include "opal/constants.h"
33 #include "opal/runtime/opal_params.h"
34
35
36 #include "opal/class/opal_pointer_array.h"
37 #include "opal/class/opal_list.h"
38 #include "opal/util/timings.h"
39 #include "opal/util/output.h"
40 #include "opal/util/basename.h"
41 #include "opal/mca/timer/timer.h"
42
43 #include MCA_timer_IMPLEMENTATION_HEADER
44
45 static double get_ts_gettimeofday(void)
46 {
47 double ret;
48
49 struct timeval tv;
50 gettimeofday(&tv, NULL);
51 ret = tv.tv_sec;
52 ret += (double)tv.tv_usec / 1000000.0;
53 return ret;
54 }
55
56 #if OPAL_TIMER_CYCLE_NATIVE
57 static double get_ts_cycle(void)
58 {
59 return ((double) opal_timer_base_get_cycles()) / opal_timer_base_get_freq();
60 }
61 #endif
62
63 #if OPAL_TIMER_USEC_NATIVE
64 static double get_ts_usec(void)
65 {
66 return ((double) opal_timer_base_get_usec()) / 1000000.0;
67 }
68 #endif
69
70 opal_timing_ts_func_t opal_timing_ts_func(opal_timer_type_t type)
71 {
72 switch (type) {
73 case OPAL_TIMING_GET_TIME_OF_DAY:
74 return get_ts_gettimeofday;
75
76 case OPAL_TIMING_CYCLE_NATIVE:
77 #if OPAL_TIMER_CYCLE_NATIVE
78 return get_ts_cycle;
79 #else
80 return NULL;
81 #endif
82 case OPAL_TIMING_USEC_NATIVE:
83 #if OPAL_TIMER_USEC_NATIVE
84 return get_ts_usec;
85 #else
86 return NULL;
87 #endif
88 default:
89 if( !opal_initialized ){
90 return get_ts_gettimeofday;
91 }
92 #if OPAL_TIMER_CYCLE_NATIVE
93 return get_ts_cycle;
94 #elif OPAL_TIMER_USEC_NATIVE
95 return get_ts_usec;
96 #endif
97 return get_ts_gettimeofday;
98 }
99 }
100