PAPI
7.1.0.0
Loading...
Searching...
No Matches
perfctr-x86.h
Go to the documentation of this file.
1
#ifndef _PERFCTR_X86_H
2
#define _PERFCTR_X86_H
3
4
#include "
perfmon/pfmlib.h
"
5
#include "libperfctr.h"
6
#include "
papi_lock.h
"
7
8
#define MAX_COUNTERS 18
9
#define MAX_COUNTER_TERMS 8
10
#define HW_OVERFLOW 1
11
#define hwd_pmc_control vperfctr_control
12
13
#include "
linux-context.h
"
14
15
/* bit fields unique to P4 */
16
#define ESCR_T0_OS (1 << 3)
17
#define ESCR_T0_USR (1 << 2)
18
#define CCCR_OVF_PMI_T0 (1 << 26)
19
#define FAST_RDPMC (1 << 31)
20
21
#ifndef CONFIG_SMP
22
/* Assert that CONFIG_SMP is set before including asm/atomic.h to
23
* get bus-locking atomic_* operations when building on UP kernels */
24
#define CONFIG_SMP
25
#endif
26
27
28
/* Used in resources.selector to determine on which counters an event can live. */
29
#define CNTR1 0x1
30
#define CNTR2 0x2
31
#define CNTR3 0x4
32
#define CNTR4 0x8
33
#define CNTR5 0x10
34
#define CNTRS12 (CNTR1|CNTR2)
35
#define ALLCNTRS (CNTR1|CNTR2|CNTR3|CNTR4|CNTR5)
36
37
#define HAS_MESI 0x0100
// indicates this event supports MESI modifiers
38
#define HAS_MOESI 0x0200
// indicates this event supports MOESI modifiers
39
#define HAS_UMASK 0x0400
// indicates this event has defined unit mask bits
40
#define MOESI_M 0x1000
// modified bit
41
#define MOESI_O 0x0800
// owner bit
42
#define MOESI_E 0x0400
// exclusive bit
43
#define MOESI_S 0x0200
// shared bit
44
#define MOESI_I 0x0100
// invalid bit
45
#define MOESI_M_INTEL MOESI_O
// modified bit on Intel processors
46
#define MOESI_ALL 0x1F00
// mask for MOESI bits in event code or counter_cmd
47
#define UNIT_MASK_ALL 0xFF00
// mask for unit mask bits in event code or counter_cmd
48
49
/* Masks to craft an eventcode to perfctr's liking */
50
#define PERF_CTR_MASK 0xFF000000
51
#define PERF_INV_CTR_MASK 0x00800000
52
#define PERF_ENABLE 0x00400000
53
#define PERF_INT_ENABLE 0x00100000
54
#define PERF_PIN_CONTROL 0x00080000
55
#define PERF_EDGE_DETECT 0x00040000
56
#define PERF_OS 0x00020000
57
#define PERF_USR 0x00010000
58
#define PERF_UNIT_MASK 0x0000FF00
59
#define PERF_EVNT_MASK 0x000000FF
60
61
#define AI_ERROR "No support for a-mode counters after adding an i-mode counter"
62
#define VOPEN_ERROR "vperfctr_open() returned NULL, please run perfex -i to verify your perfctr installation"
63
#define GOPEN_ERROR "gperfctr_open() returned NULL"
64
#define VINFO_ERROR "vperfctr_info() returned < 0"
65
#define VCNTRL_ERROR "vperfctr_control() returned < 0"
66
#define RCNTRL_ERROR "rvperfctr_control() returned < 0"
67
#define GCNTRL_ERROR "gperfctr_control() returned < 0"
68
#define FOPEN_ERROR "fopen(%s) returned NULL"
69
#define STATE_MAL_ERROR "Error allocating perfctr structures"
70
#define MODEL_ERROR "This is not a supported cpu."
71
72
typedef
struct
X86_register
73
{
74
unsigned
int
selector
;
// mask for which counters in use
75
int
counter_cmd
;
// event code
76
/****************** P4 elements *******************/
77
unsigned
counter[2];
// bitmap of valid counters for each escr
78
unsigned
escr[2];
// bit offset for each of 2 valid escrs
79
unsigned
cccr
;
// value to be loaded into cccr register
80
unsigned
event
;
// value defining event to be loaded into escr register
81
unsigned
pebs_enable
;
// flag for PEBS counting
82
unsigned
pebs_matrix_vert
;
// flag for PEBS_MATRIX_VERT
83
unsigned
ireset
;
84
}
X86_register_t
;
85
86
typedef
struct
X86_reg_alloc
87
{
88
X86_register_t
ra_bits
;
// info about this native event mapping
89
unsigned
ra_selector
;
// bit mask showing which counters can carry this metric
90
unsigned
ra_rank
;
// how many counters can carry this metric
91
/*************** P4 specific element ****************/
92
unsigned
ra_escr[2];
// bit field array showing which esc registers can carry this metric
93
}
X86_reg_alloc_t
;
94
95
typedef
struct
hwd_native
96
{
97
int
index
;
// index in the native table, required
98
unsigned
int
selector
;
// which counters
99
unsigned
char
rank
;
// rank determines how many counters carry each metric
100
int
position
;
// which counter this native event stays
101
int
mod
;
102
int
link
;
103
}
hwd_native_t
;
104
105
typedef
struct
X86_perfctr_control
106
{
107
hwd_native_t
native
[
MAX_COUNTERS
];
108
int
native_idx
;
109
unsigned
char
master_selector
;
110
X86_register_t
allocated_registers
;
111
struct
vperfctr_control control;
112
struct
perfctr_sum_ctrs
state
;
113
struct
rvperfctr *
rvperfctr
;
// Allow attach to be per-eventset
114
}
X86_perfctr_control_t
;
115
116
typedef
struct
X86_perfctr_context
117
{
118
struct
vperfctr *
perfctr
;
119
int
stat_fd
;
120
}
X86_perfctr_context_t
;
121
122
/* Override void* definitions from PAPI framework layer
123
with typedefs to conform to PAPI component layer code. */
124
#undef hwd_reg_alloc_t
125
typedef
X86_reg_alloc_t
hwd_reg_alloc_t
;
126
#undef hwd_register_t
127
typedef
X86_register_t
hwd_register_t
;
128
#undef hwd_control_state_t
129
typedef
X86_perfctr_control_t
hwd_control_state_t
;
130
#undef hwd_context_t
131
typedef
X86_perfctr_context_t
hwd_context_t
;
132
133
typedef
struct
native_event_entry
134
{
135
char
name
[
PAPI_MAX_STR_LEN
];
// name of this event
136
char
*
description
;
// description of this event
137
X86_register_t
resources
;
// resources required by this native event
138
}
native_event_entry_t
;
139
140
typedef
pfmlib_event_t
pfm_register_t
;
141
142
#endif
PAPI_MAX_STR_LEN
#define PAPI_MAX_STR_LEN
Definition:
f90papi.h:77
linux-context.h
state
bool state
Definition:
papi_hl.c:155
papi_lock.h
native
static int native
Definition:
papi_xml_event_info.c:39
hwd_context_t
X86_perfctr_context_t hwd_context_t
Definition:
perfctr-x86.h:131
hwd_register_t
X86_register_t hwd_register_t
Definition:
perfctr-x86.h:127
hwd_control_state_t
X86_perfctr_control_t hwd_control_state_t
Definition:
perfctr-x86.h:129
pfm_register_t
pfmlib_event_t pfm_register_t
Definition:
perfctr-x86.h:140
hwd_reg_alloc_t
X86_reg_alloc_t hwd_reg_alloc_t
Definition:
perfctr-x86.h:125
MAX_COUNTERS
#define MAX_COUNTERS
Definition:
perfctr-x86.h:8
pfmlib.h
name
const char * name
Definition:
rocs.c:225
X86_perfctr_context_t
Definition:
perfctr-x86.h:117
X86_perfctr_context_t::perfctr
struct vperfctr * perfctr
Definition:
perfctr-x86.h:118
X86_perfctr_context_t::stat_fd
int stat_fd
Definition:
perfctr-x86.h:119
X86_perfctr_control_t
Definition:
perfctr-x86.h:106
X86_perfctr_control_t::allocated_registers
X86_register_t allocated_registers
Definition:
perfctr-x86.h:110
X86_perfctr_control_t::master_selector
unsigned char master_selector
Definition:
perfctr-x86.h:109
X86_perfctr_control_t::rvperfctr
struct rvperfctr * rvperfctr
Definition:
perfctr-x86.h:113
X86_perfctr_control_t::native_idx
int native_idx
Definition:
perfctr-x86.h:108
X86_reg_alloc_t
Definition:
perfctr-x86.h:87
X86_reg_alloc_t::ra_selector
unsigned ra_selector
Definition:
perfctr-x86.h:89
X86_reg_alloc_t::ra_bits
X86_register_t ra_bits
Definition:
perfctr-x86.h:88
X86_reg_alloc_t::ra_rank
unsigned ra_rank
Definition:
perfctr-x86.h:90
X86_register_t
Definition:
perfctr-x86.h:73
X86_register_t::selector
unsigned int selector
Definition:
perfctr-x86.h:74
X86_register_t::pebs_enable
unsigned pebs_enable
Definition:
perfctr-x86.h:81
X86_register_t::ireset
unsigned ireset
Definition:
perfctr-x86.h:83
X86_register_t::event
unsigned event
Definition:
perfctr-x86.h:80
X86_register_t::pebs_matrix_vert
unsigned pebs_matrix_vert
Definition:
perfctr-x86.h:82
X86_register_t::cccr
unsigned cccr
Definition:
perfctr-x86.h:79
X86_register_t::counter_cmd
int counter_cmd
Definition:
perfctr-x86.h:75
hwd_native_t
Definition:
perfctr-x86.h:96
hwd_native_t::link
int link
Definition:
perfctr-x86.h:102
hwd_native_t::selector
unsigned int selector
Definition:
perfctr-x86.h:98
hwd_native_t::mod
int mod
Definition:
perfctr-x86.h:101
hwd_native_t::rank
unsigned char rank
Definition:
perfctr-x86.h:99
hwd_native_t::position
int position
Definition:
perfctr-x86.h:100
hwd_native_t::index
int index
Definition:
perfctr-x86.h:97
native_event_entry_t
Definition:
perfctr-x86.h:134
native_event_entry_t::description
char * description
Definition:
perfctr-x86.h:136
native_event_entry_t::resources
X86_register_t resources
Definition:
perfctr-x86.h:137
pfmlib_event_t
Definition:
pfmlib.h:85
src
components
perfctr
perfctr-x86.h
Generated on Wed Dec 20 2023 18:12:51 for PAPI by
1.9.6