| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

perfmon.h
Go to the documentation of this file.
1 /*
2 * This file contains the user level interface description for
3 * the perfmon3.x interface on Linux.
4 *
5 * It also includes perfmon2.x interface definitions.
6 *
7 * Copyright (c) 2001-2006 Hewlett-Packard Development Company, L.P.
8 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
9 */
10 #ifndef __PERFMON_H__
11 #define __PERFMON_H__
12
13 #include <sys/types.h>
14 #include <stdint.h>
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 #ifdef __ia64__
21 #include <perfmon/perfmon_ia64.h>
22 #endif
23
24 #ifdef __x86_64__
25 #include <perfmon/perfmon_x86_64.h>
26 #endif
27
28 #ifdef __i386__
29 #include <perfmon/perfmon_i386.h>
30 #endif
31
32 #if defined(__powerpc__) || defined(__cell__)
33 #include <perfmon/perfmon_powerpc.h>
34 #endif
35
36 #ifdef __sparc__
37 #include <perfmon/perfmon_sparc.h>
38 #endif
39
40 #ifdef __mips__
41 #include <perfmon/perfmon_mips64.h>
42 #endif
43
44 #ifdef __crayx2
45 #include <perfmon/perfmon_crayx2.h>
46 #endif
47
48 #define PFM_MAX_PMCS PFM_ARCH_MAX_PMCS
49 #define PFM_MAX_PMDS PFM_ARCH_MAX_PMDS
50
51 #ifndef SWIG
52 /*
53 * number of element for each type of bitvector
54 */
55 #define PFM_BPL (sizeof(uint64_t)<<3)
56 #define PFM_BVSIZE(x) (((x)+PFM_BPL-1) / PFM_BPL)
57 #define PFM_PMD_BV PFM_BVSIZE(PFM_MAX_PMDS)
58 #define PFM_PMC_BV PFM_BVSIZE(PFM_MAX_PMCS)
59 #endif
60
61 /*
62 * special data type for syscall error value used to help
63 * with Python support and in particular for SWIG. By using
64 * a specific type we can detect syscalls and trap errors
65 * in one SWIG statement as opposed to having to keep track of
66 * each syscall individually. Programs can use 'int' safely for
67 * the return value.
68 */
69 typedef int os_err_t; /* error if -1 */
70
71 /*
72 * passed to pfm_create
73 * contains list of available register upon return
74 */
75 typedef struct {
76 uint64_t sif_avail_pmcs[PFM_PMC_BV]; /* out: available PMCs */
77 uint64_t sif_avail_pmds[PFM_PMD_BV]; /* out: available PMDs */
78 uint64_t sif_reserved[4];
79 } pfarg_sinfo_t;
80
81 //os_err_t pfm_create(int flags, pfarg_sinfo_t *sif,
82 // char *smpl_name, void *smpl_arg, size_t arg_size);
83 extern os_err_t pfm_create(int flags, pfarg_sinfo_t *sif, ...);
84
85
86 /*
87 * pfm_create flags:
88 * bits[00-15]: generic flags
89 * bits[16-31]: arch-specific flags (see perfmon_const.h)
90 */
91 #define PFM_FL_NOTIFY_BLOCK 0x01 /* block task on user notifications */
92 #define PFM_FL_SYSTEM_WIDE 0x02 /* create a system wide context */
93 #define PFM_FL_SMPL_FMT 0x04 /* session uses sampling format */
94 #define PFM_FL_OVFL_NO_MSG 0x80 /* no overflow msgs */
95
96 /*
97 * PMC and PMD generic (simplified) register description
98 */
99 typedef struct {
100 uint16_t reg_num; /* which register */
101 uint16_t reg_set; /* which event set */
102 uint32_t reg_flags; /* REGFL flags */
103 uint64_t reg_value; /* 64-bit value */
104 } pfarg_pmr_t;
105
106 /*
107 * pfarg_pmr_t flags:
108 * bit[00-15] : generic flags
109 * bit[16-31] : arch-specific flags
110 *
111 * PFM_REGFL_NO_EMUL64: must be set on the PMC controlling the PMD
112 */
113 #define PFM_REGFL_OVFL_NOTIFY 0x1 /* PMD: send notification on event */
114 #define PFM_REGFL_RANDOM 0x2 /* PMD: randomize value after event */
115 #define PFM_REGFL_NO_EMUL64 0x4 /* PMC: no 64-bit emulation */
116
117 /*
118 * PMD extended description
119 * to be used with pfm_writeand pfm_read
120 * must be used with type = PFM_RW_PMD_ATTR
121 */
122 typedef struct {
123 uint16_t reg_num; /* which register */
124 uint16_t reg_set; /* which event set */
125 uint32_t reg_flags; /* REGFL flags */
126 uint64_t reg_value; /* 64-bit value */
127 uint64_t reg_long_reset; /* write: value to reload after notification */
128 uint64_t reg_short_reset; /* write: reset after counter overflow */
129 uint64_t reg_random_mask; /* write: bitmask used to limit random value */
130 uint64_t reg_smpl_pmds[PFM_PMD_BV]; /* write: record in sample */
131 uint64_t reg_reset_pmds[PFM_PMD_BV]; /* write: reset on overflow */
132 uint64_t reg_ovfl_swcnt; /* write: # overflows before switch */
133 uint64_t reg_smpl_eventid; /* write: opaque event identifier */
134 uint64_t reg_last_value; /* read: PMD last reset value */
135 uint64_t reg_reserved[8]; /* for future use */
136 } pfarg_pmd_attr_t;
137
138
139 /*
140 * pfm_write, pfm_read type:
141 */
142 #define PFM_RW_PMD 1 /* simplified PMD (pfarg_pmr_t) */
143 #define PFM_RW_PMC 2 /* PMC registers (pfarg_pmr_t) */
144 #define PFM_RW_PMD_ATTR 3 /* extended PMD (pfarg_pmd_attr) */
145
146 /*
147 * pfm_attach special target for detach
148 */
149 #define PFM_NO_TARGET -1 /* no target, detach */
150
151
152 /*
153 * pfm_set_state state:
154 */
155 #define PFM_ST_START 0x1 /* start monitoring */
156 #define PFM_ST_STOP 0x2 /* stop monitoring */
157 #define PFM_ST_RESTART 0x3 /* resume after notify */
158
159 #ifndef PFMLIB_OLD_PFMV2
160 typedef struct {
161 uint16_t set_id; /* which set */
162 uint16_t set_reserved1; /* for future use */
163 uint32_t set_flags; /* SETFL flags */
164 uint64_t set_timeout; /* requested/effective switch timeout in nsecs */
165 uint64_t reserved[6]; /* for future use */
166 } pfarg_set_desc_t;
167
168 typedef struct {
169 uint16_t set_id; /* which set */
170 uint16_t set_reserved1; /* for future use */
171 uint32_t set_reserved2; /* for future use */
172 uint64_t set_ovfl_pmds[PFM_PMD_BV]; /* out: last ovfl PMDs */
173 uint64_t set_runs; /* out: #times set was active */
174 uint64_t set_timeout; /* out: leftover switch timeout (nsecs) */
175 uint64_t set_duration; /* out: time set was active (nsecs) */
176 uint64_t set_reserved3[4]; /* for future use */
177 } pfarg_set_info_t;
178 #endif
179
180 /*
181 * pfm_set_desc_t flags:
182 */
183 #define PFM_SETFL_OVFL_SWITCH 0x01 /* enable switch on overflow (subject to individual switch_cnt */
184 #define PFM_SETFL_TIME_SWITCH 0x02 /* switch set on timeout */
185
186 #ifndef PFMLIB_OLD_PFMV2
187 typedef struct {
188 uint32_t msg_type; /* PFM_MSG_OVFL */
189 uint32_t msg_ovfl_pid; /* process id */
190 uint16_t msg_active_set; /* active set at the time of overflow */
191 uint16_t msg_ovfl_cpu; /* cpu on which the overflow occurred */
192 uint32_t msg_ovfl_tid; /* thread id */
193 uint64_t msg_ovfl_ip; /* instruction pointer where overflow interrupt happened */
194 uint64_t msg_ovfl_pmds[PFM_PMD_BV];/* which PMDs overflowed */
195 } pfarg_ovfl_msg_t;
196
197 extern os_err_t pfm_write(int fd, int flags, int type, void *reg, size_t n);
198 extern os_err_t pfm_read(int fd, int flags, int type, void *reg, size_t n);
199 extern os_err_t pfm_set_state(int fd, int flags, int state);
200 extern os_err_t pfm_create_sets(int fd, int flags, pfarg_set_desc_t *s, size_t sz);
201 extern os_err_t pfm_getinfo_sets(int fd, int flags, pfarg_set_info_t *s, size_t sz);
202 extern os_err_t pfm_attach(int fd, int flags, int target);
203
204 #endif
205
206 #include "perfmon_v2.h"
207
208 typedef union {
209 uint32_t type;
210 pfarg_ovfl_msg_t pfm_ovfl_msg;
211 } pfarg_msg_t;
212
213 #define PFM_MSG_OVFL 1 /* an overflow happened */
214 #define PFM_MSG_END 2 /* thread to which context was attached ended */
215
216 #define PFM_VERSION_MAJOR(x) (((x)>>16) & 0xffff)
217 #define PFM_VERSION_MINOR(x) ((x) & 0xffff)
218
219 #ifdef __cplusplus
220 }
221 #endif
222
223 #endif /* _PERFMON_H */
compareRootHistos.state
tuple state
Definition: compareRootHistos.py:348
pfarg_pmr_t::reg_value
uint64_t reg_value
Definition: perfmon.h:103
pfarg_set_desc_t
Definition: perfmon.h:160
pfarg_pmd_attr_t::reg_ovfl_swcnt
uint64_t reg_ovfl_swcnt
Definition: perfmon.h:132
pfarg_set_desc_t::set_flags
uint32_t set_flags
Definition: perfmon.h:163
PFM_PMC_BV
#define PFM_PMC_BV
Definition: perfmon.h:58
pfarg_ovfl_msg_t::msg_ovfl_cpu
uint16_t msg_ovfl_cpu
Definition: perfmon.h:191
pfm_read
os_err_t pfm_read(int fd, int flags, int type, void *reg, size_t n)
pfarg_pmd_attr_t
Definition: perfmon.h:122
pfarg_set_info_t::set_id
uint16_t set_id
Definition: perfmon.h:169
pfarg_ovfl_msg_t::msg_ovfl_pid
uint32_t msg_ovfl_pid
Definition: perfmon.h:189
pfarg_pmd_attr_t::reg_random_mask
uint64_t reg_random_mask
Definition: perfmon.h:129
perfmon_v2.h
os_err_t
int os_err_t
Definition: perfmon.h:69
uint64_t
unsigned long long uint64_t
Definition: instrset.h:144
pfarg_pmr_t::reg_set
uint16_t reg_set
Definition: perfmon.h:101
pfm_attach
os_err_t pfm_attach(int fd, int flags, int target)
pfarg_pmd_attr_t::reg_smpl_eventid
uint64_t reg_smpl_eventid
Definition: perfmon.h:133
pfarg_ovfl_msg_t
Definition: perfmon.h:187
uint16_t
unsigned short int uint16_t
Definition: instrset.h:140
pfarg_msg_t::type
uint32_t type
Definition: perfmon.h:209
pfarg_pmd_attr_t::reg_short_reset
uint64_t reg_short_reset
Definition: perfmon.h:128
pfarg_ovfl_msg_t::msg_ovfl_ip
uint64_t msg_ovfl_ip
Definition: perfmon.h:193
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
pfarg_sinfo_t
Definition: perfmon.h:75
pfarg_ovfl_msg_t::msg_ovfl_tid
uint32_t msg_ovfl_tid
Definition: perfmon.h:192
pfm_create_sets
os_err_t pfm_create_sets(int fd, int flags, pfarg_set_desc_t *s, size_t sz)
pfm_getinfo_sets
os_err_t pfm_getinfo_sets(int fd, int flags, pfarg_set_info_t *s, size_t sz)
gaudirun.type
string type
Definition: gaudirun.py:151
perfmon_x86_64.h
pfarg_set_info_t
Definition: perfmon.h:168
pfarg_pmd_attr_t::reg_value
uint64_t reg_value
Definition: perfmon.h:126
pfarg_pmr_t::reg_flags
uint32_t reg_flags
Definition: perfmon.h:102
pfarg_set_desc_t::set_timeout
uint64_t set_timeout
Definition: perfmon.h:164
pfarg_pmd_attr_t::reg_long_reset
uint64_t reg_long_reset
Definition: perfmon.h:127
pfarg_msg_t::pfm_ovfl_msg
pfarg_ovfl_msg_t pfm_ovfl_msg
Definition: perfmon.h:210
pfarg_set_desc_t::set_reserved1
uint16_t set_reserved1
Definition: perfmon.h:162
pfarg_set_info_t::set_timeout
uint64_t set_timeout
Definition: perfmon.h:174
uint32_t
unsigned int uint32_t
Definition: instrset.h:142
pfarg_set_info_t::set_duration
uint64_t set_duration
Definition: perfmon.h:175
pfarg_pmd_attr_t::reg_flags
uint32_t reg_flags
Definition: perfmon.h:125
pfm_create
os_err_t pfm_create(int flags, pfarg_sinfo_t *sif,...)
pfm_set_state
os_err_t pfm_set_state(int fd, int flags, int state)
perfmon_i386.h
pfarg_pmr_t
Definition: perfmon.h:99
pfarg_set_info_t::set_reserved1
uint16_t set_reserved1
Definition: perfmon.h:170
pfarg_ovfl_msg_t::msg_active_set
uint16_t msg_active_set
Definition: perfmon.h:190
PFM_PMD_BV
#define PFM_PMD_BV
Definition: perfmon.h:57
pfarg_msg_t
Definition: perfmon.h:208
gaudirun.s
string s
Definition: gaudirun.py:245
pfarg_set_info_t::set_reserved2
uint32_t set_reserved2
Definition: perfmon.h:171
pfarg_pmr_t::reg_num
uint16_t reg_num
Definition: perfmon.h:100
pfarg_ovfl_msg_t::msg_type
uint32_t msg_type
Definition: perfmon.h:188
pfarg_pmd_attr_t::reg_set
uint16_t reg_set
Definition: perfmon.h:124
pfarg_set_info_t::set_runs
uint64_t set_runs
Definition: perfmon.h:173
pfarg_set_desc_t::set_id
uint16_t set_id
Definition: perfmon.h:161
pfarg_pmd_attr_t::reg_num
uint16_t reg_num
Definition: perfmon.h:123
pfm_write
os_err_t pfm_write(int fd, int flags, int type, void *reg, size_t n)
pfarg_pmd_attr_t::reg_last_value
uint64_t reg_last_value
Definition: perfmon.h:134