|
PAPI
5.3.0.0
|
00001 #ifndef _PERFCTR_X86_H 00002 #define _PERFCTR_X86_H 00003 00004 #include "perfmon/pfmlib.h" 00005 #include "libperfctr.h" 00006 #include "papi_lock.h" 00007 00008 #define MAX_COUNTERS 18 00009 #define MAX_COUNTER_TERMS 8 00010 #define HW_OVERFLOW 1 00011 #define hwd_pmc_control vperfctr_control 00012 00013 #include "linux-context.h" 00014 00015 /* bit fields unique to P4 */ 00016 #define ESCR_T0_OS (1 << 3) 00017 #define ESCR_T0_USR (1 << 2) 00018 #define CCCR_OVF_PMI_T0 (1 << 26) 00019 #define FAST_RDPMC (1 << 31) 00020 00021 #ifndef CONFIG_SMP 00022 /* Assert that CONFIG_SMP is set before including asm/atomic.h to 00023 * get bus-locking atomic_* operations when building on UP kernels */ 00024 #define CONFIG_SMP 00025 #endif 00026 00027 00028 /* Used in resources.selector to determine on which counters an event can live. */ 00029 #define CNTR1 0x1 00030 #define CNTR2 0x2 00031 #define CNTR3 0x4 00032 #define CNTR4 0x8 00033 #define CNTR5 0x10 00034 #define CNTRS12 (CNTR1|CNTR2) 00035 #define ALLCNTRS (CNTR1|CNTR2|CNTR3|CNTR4|CNTR5) 00036 00037 #define HAS_MESI 0x0100 // indicates this event supports MESI modifiers 00038 #define HAS_MOESI 0x0200 // indicates this event supports MOESI modifiers 00039 #define HAS_UMASK 0x0400 // indicates this event has defined unit mask bits 00040 #define MOESI_M 0x1000 // modified bit 00041 #define MOESI_O 0x0800 // owner bit 00042 #define MOESI_E 0x0400 // exclusive bit 00043 #define MOESI_S 0x0200 // shared bit 00044 #define MOESI_I 0x0100 // invalid bit 00045 #define MOESI_M_INTEL MOESI_O // modified bit on Intel processors 00046 #define MOESI_ALL 0x1F00 // mask for MOESI bits in event code or counter_cmd 00047 #define UNIT_MASK_ALL 0xFF00 // mask for unit mask bits in event code or counter_cmd 00048 00049 /* Masks to craft an eventcode to perfctr's liking */ 00050 #define PERF_CTR_MASK 0xFF000000 00051 #define PERF_INV_CTR_MASK 0x00800000 00052 #define PERF_ENABLE 0x00400000 00053 #define PERF_INT_ENABLE 0x00100000 00054 #define PERF_PIN_CONTROL 0x00080000 00055 #define PERF_EDGE_DETECT 0x00040000 00056 #define PERF_OS 0x00020000 00057 #define PERF_USR 0x00010000 00058 #define PERF_UNIT_MASK 0x0000FF00 00059 #define PERF_EVNT_MASK 0x000000FF 00060 00061 #define AI_ERROR "No support for a-mode counters after adding an i-mode counter" 00062 #define VOPEN_ERROR "vperfctr_open() returned NULL, please run perfex -i to verify your perfctr installation" 00063 #define GOPEN_ERROR "gperfctr_open() returned NULL" 00064 #define VINFO_ERROR "vperfctr_info() returned < 0" 00065 #define VCNTRL_ERROR "vperfctr_control() returned < 0" 00066 #define RCNTRL_ERROR "rvperfctr_control() returned < 0" 00067 #define GCNTRL_ERROR "gperfctr_control() returned < 0" 00068 #define FOPEN_ERROR "fopen(%s) returned NULL" 00069 #define STATE_MAL_ERROR "Error allocating perfctr structures" 00070 #define MODEL_ERROR "This is not a supported cpu." 00071 00072 typedef struct X86_register 00073 { 00074 unsigned int selector; // mask for which counters in use 00075 int counter_cmd; // event code 00076 /****************** P4 elements *******************/ 00077 unsigned counter[2]; // bitmap of valid counters for each escr 00078 unsigned escr[2]; // bit offset for each of 2 valid escrs 00079 unsigned cccr; // value to be loaded into cccr register 00080 unsigned event; // value defining event to be loaded into escr register 00081 unsigned pebs_enable; // flag for PEBS counting 00082 unsigned pebs_matrix_vert; // flag for PEBS_MATRIX_VERT 00083 unsigned ireset; 00084 } X86_register_t; 00085 00086 typedef struct X86_reg_alloc 00087 { 00088 X86_register_t ra_bits; // info about this native event mapping 00089 unsigned ra_selector; // bit mask showing which counters can carry this metric 00090 unsigned ra_rank; // how many counters can carry this metric 00091 /*************** P4 specific element ****************/ 00092 unsigned ra_escr[2]; // bit field array showing which esc registers can carry this metric 00093 } X86_reg_alloc_t; 00094 00095 typedef struct hwd_native 00096 { 00097 int index; // index in the native table, required 00098 unsigned int selector; // which counters 00099 unsigned char rank; // rank determines how many counters carry each metric 00100 int position; // which counter this native event stays 00101 int mod; 00102 int link; 00103 } hwd_native_t; 00104 00105 typedef struct X86_perfctr_control 00106 { 00107 hwd_native_t native[MAX_COUNTERS]; 00108 int native_idx; 00109 unsigned char master_selector; 00110 X86_register_t allocated_registers; 00111 struct vperfctr_control control; 00112 struct perfctr_sum_ctrs state; 00113 struct rvperfctr *rvperfctr; // Allow attach to be per-eventset 00114 } X86_perfctr_control_t; 00115 00116 typedef struct X86_perfctr_context 00117 { 00118 struct vperfctr *perfctr; 00119 int stat_fd; 00120 } X86_perfctr_context_t; 00121 00122 /* Override void* definitions from PAPI framework layer 00123 with typedefs to conform to PAPI component layer code. */ 00124 #undef hwd_reg_alloc_t 00125 typedef X86_reg_alloc_t hwd_reg_alloc_t; 00126 #undef hwd_register_t 00127 typedef X86_register_t hwd_register_t; 00128 #undef hwd_control_state_t 00129 typedef X86_perfctr_control_t hwd_control_state_t; 00130 #undef hwd_context_t 00131 typedef X86_perfctr_context_t hwd_context_t; 00132 00133 typedef struct native_event_entry 00134 { 00135 char name[PAPI_MAX_STR_LEN]; // name of this event 00136 char *description; // description of this event 00137 X86_register_t resources; // resources required by this native event 00138 } native_event_entry_t; 00139 00140 typedef pfmlib_event_t pfm_register_t; 00141 00142 #endif