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
72typedef 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;
85
86typedef 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
94
95typedef 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;
104
105typedef struct X86_perfctr_control
106{
109 unsigned char master_selector;
111 struct vperfctr_control control;
112 struct perfctr_sum_ctrs state;
113 struct rvperfctr *rvperfctr; // Allow attach to be per-eventset
115
116typedef struct X86_perfctr_context
117{
118 struct vperfctr *perfctr;
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
126#undef hwd_register_t
128#undef hwd_control_state_t
130#undef hwd_context_t
132
133typedef 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
139
141
142#endif
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
bool state
Definition: papi_hl.c:155
static int native
X86_perfctr_context_t hwd_context_t
Definition: perfctr-x86.h:131
X86_register_t hwd_register_t
Definition: perfctr-x86.h:127
X86_perfctr_control_t hwd_control_state_t
Definition: perfctr-x86.h:129
pfmlib_event_t pfm_register_t
Definition: perfctr-x86.h:140
X86_reg_alloc_t hwd_reg_alloc_t
Definition: perfctr-x86.h:125
#define MAX_COUNTERS
Definition: perfctr-x86.h:8
const char * name
Definition: rocs.c:225
struct vperfctr * perfctr
Definition: perfctr-x86.h:118
X86_register_t allocated_registers
Definition: perfctr-x86.h:110
unsigned char master_selector
Definition: perfctr-x86.h:109
struct rvperfctr * rvperfctr
Definition: perfctr-x86.h:113
unsigned ra_selector
Definition: perfctr-x86.h:89
X86_register_t ra_bits
Definition: perfctr-x86.h:88
unsigned ra_rank
Definition: perfctr-x86.h:90
unsigned int selector
Definition: perfctr-x86.h:74
unsigned pebs_enable
Definition: perfctr-x86.h:81
unsigned ireset
Definition: perfctr-x86.h:83
unsigned event
Definition: perfctr-x86.h:80
unsigned pebs_matrix_vert
Definition: perfctr-x86.h:82
unsigned cccr
Definition: perfctr-x86.h:79
unsigned int selector
Definition: perfctr-x86.h:98
unsigned char rank
Definition: perfctr-x86.h:99
Definition: perfctr-x86.h:134
char * description
Definition: perfctr-x86.h:136
X86_register_t resources
Definition: perfctr-x86.h:137