20#define PERFCTR_CPU_NAME perfctr_info_cpu_name
22#define PERFCTR_CPU_NRCTRS perfctr_info_nrctrs
24#define PERFCTR_CPU_NAME perfctr_cpu_name
25#define PERFCTR_CPU_NRCTRS perfctr_cpu_nrctrs
29#if defined(_POWER5) || defined(_POWER5p)
77 {
PAPI_L2_DCM, {0, {
PNE_PM_DATA_FROM_MEM,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
78 {
PAPI_L2_DCR, {
DERIVED_ADD, {
PNE_PM_DATA_FROM_L2,
PNE_PM_DATA_FROM_L25_MOD,
PNE_PM_DATA_FROM_L25_SHR,
PNE_PM_DATA_FROM_MEM,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
79 {
PAPI_L2_DCH, {
DERIVED_ADD, {
PNE_PM_DATA_FROM_L2,
PNE_PM_DATA_FROM_L25_MOD,
PNE_PM_DATA_FROM_L25_SHR,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
80 {
PAPI_L2_LDM, {0, {
PNE_PM_DATA_FROM_MEM,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
82 {
PAPI_L1_ICM, {
DERIVED_ADD, {
PNE_PM_INST_FROM_L2,
PNE_PM_INST_FROM_L25_SHR,
PNE_PM_INST_FROM_L25_MOD,
PNE_PM_INST_FROM_MEM,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
83 {
PAPI_L2_ICA, {
DERIVED_ADD, {
PNE_PM_INST_FROM_L2,
PNE_PM_INST_FROM_L25_SHR,
PNE_PM_INST_FROM_L25_MOD,
PNE_PM_INST_FROM_MEM,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
84 {
PAPI_L2_ICH, {
DERIVED_ADD, {
PNE_PM_INST_FROM_L2,
PNE_PM_INST_FROM_L25_SHR,
PNE_PM_INST_FROM_L25_MOD,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
85 {
PAPI_L2_ICM, {0, {
PNE_PM_INST_FROM_MEM,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
88 {
PAPI_L1_DCM, {
DERIVED_ADD, {
PNE_PM_LD_MISS_L1,
PNE_PM_ST_MISS_L1,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
89 {
PAPI_L1_DCA, {
DERIVED_ADD, {
PNE_PM_LD_REF_L1,
PNE_PM_ST_REF_L1,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
90 {
PAPI_FXU_IDL, {0, {
PNE_PM_FXU_IDLE,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
91 {
PAPI_L1_LDM, {0, {
PNE_PM_LD_MISS_L1,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
92 {
PAPI_L1_STM, {0, {
PNE_PM_ST_MISS_L1,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
93 {
PAPI_L1_DCW, {0, {
PNE_PM_ST_REF_L1,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
94 {
PAPI_L1_DCR, {0, {
PNE_PM_LD_REF_L1,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
95 {
PAPI_FMA_INS, {0, {
PNE_PM_FPU_FMA,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
96 {
PAPI_TOT_IIS, {0, {
PNE_PM_INST_DISP,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
97 {
PAPI_TOT_INS, {0, {
PNE_PM_INST_CMPL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
98 {
PAPI_INT_INS, {0, {
PNE_PM_FXU_FIN,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
99 {
PAPI_FP_OPS, {
DERIVED_POSTFIX, {
PNE_PM_FPU0_FIN,
PNE_PM_FPU1_FIN,
PNE_PM_FPU_FMA,
PNE_PM_FPU_STF,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL},
"N0|N1|+|N2|+|N3|-|"}},
100 {
PAPI_FP_INS, {0, {
PNE_PM_FPU_FIN,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
101 {
PAPI_TOT_CYC, {0, {
PNE_PM_CYC,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
102 {
PAPI_FDV_INS, {0, {
PNE_PM_FPU_FDIV,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
103 {
PAPI_FSQ_INS, {0, {
PNE_PM_FPU_FSQRT,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
104 {
PAPI_TLB_DM, {0, {
PNE_PM_DTLB_MISS,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
105 {
PAPI_TLB_IM, {0, {
PNE_PM_ITLB_MISS,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
106 {
PAPI_TLB_TL, {
DERIVED_ADD, {
PNE_PM_DTLB_MISS,
PNE_PM_ITLB_MISS,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
107 {
PAPI_HW_INT, {0, {
PNE_PM_EXT_INT,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
108 {
PAPI_STL_ICY, {0, {
PNE_PM_0INST_FETCH,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
109 {
PAPI_LD_INS, {0, {
PNE_PM_LD_REF_L1,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
110 {
PAPI_SR_INS, {0, {
PNE_PM_ST_REF_L1,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
111 {
PAPI_LST_INS, {
DERIVED_ADD, {
PNE_PM_ST_REF_L1,
PNE_PM_LD_REF_L1,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
112 {
PAPI_BR_INS, {0, {
PNE_PM_BR_ISSUED,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
113 {
PAPI_BR_MSP, {
DERIVED_ADD, {
PNE_PM_BR_MPRED_CR,
PNE_PM_BR_MPRED_TA,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
114 {
PAPI_L1_DCH, {
DERIVED_POSTFIX, {
PNE_PM_LD_REF_L1,
PNE_PM_LD_MISS_L1,
PNE_PM_ST_REF_L1,
PNE_PM_ST_MISS_L1,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL},
"N0|N1|-|N2|+|N3|-|"}},
116 {
PAPI_L3_DCM, {0, {
PNE_PM_DATA_FROM_MEM,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
117 {
PAPI_L3_LDM, {0, {
PNE_PM_DATA_FROM_MEM,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
118 {
PAPI_L1_ICH, {0, {
PNE_PM_INST_FROM_L1,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
119 {
PAPI_L3_ICM, {0, {
PNE_PM_INST_FROM_MEM,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}},
120 {0, {0, {
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL,
PAPI_NULL}, {0}}}
125#if defined(_POWER5) || defined(_POWER5p)
149 struct perfctr_cpu_control *cpu_ctl = &cntrl->control.cpu_control;
151 int num_used_counters = cpu_ctl->nractrs + cpu_ctl->nrictrs;
152 unsigned int used_counters = 0x0;
153 for (
i = 0;
i < num_used_counters;
i++ ) {
154 used_counters |= 1 << cpu_ctl->pmc_map[
i];
156#if defined(_POWER5) || defined(_POWER5p)
157 int freeze_pmc5_pmc6 = 0;
161 unsigned int active_counter = ( ( 1 <<
i ) & used_counters );
162 if ( !active_counter ) {
163#if defined(_POWER5) || defined(_POWER5p)
179#if defined(_POWER5) || defined(_POWER5p)
180 if ( freeze_pmc5_pmc6 == 2 )
181 cpu_ctl->ppc64.mmcr0 |= PMC5_PMC6_FREEZE;
193 cntrl->control.cpu_control.ppc64.mmcr0 |=
196 cntrl->control.cpu_control.ppc64.mmcr0 |=
PERF_USER;
197 cntrl->control.cpu_control.ppc64.mmcr0 ^=
PERF_USER;
201 cntrl->control.cpu_control.ppc64.mmcr0 |=
PERF_KERNEL;
202 cntrl->control.cpu_control.ppc64.mmcr0 ^=
PERF_KERNEL;
230 SUBDBG(
"Control used:\n" );
231 SUBDBG(
"tsc_on\t\t\t%u\n", control->tsc_on );
232 SUBDBG(
"nractrs\t\t\t%u\n", control->nractrs );
233 SUBDBG(
"nrictrs\t\t\t%u\n", control->nrictrs );
234 SUBDBG(
"mmcr0\t\t\t0x%X\n", control->ppc64.mmcr0 );
235 SUBDBG(
"mmcr1\t\t\t0x%llX\n",
236 (
unsigned long long ) control->ppc64.mmcr1 );
237 SUBDBG(
"mmcra\t\t\t0x%X\n", control->ppc64.mmcra );
239 for (
i = 0;
i < ( control->nractrs + control->nrictrs ); ++
i ) {
240 SUBDBG(
"pmc_map[%u]\t\t%u\n",
i, control->pmc_map[
i] );
241 if ( control->ireset[
i] ) {
242 SUBDBG(
"ireset[%d]\t%X\n",
i, control->ireset[
i] );
265 ptr->control.cpu_control.pmc_map[
i] =
i;
267 ptr->control.cpu_control.tsc_on = 1;
290 int i, j, group = -1;
297 for (
i = 1;
i < size;
i++ ) {
299 map[j] &= event_list[
i].ra_group[j];
304 group = ffs( map[
i] ) - 1 +
i * 32;
312 for (
i = 0;
i < size;
i++ ) {
314 if ( event_list[
i].ra_counter_cmd[j] >= 0
315 && event_list[
i].ra_counter_cmd[j] ==
330 int i, j, natNum, index;
339 for (
i = 0;
i < natNum;
i++ ) {
361 this_state->group_id = group;
362 for (
i = 0;
i < natNum;
i++ ) {
364 this_state->control.cpu_control.pmc_map[
i] =
369 SUBDBG(
"Group ID: %d\n", group );
387 this_state->control.cpu_control.nractrs =
388 count - this_state->control.cpu_control.nrictrs;
390 unsigned int save_mmcr0_ctlbits =
393 this_state->control.cpu_control.ppc64.mmcr0 =
394 group_map[this_state->group_id].mmcr0 | save_mmcr0_ctlbits;
396 unsigned long long mmcr1 =
397 ( (
unsigned long long )
group_map[this_state->group_id].mmcr1U ) << 32;
398 mmcr1 +=
group_map[this_state->group_id].mmcr1L;
399 this_state->control.cpu_control.ppc64.mmcr1 = mmcr1;
401 this_state->control.cpu_control.ppc64.mmcra =
417 if (
state->rvperfctr != NULL ) {
419 rvperfctr_control(
state->rvperfctr, &
state->control ) ) < 0 ) {
420 SUBDBG(
"rvperfctr_control returns: %d\n", error );
426 if ( ( error = vperfctr_control( ctx->perfctr, &
state->control ) ) < 0 ) {
427 SUBDBG(
"vperfctr_control returns: %d\n", error );
437 if (
state->rvperfctr != NULL ) {
438 if ( rvperfctr_stop( (
struct rvperfctr * ) ctx->perfctr ) < 0 ) {
444 if ( vperfctr_stop( ctx->perfctr ) < 0 ) {
456 vperfctr_read_state( ctx->perfctr, &spc->state, NULL );
458 SUBDBG(
"vperfctr_read_ctrs\n" );
459 if ( spc->rvperfctr != NULL ) {
460 rvperfctr_read_ctrs( spc->rvperfctr, &spc->state );
462 vperfctr_read_ctrs( ctx->perfctr, &spc->state );
466 *dp = (
long long * ) spc->state.pmc;
473 spc->control.cpu_control.nractrs +
474 spc->control.cpu_control.nrictrs;
i++ ) {
475 SUBDBG(
"raw val hardware index %d is %lld\n",
i,
476 (
long long ) spc->state.pmc[
i] );
497 int retval = vperfctr_unlink( ctx->perfctr );
498 SUBDBG(
"_papi_hwd_shutdown vperfctr_unlink(%p) = %d\n", ctx->perfctr,
500 vperfctr_close( ctx->perfctr );
501 SUBDBG(
"_papi_hwd_shutdown vperfctr_close(%p)\n", ctx->perfctr );
538 ui = contr->cpu_control.pmc_map[cntr1];
539 contr->cpu_control.pmc_map[cntr1] = contr->cpu_control.pmc_map[cntr2];
540 contr->cpu_control.pmc_map[cntr2] = ui;
542 si = contr->cpu_control.ireset[cntr1];
543 contr->cpu_control.ireset[cntr1] = contr->cpu_control.ireset[cntr2];
544 contr->cpu_control.ireset[cntr2] = si;
553 int i, ncntrs, nricntrs = 0, nracntrs = 0,
retval = 0;
561 OVFDBG(
"Selector id (%d) larger than ncntrs (%d)\n",
i, ncntrs );
566 OVFDBG(
"Can't overflow on a derived event.\n" );
577 nricntrs = ++contr->cpu_control.nrictrs;
578 nracntrs = --contr->cpu_control.nractrs;
586 OVFDBG(
"Modified event set\n" );
589 contr->cpu_control.ireset[
i] = 0;
590 nricntrs = --contr->cpu_control.nrictrs;
591 nracntrs = ++contr->cpu_control.nractrs;
593 contr->cpu_control.ppc64.mmcr0 &= ( ~PERF_INT_ENABLE );
601 OVFDBG(
"Modified event set\n" );
610 OVFDBG(
"%s:%d: Hardware overflow is still experimental.\n", __FILE__,
630 ESI->
profile.overflowcount = 0;
669 strncpy(
names, nam, len );
694 *EventCode = *EventCode + 1;
697 }
else if ( modifier == PAPI_PWR4_ENUM_GROUPS ) {
699 unsigned int group = ( *EventCode & 0x00FF0000 ) >> 16;
700 int index = *EventCode & 0x000001FF;
704 *EventCode = *EventCode & 0xFF00FFFF;
708 while ( ( ffs( tmpg ) +
i * 32 ) <= group && tmpg != 0 )
709 tmpg = tmpg ^ ( 1 << ( ffs( tmpg ) - 1 ) );
712 group = ffs( tmpg ) +
i * 32;
713 *EventCode = *EventCode | ( group << 16 );
720 *EventCode = *EventCode + 1;
728 VEC_PAPI_HWD_INIT_CONTROL_STATE},
730 VEC_PAPI_HWD_ALLOCATE_REGISTERS},
732 VEC_PAPI_HWD_UPDATE_CONTROL_STATE},
743 VEC_PAPI_HWD_NTV_CODE_TO_NAME},
745 VEC_PAPI_HWD_NTV_CODE_TO_BITS},
747 VEC_PAPI_HWD_NTV_CODE_TO_DESCR},
749 VEC_PAPI_HWD_NTV_ENUM_EVENTS},
hwd_groups_t group_map[MAX_GROUPS]
PPC64_native_map_t native_name_map[PAPI_MAX_NATIVE_EVENTS]
native_event_entry_t native_table[PAPI_MAX_NATIVE_EVENTS]
const char * names[NUM_EVENTS]
#define MAX_NATNAME_MAP_INDEX
@ PNE_PM_DATA_FROM_L2MISS
@ PNE_PM_DATA_FROM_L25_MOD
@ PNE_PM_INST_FROM_L25_SHR
@ PNE_PM_INST_FROM_L25_MOD
@ PNE_PM_INST_FROM_L2MISS
@ PNE_PM_DATA_FROM_L25_SHR
#define PAPI_DOM_SUPERVISOR
static long long values[NUM_EVENTS]
#define PAPI_NATIVE_AND_MASK
#define PAPI_MAX_PRESET_EVENTS
Return codes and api definitions.
#define OVFDBG(format, args...)
#define SUBDBG(format, args...)
void PAPIERROR(char *format,...)
int _papi_hwi_setup_all_presets(hwi_search_t *findem, int cidx)
int _papi_hwd_allocate_registers(EventSetInfo_t *ESI)
int setup_ppc64_presets(int cputype)
papi_mdi_t _papi_hwi_system_info
static int set_domain(hwd_control_state_t *cntrl, unsigned int domain)
void print_control(const struct perfctr_cpu_control *control)
int _papi_hwd_reset(hwd_context_t *ctx, hwd_control_state_t *cntrl)
int _papi_hwd_ntv_code_to_bits(unsigned int EventCode, hwd_register_t *bits)
int ppc64_setup_vector_table(papi_vectors_t *vtable)
papi_svector_t _ppc64_vector_table[]
static void clear_unused_pmcsel_bits(hwd_control_state_t *cntrl)
unsigned long long pmc_sel_mask[NUM_COUNTER_MASKS]
char * _papi_hwd_ntv_code_to_name(unsigned int EventCode)
int _papi_hwd_shutdown(hwd_context_t *ctx)
int _papi_hwd_stop_profiling(ThreadInfo_t *master, EventSetInfo_t *ESI)
int _papi_hwd_update_control_state(hwd_control_state_t *this_state, NativeInfo_t *native, int count, hwd_context_t *context)
int _papi_hwd_read(hwd_context_t *ctx, hwd_control_state_t *spc, long long **dp, int flags)
static void swap_events(EventSetInfo_t *ESI, struct hwd_pmc_control *contr, int cntr1, int cntr2)
int _papi_hwd_set_profile(EventSetInfo_t *ESI, int EventIndex, int threshold)
static void copy_value(unsigned int val, char *nam, char *names, unsigned int *values, int len)
int _papi_hwd_ntv_enum_events(unsigned int *EventCode, int modifier)
int _papi_hwd_start(hwd_context_t *ctx, hwd_control_state_t *state)
static int do_counter_allocation(ppc64_reg_alloc_t *event_list, int size)
char * _papi_hwd_ntv_code_to_descr(unsigned int EventCode)
int _papi_hwd_init_control_state(hwd_control_state_t *ptr)
int _papi_hwd_set_overflow(EventSetInfo_t *ESI, int EventIndex, int threshold)
int _papi_hwd_stop(hwd_context_t *ctx, hwd_control_state_t *state)
static hwi_search_t preset_name_map_PPC64[PAPI_MAX_PRESET_EVENTS]
int _papi_hwd_set_domain(hwd_control_state_t *cntrl, int domain)
hwi_search_t * preset_search_map
#define NUM_COUNTER_MASKS
#define PERF_CONTROL_MASK
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
EventSetProfileInfo_t profile
EventInfo_t * EventInfoArray
NativeInfo_t * NativeInfoArray
int ra_counter_cmd[MAX_COUNTERS]
unsigned int ra_group[GROUP_INTS]