PAPI 7.1.0.0
Loading...
Searching...
No Matches
perfmon_nec.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
17extern "C" {
18#endif
19
20#ifdef __ia64__
22#endif
23
24#ifdef __x86_64__
26#endif
27
28#ifdef __i386__
30#endif
31
32#if defined(__powerpc__) || defined(__cell__)
34#endif
35
36#ifdef __sparc__
38#endif
39
40#ifdef __mips__
42#endif
43
44#ifdef __crayx2
46#endif
47
48#define PFM_MAX_PMCS 8
49#define PFM_MAX_PMDS 8
50#define PFM_PMC_BV 8
51#define PFM_PMD_BV 8
52
53#ifndef SWIG
54/*
55 * number of element for each type of bitvector
56 */
57#define PFM_BPL (sizeof(uint64_t)<<3)
58#define PFM_BVSIZE(x) (((x)+PFM_BPL-1) / PFM_BPL)
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 */
69typedef int os_err_t; /* error if -1 */
70
71/*
72 * passed to pfm_create
73 * contains list of available register upon return
74 */
75
76typedef struct {
77 uint64_t sif_avail_pmcs[PFM_PMC_BV]; /* out: available PMCs */
78 uint64_t sif_avail_pmds[PFM_PMD_BV]; /* out: available PMDs */
79 uint64_t sif_reserved[4];
81
82//os_err_t pfm_create(int flags, pfarg_sinfo_t *sif,
83// char *smpl_name, void *smpl_arg, size_t arg_size);
84extern os_err_t pfm_create(int flags, pfarg_sinfo_t *sif, ...);
85
86
87/*
88 * pfm_create flags:
89 * bits[00-15]: generic flags
90 * bits[16-31]: arch-specific flags (see perfmon_const.h)
91 */
92#define PFM_FL_NOTIFY_BLOCK 0x01 /* block task on user notifications */
93#define PFM_FL_SYSTEM_WIDE 0x02 /* create a system wide context */
94#define PFM_FL_SMPL_FMT 0x04 /* session uses sampling format */
95#define PFM_FL_OVFL_NO_MSG 0x80 /* no overflow msgs */
96
97/*
98 * PMC and PMD generic (simplified) register description
99 */
100typedef struct {
101 uint16_t reg_num; /* which register */
102 uint16_t reg_set; /* which event set */
103 uint32_t reg_flags; /* REGFL flags */
104 uint64_t reg_value; /* 64-bit value */
106
107/*
108 * pfarg_pmr_t flags:
109 * bit[00-15] : generic flags
110 * bit[16-31] : arch-specific flags
111 *
112 * PFM_REGFL_NO_EMUL64: must be set on the PMC controlling the PMD
113 */
114#define PFM_REGFL_OVFL_NOTIFY 0x1 /* PMD: send notification on event */
115#define PFM_REGFL_RANDOM 0x2 /* PMD: randomize value after event */
116#define PFM_REGFL_NO_EMUL64 0x4 /* PMC: no 64-bit emulation */
117
118/*
119 * PMD extended description
120 * to be used with pfm_writeand pfm_read
121 * must be used with type = PFM_RW_PMD_ATTR
122 */
123typedef struct {
124 uint16_t reg_num; /* which register */
125 uint16_t reg_set; /* which event set */
126 uint32_t reg_flags; /* REGFL flags */
127 uint64_t reg_value; /* 64-bit value */
128 uint64_t reg_long_reset; /* write: value to reload after notification */
129 uint64_t reg_short_reset; /* write: reset after counter overflow */
130 uint64_t reg_random_mask; /* write: bitmask used to limit random value */
131 uint64_t reg_smpl_pmds[PFM_PMD_BV]; /* write: record in sample */
132 uint64_t reg_reset_pmds[PFM_PMD_BV]; /* write: reset on overflow */
133 uint64_t reg_ovfl_swcnt; /* write: # overflows before switch */
134 uint64_t reg_smpl_eventid; /* write: opaque event identifier */
135 uint64_t reg_last_value; /* read: PMD last reset value */
136 uint64_t reg_reserved[8]; /* for future use */
138
139
140/*
141 * pfm_write, pfm_read type:
142 */
143#define PFM_RW_PMD 1 /* simplified PMD (pfarg_pmr_t) */
144#define PFM_RW_PMC 2 /* PMC registers (pfarg_pmr_t) */
145#define PFM_RW_PMD_ATTR 3 /* extended PMD (pfarg_pmd_attr) */
146
147/*
148 * pfm_attach special target for detach
149 */
150#define PFM_NO_TARGET -1 /* no target, detach */
151
152
153/*
154 * pfm_set_state state:
155 */
156#define PFM_ST_START 0x1 /* start monitoring */
157#define PFM_ST_STOP 0x2 /* stop monitoring */
158#define PFM_ST_RESTART 0x3 /* resume after notify */
159
160#ifndef PFMLIB_OLD_PFMV2
161typedef struct {
162 uint16_t set_id; /* which set */
163 uint16_t set_reserved1; /* for future use */
164 uint32_t set_flags; /* SETFL flags */
165 uint64_t set_timeout; /* requested/effective switch timeout in nsecs */
166 uint64_t reserved[6]; /* for future use */
168
169typedef struct {
170 uint16_t set_id; /* which set */
171 uint16_t set_reserved1; /* for future use */
172 uint32_t set_reserved2; /* for future use */
173 uint64_t set_ovfl_pmds[PFM_PMD_BV]; /* out: last ovfl PMDs */
174 uint64_t set_runs; /* out: #times set was active */
175 uint64_t set_timeout; /* out: leftover switch timeout (nsecs) */
176 uint64_t set_duration; /* out: time set was active (nsecs) */
177 uint64_t set_reserved3[4]; /* for future use */
179#endif
180
181/*
182 * pfm_set_desc_t flags:
183 */
184#define PFM_SETFL_OVFL_SWITCH 0x01 /* enable switch on overflow (subject to individual switch_cnt */
185#define PFM_SETFL_TIME_SWITCH 0x02 /* switch set on timeout */
186
187#ifndef PFMLIB_OLD_PFMV2
188typedef struct {
189 uint32_t msg_type; /* PFM_MSG_OVFL */
190 uint32_t msg_ovfl_pid; /* process id */
191 uint16_t msg_active_set; /* active set at the time of overflow */
192 uint16_t msg_ovfl_cpu; /* cpu on which the overflow occurred */
193 uint32_t msg_ovfl_tid; /* thread id */
194 uint64_t msg_ovfl_ip; /* instruction pointer where overflow interrupt happened */
195 uint64_t msg_ovfl_pmds[PFM_PMD_BV];/* which PMDs overflowed */
197
198extern os_err_t pfm_write(int fd, int flags, int type, void *reg, size_t n);
199extern os_err_t pfm_read(int fd, int flags, int type, void *reg, size_t n);
200extern os_err_t pfm_set_state(int fd, int flags, int state);
201extern os_err_t pfm_create_sets(int fd, int flags, pfarg_set_desc_t *s, size_t sz);
202extern os_err_t pfm_getinfo_sets(int fd, int flags, pfarg_set_info_t *s, size_t sz);
203extern os_err_t pfm_attach(int fd, int flags, int target);
204
205#endif
206
207#include "perfmon_v2.h"
208
209typedef union {
210 uint32_t type;
211 pfarg_ovfl_msg_t pfm_ovfl_msg;
213
214#define PFM_MSG_OVFL 1 /* an overflow happened */
215#define PFM_MSG_END 2 /* thread to which context was attached ended */
216
217#define PFM_VERSION_MAJOR(x) (((x)>>16) & 0xffff)
218#define PFM_VERSION_MINOR(x) ((x) & 0xffff)
219
220#ifdef __cplusplus
221};
222#endif
223
224#endif /* _PERFMON_H */
double s
Definition: byte_profile.c:36
uint16_t reserved
uint16_t type
bool state
Definition: papi_hl.c:155
#define PFM_PMD_BV
Definition: perfmon_nec.h:51
os_err_t pfm_read(int fd, int flags, int type, void *reg, size_t n)
os_err_t pfm_set_state(int fd, int flags, int state)
os_err_t pfm_create(int flags, pfarg_sinfo_t *sif,...)
os_err_t pfm_write(int fd, int flags, int type, void *reg, size_t n)
os_err_t pfm_getinfo_sets(int fd, int flags, pfarg_set_info_t *s, size_t sz)
#define PFM_PMC_BV
Definition: perfmon_nec.h:50
int os_err_t
Definition: perfmon_nec.h:69
os_err_t pfm_attach(int fd, int flags, int target)
os_err_t pfm_create_sets(int fd, int flags, pfarg_set_desc_t *s, size_t sz)