| The Gaudi Framework v32r1 (f65d50dc)

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 <stdint.h>
14 #include <sys/types.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 * pfm_create flags:
87 * bits[00-15]: generic flags
88 * bits[16-31]: arch-specific flags (see perfmon_const.h)
89 */
90 #define PFM_FL_NOTIFY_BLOCK 0x01 /* block task on user notifications */
91 #define PFM_FL_SYSTEM_WIDE 0x02 /* create a system wide context */
92 #define PFM_FL_SMPL_FMT 0x04 /* session uses sampling format */
93 #define PFM_FL_OVFL_NO_MSG 0x80 /* no overflow msgs */
94
95 /*
96 * PMC and PMD generic (simplified) register description
97 */
98 typedef struct {
99 uint16_t reg_num; /* which register */
100 uint16_t reg_set; /* which event set */
101 uint32_t reg_flags; /* REGFL flags */
102 uint64_t reg_value; /* 64-bit value */
103 } pfarg_pmr_t;
104
105 /*
106 * pfarg_pmr_t flags:
107 * bit[00-15] : generic flags
108 * bit[16-31] : arch-specific flags
109 *
110 * PFM_REGFL_NO_EMUL64: must be set on the PMC controlling the PMD
111 */
112 #define PFM_REGFL_OVFL_NOTIFY 0x1 /* PMD: send notification on event */
113 #define PFM_REGFL_RANDOM 0x2 /* PMD: randomize value after event */
114 #define PFM_REGFL_NO_EMUL64 0x4 /* PMC: no 64-bit emulation */
115
116 /*
117 * PMD extended description
118 * to be used with pfm_writeand pfm_read
119 * must be used with type = PFM_RW_PMD_ATTR
120 */
121 typedef struct {
122 uint16_t reg_num; /* which register */
123 uint16_t reg_set; /* which event set */
124 uint32_t reg_flags; /* REGFL flags */
125 uint64_t reg_value; /* 64-bit value */
126 uint64_t reg_long_reset; /* write: value to reload after notification */
127 uint64_t reg_short_reset; /* write: reset after counter overflow */
128 uint64_t reg_random_mask; /* write: bitmask used to limit random value */
129 uint64_t reg_smpl_pmds[PFM_PMD_BV]; /* write: record in sample */
130 uint64_t reg_reset_pmds[PFM_PMD_BV]; /* write: reset on overflow */
131 uint64_t reg_ovfl_swcnt; /* write: # overflows before switch */
132 uint64_t reg_smpl_eventid; /* write: opaque event identifier */
133 uint64_t reg_last_value; /* read: PMD last reset value */
134 uint64_t reg_reserved[8]; /* for future use */
135 } pfarg_pmd_attr_t;
136
137 /*
138 * pfm_write, pfm_read type:
139 */
140 #define PFM_RW_PMD 1 /* simplified PMD (pfarg_pmr_t) */
141 #define PFM_RW_PMC 2 /* PMC registers (pfarg_pmr_t) */
142 #define PFM_RW_PMD_ATTR 3 /* extended PMD (pfarg_pmd_attr) */
143
144 /*
145 * pfm_attach special target for detach
146 */
147 #define PFM_NO_TARGET -1 /* no target, detach */
148
149 /*
150 * pfm_set_state state:
151 */
152 #define PFM_ST_START 0x1 /* start monitoring */
153 #define PFM_ST_STOP 0x2 /* stop monitoring */
154 #define PFM_ST_RESTART 0x3 /* resume after notify */
155
156 #ifndef PFMLIB_OLD_PFMV2
157 typedef struct {
158 uint16_t set_id; /* which set */
159 uint16_t set_reserved1; /* for future use */
160 uint32_t set_flags; /* SETFL flags */
161 uint64_t set_timeout; /* requested/effective switch timeout in nsecs */
162 uint64_t reserved[6]; /* for future use */
163 } pfarg_set_desc_t;
164
165 typedef struct {
166 uint16_t set_id; /* which set */
167 uint16_t set_reserved1; /* for future use */
168 uint32_t set_reserved2; /* for future use */
169 uint64_t set_ovfl_pmds[PFM_PMD_BV]; /* out: last ovfl PMDs */
170 uint64_t set_runs; /* out: #times set was active */
171 uint64_t set_timeout; /* out: leftover switch timeout (nsecs) */
172 uint64_t set_duration; /* out: time set was active (nsecs) */
173 uint64_t set_reserved3[4]; /* for future use */
174 } pfarg_set_info_t;
175 #endif
176
177 /*
178 * pfm_set_desc_t flags:
179 */
180 #define PFM_SETFL_OVFL_SWITCH 0x01 /* enable switch on overflow (subject to individual switch_cnt */
181 #define PFM_SETFL_TIME_SWITCH 0x02 /* switch set on timeout */
182
183 #ifndef PFMLIB_OLD_PFMV2
184 typedef struct {
185 uint32_t msg_type; /* PFM_MSG_OVFL */
186 uint32_t msg_ovfl_pid; /* process id */
187 uint16_t msg_active_set; /* active set at the time of overflow */
188 uint16_t msg_ovfl_cpu; /* cpu on which the overflow occurred */
189 uint32_t msg_ovfl_tid; /* thread id */
190 uint64_t msg_ovfl_ip; /* instruction pointer where overflow interrupt happened */
191 uint64_t msg_ovfl_pmds[PFM_PMD_BV]; /* which PMDs overflowed */
192 } pfarg_ovfl_msg_t;
193
194 extern os_err_t pfm_write( int fd, int flags, int type, void* reg, size_t n );
195 extern os_err_t pfm_read( int fd, int flags, int type, void* reg, size_t n );
196 extern os_err_t pfm_set_state( int fd, int flags, int state );
197 extern os_err_t pfm_create_sets( int fd, int flags, pfarg_set_desc_t* s, size_t sz );
198 extern os_err_t pfm_getinfo_sets( int fd, int flags, pfarg_set_info_t* s, size_t sz );
199 extern os_err_t pfm_attach( int fd, int flags, int target );
200
201 #endif
202
203 #include "perfmon_v2.h"
204
205 typedef union {
206 uint32_t type;
207 pfarg_ovfl_msg_t pfm_ovfl_msg;
208 } pfarg_msg_t;
209
210 #define PFM_MSG_OVFL 1 /* an overflow happened */
211 #define PFM_MSG_END 2 /* thread to which context was attached ended */
212
213 #define PFM_VERSION_MAJOR( x ) ( ( ( x ) >> 16 ) & 0xffff )
214 #define PFM_VERSION_MINOR( x ) ( (x)&0xffff )
215
216 #ifdef __cplusplus
217 }
218 #endif
219
220 #endif /* _PERFMON_H */
pfarg_pmr_t::reg_value
uint64_t reg_value
Definition: perfmon.h:102
pfarg_set_desc_t
Definition: perfmon.h:157
gaudirun.fd
fd
Definition: gaudirun.py:559
pfarg_pmd_attr_t::reg_ovfl_swcnt
uint64_t reg_ovfl_swcnt
Definition: perfmon.h:131
pfarg_set_desc_t::set_flags
uint32_t set_flags
Definition: perfmon.h:160
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:188
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:121
pfarg_set_info_t::set_id
uint16_t set_id
Definition: perfmon.h:166
pfarg_ovfl_msg_t::msg_ovfl_pid
uint32_t msg_ovfl_pid
Definition: perfmon.h:186
pfarg_pmd_attr_t::reg_random_mask
uint64_t reg_random_mask
Definition: perfmon.h:128
perfmon_v2.h
os_err_t
int os_err_t
Definition: perfmon.h:69
uint64_t
unsigned long long uint64_t
Definition: instrset.h:143
pfarg_pmr_t::reg_set
uint16_t reg_set
Definition: perfmon.h:100
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:132
pfarg_ovfl_msg_t
Definition: perfmon.h:184
uint16_t
unsigned short int uint16_t
Definition: instrset.h:139
pfarg_msg_t::type
uint32_t type
Definition: perfmon.h:206
pfarg_pmd_attr_t::reg_short_reset
uint64_t reg_short_reset
Definition: perfmon.h:127
pfarg_ovfl_msg_t::msg_ovfl_ip
uint64_t msg_ovfl_ip
Definition: perfmon.h:190
pfarg_sinfo_t
Definition: perfmon.h:75
pfarg_ovfl_msg_t::msg_ovfl_tid
uint32_t msg_ovfl_tid
Definition: perfmon.h:189
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)
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:210
perfmon_x86_64.h
pfarg_set_info_t
Definition: perfmon.h:165
pfarg_pmd_attr_t::reg_value
uint64_t reg_value
Definition: perfmon.h:125
gaudirun.type
type
Definition: gaudirun.py:142
pfarg_pmr_t::reg_flags
uint32_t reg_flags
Definition: perfmon.h:101
pfarg_set_desc_t::set_timeout
uint64_t set_timeout
Definition: perfmon.h:161
compareRootHistos.state
def state
Definition: compareRootHistos.py:455
pfarg_pmd_attr_t::reg_long_reset
uint64_t reg_long_reset
Definition: perfmon.h:126
pfarg_msg_t::pfm_ovfl_msg
pfarg_ovfl_msg_t pfm_ovfl_msg
Definition: perfmon.h:207
pfarg_set_desc_t::set_reserved1
uint16_t set_reserved1
Definition: perfmon.h:159
pfarg_set_info_t::set_timeout
uint64_t set_timeout
Definition: perfmon.h:171
uint32_t
unsigned int uint32_t
Definition: instrset.h:141
pfarg_set_info_t::set_duration
uint64_t set_duration
Definition: perfmon.h:172
pfarg_pmd_attr_t::reg_flags
uint32_t reg_flags
Definition: perfmon.h:124
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:98
pfarg_set_info_t::set_reserved1
uint16_t set_reserved1
Definition: perfmon.h:167
pfarg_ovfl_msg_t::msg_active_set
uint16_t msg_active_set
Definition: perfmon.h:187
PFM_PMD_BV
#define PFM_PMD_BV
Definition: perfmon.h:57
pfarg_msg_t
Definition: perfmon.h:205
gaudirun.s
string s
Definition: gaudirun.py:316
pfarg_set_info_t::set_reserved2
uint32_t set_reserved2
Definition: perfmon.h:168
pfarg_pmr_t::reg_num
uint16_t reg_num
Definition: perfmon.h:99
pfarg_ovfl_msg_t::msg_type
uint32_t msg_type
Definition: perfmon.h:185
pfarg_pmd_attr_t::reg_set
uint16_t reg_set
Definition: perfmon.h:123
pfarg_set_info_t::set_runs
uint64_t set_runs
Definition: perfmon.h:170
pfarg_set_desc_t::set_id
uint16_t set_id
Definition: perfmon.h:158
pfarg_pmd_attr_t::reg_num
uint16_t reg_num
Definition: perfmon.h:122
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:133