OpenMPI  0.1.1
timer.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 OMPI_SYS_ARCH_TIMER_H
20 #define OMPI_SYS_ARCH_TIMER_H 1
21 
22 
23 typedef uint64_t opal_timer_t;
24 
25 
26 #if OMPI_GCC_INLINE_ASSEMBLY
27 
28 #if 0
29 static inline opal_timer_t
30 opal_sys_timer_get_cycles(void)
31 {
32  opal_timer_t ret;
33 
34  __asm__ __volatile__("rdtsc" : "=A"(ret));
35 
36  return ret;
37 }
38 
39 #else
40 
41 static inline opal_timer_t
42 opal_sys_timer_get_cycles(void)
43 {
44  unsigned a, d;
45  __asm__ __volatile__ ("rdtsc" : "=a" (a), "=d" (d));
46  return ((opal_timer_t)a) | (((opal_timer_t)d) << 32);
47 }
48 
49 #endif
50 
51 #define OPAL_HAVE_SYS_TIMER_GET_CYCLES 1
52 
53 #else
54 
55 opal_timer_t opal_sys_timer_get_cycles(void);
56 
57 #define OPAL_HAVE_SYS_TIMER_GET_CYCLES 1
58 
59 #endif /* OMPI_GCC_INLINE_ASSEMBLY */
60 
61 #endif /* ! OMPI_SYS_ARCH_TIMER_H */