OpenMPI  0.1.1
timer_darwin.h
1 /*
2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3  * University Research and Technology
4  * Corporation. All rights reserved.
5  * Copyright (c) 2004-2005 The University of Tennessee and The University
6  * of Tennessee Research Foundation. All rights
7  * reserved.
8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9  * University of Stuttgart. All rights reserved.
10  * Copyright (c) 2004-2005 The Regents of the University of California.
11  * All rights reserved.
12  * $COPYRIGHT$
13  *
14  * Additional copyrights may follow
15  *
16  * $HEADER$
17  */
18 
19 #ifndef OPAL_MCA_TIMER_DARWIN_TIMER_DARWIN_H
20 #define OPAL_MCA_TIMER_DARWIN_TIMER_DARWIN_H
21 
22 #include "opal_config.h"
23 #include <mach/mach_time.h>
24 
25 typedef uint64_t opal_timer_t;
26 
27 /* frequency in mhz */
28 OPAL_DECLSPEC extern opal_timer_t opal_timer_darwin_freq;
29 
30 
31 static inline opal_timer_t
32 opal_timer_base_get_cycles(void)
33 {
34  /* this is basically a wrapper around the "right" assembly to get
35  the tick counter off the PowerPC Time Base. I believe it's
36  something similar on x86 */
37  return mach_absolute_time();
38 }
39 
40 
41 static inline opal_timer_t
42 opal_timer_base_get_usec(void)
43 {
44  /* freq is in Hz, so this gives usec */
45  return mach_absolute_time() * 1000000 / opal_timer_darwin_freq;
46 }
47 
48 
49 static inline opal_timer_t
50 opal_timer_base_get_freq(void)
51 {
52  return opal_timer_darwin_freq;
53 }
54 
55 
56 #define OPAL_TIMER_CYCLE_NATIVE 1
57 #define OPAL_TIMER_CYCLE_SUPPORTED 1
58 #define OPAL_TIMER_USEC_NATIVE 0
59 #define OPAL_TIMER_USEC_SUPPORTED 1
60 
61 #endif