PAPI 7.1.0.0
Loading...
Searching...
No Matches
pfmlib_gen_powerpc.c File Reference
Include dependency graph for pfmlib_gen_powerpc.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE   /* for getline */
 
#define FIRST_POWER_PMU   PFMLIB_PPC970_PMU
 

Functions

static int get_num_event_counters ()
 
static int get_num_control_regs ()
 
static const unsigned long longget_group_vector (int event)
 
static int get_event_id (int event, int counter)
 
static char * get_event_name (int event)
 
static char * get_long_desc (int event)
 
static int get_group_event_id (int group, int counter)
 
static unsigned long long get_mmcr0 (int group)
 
static unsigned long long get_mmcr1 (int group)
 
static unsigned long long get_mmcra (int group)
 
static int pfm_gen_powerpc_get_event_code (unsigned int event, unsigned int pmd, int *code)
 
static char * pfm_gen_powerpc_get_event_name (unsigned int event)
 
static char * pfm_gen_powerpc_get_event_mask_name (unsigned int event, unsigned int mask)
 
static void pfm_gen_powerpc_get_event_counters (unsigned int event, pfmlib_regmask_t *counters)
 
static unsigned int pfm_gen_powerpc_get_num_event_masks (unsigned int event)
 
static void remove_group (unsigned long long *group_vec, int group)
 
static void intersect_groups (unsigned long long *result, const unsigned long long *operand)
 
static int first_group (unsigned long long *group_vec)
 
static int pfm_gen_powerpc_dispatch_events (pfmlib_input_param_t *input, void *model_input, pfmlib_output_param_t *output, void *model_output)
 
static int pfm_gen_powerpc_pmu_detect (void)
 
static void pfm_gen_powerpc_get_impl_pmcs (pfmlib_regmask_t *impl_pmcs)
 
static void pfm_gen_powerpc_get_impl_pmds (pfmlib_regmask_t *impl_pmds)
 
static void pfm_gen_powerpc_get_impl_counters (pfmlib_regmask_t *impl_counters)
 
static void pfm_gen_powerpc_get_hw_counter_width (unsigned int *width)
 
static int pfm_gen_powerpc_get_event_desc (unsigned int event, char **desc)
 
static int pfm_gen_powerpc_get_event_mask_desc (unsigned int event, unsigned int mask, char **desc)
 
static int pfm_gen_powerpc_get_event_mask_code (unsigned int event, unsigned int mask, unsigned int *code)
 
static int pfm_gen_powerpc_get_cycle_event (pfmlib_event_t *e)
 
static int pfm_gen_powerpc_get_inst_retired (pfmlib_event_t *e)
 

Variables

static const int num_group_vec []
 
static const int event_count []
 
unsigned * pmd_priv_vec
 
static unsigned long long mmcr0_fc5_6_mask
 
static unsigned long longmmcr0_counter_mask
 
static unsigned long longmmcr1_counter_mask
 
static unsigned long longmmcr0_counter_off_val
 
static unsigned long longmmcr1_counter_off_val
 
static const pme_power_entry_tpe
 
static const pmg_power_group_tgroups
 
static unsigned gq_pmd_priv_vec [8]
 
static unsigned gr_pmd_priv_vec [6]
 
static unsigned gs_pmd_priv_vec [6]
 
static unsigned long long power4_mmcr0_counter_mask [POWER4_NUM_EVENT_COUNTERS]
 
static unsigned long long power4_mmcr1_counter_mask [POWER4_NUM_EVENT_COUNTERS]
 
static unsigned long long power4_mmcr0_counter_off_val [POWER4_NUM_EVENT_COUNTERS]
 
static unsigned long long power4_mmcr1_counter_off_val [POWER4_NUM_EVENT_COUNTERS]
 
static unsigned long long ppc970_mmcr0_counter_off_val [POWER4_NUM_EVENT_COUNTERS]
 
static unsigned long long ppc970_mmcr1_counter_off_val [POWER4_NUM_EVENT_COUNTERS]
 
static unsigned long long power5_mmcr0_counter_mask [POWER5_NUM_EVENT_COUNTERS]
 
static unsigned long long power5_mmcr1_counter_mask [POWER5_NUM_EVENT_COUNTERS]
 
static unsigned long long power5_mmcr0_counter_off_val [POWER5_NUM_EVENT_COUNTERS]
 
static unsigned long long power5_mmcr1_counter_off_val [POWER5_NUM_EVENT_COUNTERS]
 
pfm_pmu_support_t gen_powerpc_support
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE   /* for getline */

Definition at line 29 of file pfmlib_gen_powerpc.c.

◆ FIRST_POWER_PMU

#define FIRST_POWER_PMU   PFMLIB_PPC970_PMU

Definition at line 59 of file pfmlib_gen_powerpc.c.

Function Documentation

◆ first_group()

static int first_group ( unsigned long long group_vec)
static

Definition at line 213 of file pfmlib_gen_powerpc.c.

214{
215 int i, bit;
216
218 bit = ffsll(group_vec[i]);
219 if (bit) {
220 return (bit - 1) + (i * 64);
221 }
222 }
223 /* There were no groups */
224 return -1;
225}
int i
#define FIRST_POWER_PMU
static const int num_group_vec[]
pfm_pmu_support_t gen_powerpc_support
Here is the caller graph for this function:

◆ get_event_id()

static int get_event_id ( int  event,
int  counter 
)
inlinestatic

Definition at line 103 of file pfmlib_gen_powerpc.c.

103 {
104 return pe[event].pme_event_ids[counter];
105}
static const pme_power_entry_t * pe
const int * pme_event_ids
Here is the caller graph for this function:

◆ get_event_name()

static char * get_event_name ( int  event)
inlinestatic

Definition at line 107 of file pfmlib_gen_powerpc.c.

107 {
108 return pe[event].pme_name;
109}
char * pme_name
Here is the caller graph for this function:

◆ get_group_event_id()

static int get_group_event_id ( int  group,
int  counter 
)
inlinestatic

Definition at line 115 of file pfmlib_gen_powerpc.c.

115 {
116 return groups[group].pmg_event_ids[counter];
117}
static const pmg_power_group_t * groups
const int * pmg_event_ids
Here is the caller graph for this function:

◆ get_group_vector()

static const unsigned long long * get_group_vector ( int  event)
inlinestatic

Definition at line 99 of file pfmlib_gen_powerpc.c.

99 {
100 return pe[event].pme_group_vector;
101}
const unsigned long long * pme_group_vector
Here is the caller graph for this function:

◆ get_long_desc()

static char * get_long_desc ( int  event)
inlinestatic

Definition at line 111 of file pfmlib_gen_powerpc.c.

111 {
112 return pe[event].pme_long_desc;
113}
char * pme_long_desc
Here is the caller graph for this function:

◆ get_mmcr0()

static unsigned long long get_mmcr0 ( int  group)
inlinestatic

Definition at line 119 of file pfmlib_gen_powerpc.c.

119 {
120 return groups[group].pmg_mmcr0;
121}
unsigned long long pmg_mmcr0
Here is the caller graph for this function:

◆ get_mmcr1()

static unsigned long long get_mmcr1 ( int  group)
inlinestatic

Definition at line 123 of file pfmlib_gen_powerpc.c.

123 {
124 return groups[group].pmg_mmcr1;
125}
unsigned long long pmg_mmcr1
Here is the caller graph for this function:

◆ get_mmcra()

static unsigned long long get_mmcra ( int  group)
inlinestatic

Definition at line 127 of file pfmlib_gen_powerpc.c.

127 {
128 return groups[group].pmg_mmcra;
129}
unsigned long long pmg_mmcra
Here is the caller graph for this function:

◆ get_num_control_regs()

static int get_num_control_regs ( )
inlinestatic

Definition at line 95 of file pfmlib_gen_powerpc.c.

95 {
97}
unsigned int pmc_count
Definition: pfmlib_priv.h:37
Here is the caller graph for this function:

◆ get_num_event_counters()

static int get_num_event_counters ( )
inlinestatic

Definition at line 91 of file pfmlib_gen_powerpc.c.

91 {
93}
unsigned int pmd_count
Definition: pfmlib_priv.h:36
Here is the caller graph for this function:

◆ intersect_groups()

static void intersect_groups ( unsigned long long result,
const unsigned long long operand 
)
static

Definition at line 204 of file pfmlib_gen_powerpc.c.

205{
206 int i;
207
209 result[i] &= operand[i];
210 }
211}
volatile int result
Here is the caller graph for this function:

◆ pfm_gen_powerpc_dispatch_events()

static int pfm_gen_powerpc_dispatch_events ( pfmlib_input_param_t input,
void *  model_input,
pfmlib_output_param_t output,
void *  model_output 
)
static

pfm_gen_powerpc_dispatch_events

Examine each desired event specified in "input" and find an appropriate set of PMCs and PMDs to count them.

Definition at line 364 of file pfmlib_gen_powerpc.c.

369{
370 /* model_input and model_output are unused on POWER */
371
372 int i, j, group;
373 int counters_used = 0;
374 unsigned long long mmcr0_val, mmcr1_val;
375 unsigned long long group_vector[num_group_vec[gen_powerpc_support.pmu_type - FIRST_POWER_PMU]];
376 unsigned int plm;
377
378 plm = (input->pfp_events[0].plm != 0) ? input->pfp_events[0].plm : input->pfp_dfl_plm;
379
380 /*
381 * Verify that all of the privilege level masks are identical, as
382 * we cannot have mixed levels on POWER
383 */
384
385 for (i = 1; i < input->pfp_event_count; i++) {
386 if (input->pfp_events[i].plm == 0) {
387 /* it's ok if the default is the same as plm */
388 if (plm != input->pfp_dfl_plm)
389 return PFMLIB_ERR_NOASSIGN;
390 } else {
391 if (plm != input->pfp_events[i].plm)
392 return PFMLIB_ERR_NOASSIGN;
393 }
394 }
395
396 /* start by setting all of the groups as available */
397 memset(group_vector, 0xff, sizeof(unsigned long long) * num_group_vec[gen_powerpc_support.pmu_type - FIRST_POWER_PMU]);
398
399 for (i = 0; i < input->pfp_event_count; i++) {
400 mmcr0_val |= mmcr0_counter_off_val[i];
401 intersect_groups(group_vector, get_group_vector(input->pfp_events[i].event));
402 mmcr1_val |= mmcr1_counter_off_val[i];
403 }
404 group = first_group(group_vector);
405 while (group != -1) {
406 /* find out if the the privilege levels are compatible with each counter */
407 for (i = 0; i < input->pfp_event_count; i++) {
408 /* find event counter in group */
409 for (j = 0; j < get_num_event_counters(); j++) {
410 if (get_event_id(input->pfp_events[i].event,j) == get_group_event_id(group, j)) {
411 /* found counter */
412 if (input->pfp_events[i].plm != 0) {
413 if (! (pmd_priv_vec[j] & (1 << input->pfp_events[0].plm))) {
414 remove_group(group_vector, group);
415 group = first_group(group_vector);
416 goto try_next_group;
417 }
418 } else {
419 if (! (pmd_priv_vec[j] & (1 << input->pfp_dfl_plm))) {
420 remove_group(group_vector, group);
421 group = first_group(group_vector);
422 goto try_next_group;
423 }
424 }
425 /* We located this counter and its privilege checks out ok. */
426 counters_used |= (1 << j);
427 output->pfp_pmds[i].reg_value = 0;
428 output->pfp_pmds[i].reg_addr = 0;
429 output->pfp_pmds[i].reg_alt_addr = 0;
430 output->pfp_pmds[i].reg_num = j + 1;
431 output->pfp_pmds[i].reg_reserved1 = 0;
432 output->pfp_pmd_count = i + 1;
433
434 /* Find the next counter */
435 break;
436 }
437 }
438 if (j == get_num_event_counters()) {
439 printf ("libpfm: Internal error. Unable to find counter in group.\n");
440 }
441 }
442 /*
443 * Success! We found a group (group) that meets the
444 * privilege constraints
445 */
446 break;
447try_next_group: ;
448 }
449 if (group == -1)
450 /* We did not find a group that meets the constraints */
451 return PFMLIB_ERR_NOASSIGN;
452
453 /* We now have a group that meets the constraints */
454
455 mmcr0_val = get_mmcr0(group);
456 mmcr1_val = get_mmcr1(group);
457 for (i = 0; i < get_num_event_counters(); i++) {
458 if (! (counters_used & (1 << i))) {
459 /*
460 * This counter is not used, so set that
461 * selector to its off value.
462 */
463 mmcr0_val &= ~mmcr0_counter_mask[i];
464 mmcr0_val |= mmcr0_counter_off_val[i];
465 mmcr1_val &= ~mmcr1_counter_mask[i];
466 mmcr1_val |= mmcr1_counter_off_val[i];
467 }
468 }
469 /*
470 * As a special case for PMC5 and PMC6 on POWER5/5+, freeze these
471 * two counters if neither are used. Note that the
472 * mmcr0_fc5_6_mask is zero for all processors except POWER5/5+
473 */
474 if ((counters_used & ((1 << (5 - 1)) | (1 << (6 - 1)))) == 0)
475 mmcr0_val |= mmcr0_fc5_6_mask;
476
477 /*
478 * Enable counter "exception on negative" and performance monitor
479 * exceptions
480 */
481 mmcr0_val |= MMCR0_PMXE | MMCR0_PMC1CE | MMCR0_PMCjCE;
482
483 /* Start with the counters frozen in every state, then selectively
484 enable them */
485
486 mmcr0_val |= MMCR0_FCP | MMCR0_FCS | MMCR0_FCHV;
487
488 if (plm & PFM_PLM3) {
489 /* user */
490 mmcr0_val &= ~MMCR0_FCP;
491 }
492 if (plm & PFM_PLM0) {
493 /* kernel */
494 mmcr0_val &= ~MMCR0_FCS;
495 }
496 if (plm & PFM_PLM1) {
497 /* hypervisor */
498 mmcr0_val &= ~MMCR0_FCHV;
499 }
500 /* PFM_PLM2 is not supported */
501
502 output->pfp_pmcs[0].reg_value = mmcr0_val;
503 output->pfp_pmcs[0].reg_addr = 0;
504 output->pfp_pmcs[0].reg_alt_addr = 0;
505 output->pfp_pmcs[0].reg_num = 0;
506 output->pfp_pmcs[0].reg_reserved1 = 0;
507
508 output->pfp_pmcs[1].reg_value = mmcr1_val;
509 output->pfp_pmcs[1].reg_addr = 0;
510 output->pfp_pmcs[1].reg_alt_addr = 0;
511 output->pfp_pmcs[1].reg_num = 1;
512 output->pfp_pmcs[1].reg_reserved1 = 0;
513
514 output->pfp_pmcs[2].reg_value = get_mmcra(group);
515 output->pfp_pmcs[2].reg_addr = 0;
516 output->pfp_pmcs[2].reg_alt_addr = 0;
517 output->pfp_pmcs[2].reg_num = 2;
518 output->pfp_pmcs[2].reg_reserved1 = 0;
519
520 /* We always use the same number of control regs */
522
523 return PFMLIB_SUCCESS;
524}
#define PFMLIB_SUCCESS
Definition: pfmlib.h:283
#define PFM_PLM3
Definition: pfmlib.h:53
#define PFM_PLM0
Definition: pfmlib.h:50
#define PFMLIB_ERR_NOASSIGN
Definition: pfmlib.h:288
#define PFM_PLM1
Definition: pfmlib.h:51
static void intersect_groups(unsigned long long *result, const unsigned long long *operand)
static int get_num_event_counters()
static int get_group_event_id(int group, int counter)
static unsigned long long get_mmcr0(int group)
static unsigned long long get_mmcra(int group)
static int first_group(unsigned long long *group_vec)
static unsigned long long * mmcr1_counter_off_val
static const unsigned long long * get_group_vector(int event)
unsigned * pmd_priv_vec
static int get_event_id(int event, int counter)
static int get_num_control_regs()
static void remove_group(unsigned long long *group_vec, int group)
static unsigned long long mmcr0_fc5_6_mask
static unsigned long long * mmcr0_counter_off_val
static unsigned long long get_mmcr1(int group)
#define MMCR0_FCP
Definition: powerpc_reg.h:26
#define MMCR0_PMC1CE
Definition: powerpc_reg.h:33
#define MMCR0_FCHV
Definition: powerpc_reg.h:43
#define MMCR0_FCS
Definition: powerpc_reg.h:24
#define MMCR0_PMCjCE
Definition: powerpc_reg.h:34
#define MMCR0_PMXE
Definition: powerpc_reg.h:30
unsigned int plm
Definition: pfmlib.h:87
unsigned int event
Definition: pfmlib.h:86
unsigned int pfp_dfl_plm
Definition: pfmlib.h:110
pfmlib_event_t pfp_events[PFMLIB_MAX_PMCS]
Definition: pfmlib.h:113
unsigned int pfp_event_count
Definition: pfmlib.h:109
pfmlib_reg_t pfp_pmds[PFMLIB_MAX_PMDS]
Definition: pfmlib.h:130
pfmlib_reg_t pfp_pmcs[PFMLIB_MAX_PMCS]
Definition: pfmlib.h:129
unsigned int pfp_pmc_count
Definition: pfmlib.h:127
unsigned int pfp_pmd_count
Definition: pfmlib.h:128
unsigned int reg_reserved1
Definition: pfmlib.h:101
unsigned long long reg_value
Definition: pfmlib.h:98
unsigned int reg_num
Definition: pfmlib.h:100
unsigned long reg_alt_addr
Definition: pfmlib.h:102
unsigned long long reg_addr
Definition: pfmlib.h:99
Here is the call graph for this function:

◆ pfm_gen_powerpc_get_cycle_event()

static int pfm_gen_powerpc_get_cycle_event ( pfmlib_event_t e)
static

Definition at line 761 of file pfmlib_gen_powerpc.c.

762{
766 break;
769 break;
772 break;
775 break;
778 break;
781 break;
784 break;
785 default:
786 /* perhaps gen_powerpc_suport.pmu_type wasn't initialized? */
787 return PFMLIB_ERR_NOINIT;
788 }
789 e->num_masks = 0;
790 e->unit_masks[0] = 0;
791 return PFMLIB_SUCCESS;
792
793}
#define POWER5p_PME_PM_RUN_CYC
#define POWER5_PME_PM_CYC
#define POWER6_PME_PM_RUN_CYC
#define POWER7_PME_PM_RUN_CYC
#define PPC970_PME_PM_CYC
#define PFMLIB_POWER4_PMU
Definition: pfmlib.h:266
#define PFMLIB_POWER6_PMU
Definition: pfmlib.h:269
#define PFMLIB_PPC970_PMU
Definition: pfmlib.h:263
#define PFMLIB_POWER5p_PMU
Definition: pfmlib.h:268
#define PFMLIB_POWER5_PMU
Definition: pfmlib.h:267
#define PFMLIB_POWER7_PMU
Definition: pfmlib.h:270
#define PFMLIB_PPC970MP_PMU
Definition: pfmlib.h:264
#define PFMLIB_ERR_NOINIT
Definition: pfmlib.h:286
#define POWER4_PME_PM_CYC
#define PPC970MP_PME_PM_CYC
unsigned int num_masks
Definition: pfmlib.h:90
unsigned int unit_masks[PFMLIB_MAX_MASKS_PER_EVENT]
Definition: pfmlib.h:89

◆ pfm_gen_powerpc_get_event_code()

static int pfm_gen_powerpc_get_event_code ( unsigned int  event,
unsigned int  pmd,
int code 
)
static

pfm_gen_powerpc_get_event_code

Return the event-select value for the specified event as needed for the specified PMD counter.

Definition at line 138 of file pfmlib_gen_powerpc.c.

141{
143 *code = pe[event].pme_code;
144 return PFMLIB_SUCCESS;
145 } else
146 return PFMLIB_ERR_INVAL;
147}
#define PFMLIB_ERR_INVAL
Definition: pfmlib.h:285
static const int event_count[]
unsigned pme_code

◆ pfm_gen_powerpc_get_event_counters()

static void pfm_gen_powerpc_get_event_counters ( unsigned int  event,
pfmlib_regmask_t counters 
)
static

pfm_gen_powerpc_get_event_counters

Fill in the 'counters' bitmask with all possible PMDs that could be used to count the specified event.

Definition at line 175 of file pfmlib_gen_powerpc.c.

177{
178 int i;
179
180 counters->bits[0] = 0;
181 for (i = 0; i < get_num_event_counters(); i++) {
182 if (get_event_id(event, i) != -1) {
183 counters->bits[0] |= (1 << i);
184 }
185 }
186}
pfmlib_regmask_bits_t bits[PFMLIB_REG_BV]
Definition: pfmlib.h:76
Here is the call graph for this function:

◆ pfm_gen_powerpc_get_event_desc()

static int pfm_gen_powerpc_get_event_desc ( unsigned int  event,
char **  desc 
)
static

pfm_gen_powerpc_get_event_desc

Return the description for the specified event (if it has one).

Definition at line 735 of file pfmlib_gen_powerpc.c.

736{
737 *desc = strdup(get_long_desc(event));
738 return 0;
739}
static char * get_long_desc(int event)
Here is the call graph for this function:

◆ pfm_gen_powerpc_get_event_mask_code()

static int pfm_gen_powerpc_get_event_mask_code ( unsigned int  event,
unsigned int  mask,
unsigned int code 
)
static

Definition at line 753 of file pfmlib_gen_powerpc.c.

755{
756 *code = 0;
757 return 0;
758}

◆ pfm_gen_powerpc_get_event_mask_desc()

static int pfm_gen_powerpc_get_event_mask_desc ( unsigned int  event,
unsigned int  mask,
char **  desc 
)
static

pfm_gen_powerpc_get_event_mask_desc

Return the description for the specified event-mask (if it has one).

Definition at line 746 of file pfmlib_gen_powerpc.c.

748{
749 *desc = strdup("");
750 return 0;
751}

◆ pfm_gen_powerpc_get_event_mask_name()

static char * pfm_gen_powerpc_get_event_mask_name ( unsigned int  event,
unsigned int  mask 
)
static

pfm_gen_powerpc_get_event_mask_name

Return the name of the specified event-mask.

Definition at line 164 of file pfmlib_gen_powerpc.c.

165{
166 return "";
167}

◆ pfm_gen_powerpc_get_event_name()

static char * pfm_gen_powerpc_get_event_name ( unsigned int  event)
static

pfm_gen_powerpc_get_event_name

Return the name of the specified event.

Definition at line 154 of file pfmlib_gen_powerpc.c.

155{
156 return get_event_name(event);
157}
static char * get_event_name(int event)
Here is the call graph for this function:

◆ pfm_gen_powerpc_get_hw_counter_width()

static void pfm_gen_powerpc_get_hw_counter_width ( unsigned int width)
static

pfm_gen_powerpc_get_hw_counter_width

Return the number of usable bits in the PMD counters.

Definition at line 725 of file pfmlib_gen_powerpc.c.

726{
727 *width = 64;
728}

◆ pfm_gen_powerpc_get_impl_counters()

static void pfm_gen_powerpc_get_impl_counters ( pfmlib_regmask_t impl_counters)
static

pfm_gen_powerpc_get_impl_counters

Set the appropriate bit in the impl_counters bitmask for each counter that's available on power4.

For now, all PMDs are counters, so just call get_impl_pmds().

Definition at line 715 of file pfmlib_gen_powerpc.c.

716{
717 pfm_gen_powerpc_get_impl_pmds(impl_counters);
718}
static void pfm_gen_powerpc_get_impl_pmds(pfmlib_regmask_t *impl_pmds)
Here is the call graph for this function:

◆ pfm_gen_powerpc_get_impl_pmcs()

static void pfm_gen_powerpc_get_impl_pmcs ( pfmlib_regmask_t impl_pmcs)
static

pfm_gen_powerpc_get_impl_pmcs

Set the appropriate bit in the impl_pmcs bitmask for each PMC that's available on power4.

Definition at line 690 of file pfmlib_gen_powerpc.c.

691{
692 impl_pmcs->bits[0] = (0xffffffff >> (32 - get_num_control_regs()));
693}
Here is the call graph for this function:

◆ pfm_gen_powerpc_get_impl_pmds()

static void pfm_gen_powerpc_get_impl_pmds ( pfmlib_regmask_t impl_pmds)
static

pfm_gen_powerpc_get_impl_pmds

Set the appropriate bit in the impl_pmcs bitmask for each PMD that's available.

Definition at line 702 of file pfmlib_gen_powerpc.c.

703{
704 impl_pmds->bits[0] = (0xffffffff >> (32 - get_num_event_counters()));
705}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_gen_powerpc_get_inst_retired()

static int pfm_gen_powerpc_get_inst_retired ( pfmlib_event_t e)
static

Definition at line 796 of file pfmlib_gen_powerpc.c.

797{
801 break;
804 break;
807 break;
810 break;
813 break;
816 break;
819 break;
820 default:
821 /* perhaps gen_powerpc_suport.pmu_type wasn't initialized? */
822 return PFMLIB_ERR_NOINIT;
823 }
824 e->num_masks = 0;
825 e->unit_masks[0] = 0;
826 return 0;
827}
#define POWER5p_PME_PM_INST_CMPL
#define POWER5_PME_PM_INST_CMPL
#define POWER6_PME_PM_INST_CMPL
#define POWER7_PME_PM_INST_CMPL
#define PPC970_PME_PM_INST_CMPL
#define POWER4_PME_PM_INST_CMPL
#define PPC970MP_PME_PM_INST_CMPL

◆ pfm_gen_powerpc_get_num_event_masks()

static unsigned int pfm_gen_powerpc_get_num_event_masks ( unsigned int  event)
static

pfm_gen_powerpc_get_num_event_masks

Count the number of available event-masks for the specified event.

Definition at line 193 of file pfmlib_gen_powerpc.c.

194{
195 /* POWER arch doesn't use event masks */
196 return 0;
197}

◆ pfm_gen_powerpc_pmu_detect()

static int pfm_gen_powerpc_pmu_detect ( void  )
static

pfm_gen_powerpc_pmu_detect

Determine which POWER processor, if any, we are running on. These should be defined in more recent versions of /usr/include/asm-ppc64/reg.h. It isn't pretty to have these here, but maybe we can remove them someday.

Definition at line 541 of file pfmlib_gen_powerpc.c.

542{
545 gen_powerpc_support.pmu_name = "PPC970";
556 pe = ppc970_pe;
558 return PFMLIB_SUCCESS;
559 }
562 gen_powerpc_support.pmu_name = "PPC970MP";
573 pe = ppc970mp_pe;
575 return PFMLIB_SUCCESS;
576 }
579 gen_powerpc_support.pmu_name = "POWER4";
592 pe = power4_pe;
594 return PFMLIB_SUCCESS;
595 }
598 gen_powerpc_support.pmu_name = "POWER5";
611 pe = power5_pe;
613 return PFMLIB_SUCCESS;
614 }
617 gen_powerpc_support.pmu_name = "POWER5+";
628 if (PVR_VER(mfspr(SPRN_PVR)) >= 0x300) {
629 /* this is a newer, GS model POWER5+ */
632 } else {
635 }
638 pe = power5p_pe;
640 return PFMLIB_SUCCESS;
641 }
644 gen_powerpc_support.pmu_name = "POWER6";
657 pe = power6_pe;
659 return PFMLIB_SUCCESS;
660 }
663 gen_powerpc_support.pmu_name = "POWER7";
676 pe = power7_pe;
678 return PFMLIB_SUCCESS;
679 }
680
681 return PFMLIB_ERR_NOTSUPP;
682}
static const pme_power_entry_t power5p_pe[]
static const pmg_power_group_t power5p_groups[]
#define POWER5p_PME_EVENT_COUNT
static const pmg_power_group_t power5_groups[]
#define POWER5_PME_EVENT_COUNT
static const pme_power_entry_t power5_pe[]
#define POWER6_PME_EVENT_COUNT
static const pme_power_entry_t power6_pe[]
static const pmg_power_group_t power6_groups[]
static const pme_power_entry_t power7_pe[]
static pmg_power_group_t power7_groups[]
#define POWER7_PME_EVENT_COUNT
static const pme_power_entry_t ppc970_pe[]
static const pmg_power_group_t ppc970_groups[]
#define PPC970_PME_EVENT_COUNT
#define PFMLIB_ERR_NOTSUPP
Definition: pfmlib.h:284
static unsigned long long power4_mmcr1_counter_mask[POWER4_NUM_EVENT_COUNTERS]
static unsigned long long * mmcr1_counter_mask
static unsigned long long power4_mmcr0_counter_mask[POWER4_NUM_EVENT_COUNTERS]
static unsigned gq_pmd_priv_vec[8]
static unsigned long long power5_mmcr1_counter_mask[POWER5_NUM_EVENT_COUNTERS]
static unsigned long long power4_mmcr1_counter_off_val[POWER4_NUM_EVENT_COUNTERS]
static unsigned long long power5_mmcr0_counter_off_val[POWER5_NUM_EVENT_COUNTERS]
static unsigned long long power4_mmcr0_counter_off_val[POWER4_NUM_EVENT_COUNTERS]
static unsigned gr_pmd_priv_vec[6]
static unsigned long long power5_mmcr0_counter_mask[POWER5_NUM_EVENT_COUNTERS]
static unsigned long long ppc970_mmcr1_counter_off_val[POWER4_NUM_EVENT_COUNTERS]
static unsigned gs_pmd_priv_vec[6]
static unsigned long long ppc970_mmcr0_counter_off_val[POWER4_NUM_EVENT_COUNTERS]
static unsigned long long * mmcr0_counter_mask
static unsigned long long power5_mmcr1_counter_off_val[POWER5_NUM_EVENT_COUNTERS]
#define POWER4_NUM_EVENT_COUNTERS
#define POWER4_NUM_CONTROL_REGS
#define POWER5p_NUM_EVENT_COUNTERS
#define POWER5p_NUM_CONTROL_REGS
#define POWER5_NUM_CONTROL_REGS
#define POWER5_NUM_EVENT_COUNTERS
#define POWER6_NUM_CONTROL_REGS
#define POWER6_NUM_EVENT_COUNTERS
#define POWER7_NUM_CONTROL_REGS
#define POWER7_NUM_EVENT_COUNTERS
#define PPC970_NUM_EVENT_COUNTERS
#define PPC970_NUM_CONTROL_REGS
#define PPC970MP_NUM_CONTROL_REGS
#define PPC970MP_NUM_EVENT_COUNTERS
static const pme_power_entry_t power4_pe[]
#define POWER4_PME_EVENT_COUNT
static const pmg_power_group_t power4_groups[]
#define SPRN_PVR
#define MMCR0_FC5_6
Definition: powerpc_reg.h:39
#define PV_POWER5p
Definition: powerpc_reg.h:77
#define __is_processor(pv)
Definition: powerpc_reg.h:65
#define mfspr(rn)
Definition: powerpc_reg.h:14
#define PV_970MP
Definition: powerpc_reg.h:83
#define PVR_VER(pvr)
Definition: powerpc_reg.h:62
#define PV_970
Definition: powerpc_reg.h:75
#define PV_POWER7
Definition: powerpc_reg.h:80
#define PV_POWER4
Definition: powerpc_reg.h:71
#define PV_970GX
Definition: powerpc_reg.h:84
#define PV_970FX
Definition: powerpc_reg.h:78
#define PV_POWER6
Definition: powerpc_reg.h:79
#define PV_POWER4p
Definition: powerpc_reg.h:74
#define PV_POWER5
Definition: powerpc_reg.h:76
static const pme_power_entry_t ppc970mp_pe[]
#define PPC970MP_PME_EVENT_COUNT
static const pmg_power_group_t ppc970mp_groups[]
unsigned int num_cnt
Definition: pfmlib_priv.h:38
unsigned int pme_count
Definition: pfmlib_priv.h:35

◆ remove_group()

static void remove_group ( unsigned long long group_vec,
int  group 
)
static

Definition at line 199 of file pfmlib_gen_powerpc.c.

200{
201 group_vec[group / 64] &= ~(1ULL << (group % 64));
202}
Here is the caller graph for this function:

Variable Documentation

◆ event_count

◆ gen_powerpc_support

pfm_pmu_support_t gen_powerpc_support
Initial value:
= {
.pmu_name = NULL,
.pmu_type = PFMLIB_UNKNOWN_PMU,
.pme_count = 0,
.pmd_count = 0,
.pmc_count = 0,
.num_cnt = 0,
.get_event_code = pfm_gen_powerpc_get_event_code,
.get_event_name = pfm_gen_powerpc_get_event_name,
.get_event_mask_name = pfm_gen_powerpc_get_event_mask_name,
.get_event_counters = pfm_gen_powerpc_get_event_counters,
.get_num_event_masks = pfm_gen_powerpc_get_num_event_masks,
.dispatch_events = pfm_gen_powerpc_dispatch_events,
.get_impl_counters = pfm_gen_powerpc_get_impl_counters,
.get_hw_counter_width = pfm_gen_powerpc_get_hw_counter_width,
.get_event_desc = pfm_gen_powerpc_get_event_desc,
.get_event_mask_desc = pfm_gen_powerpc_get_event_mask_desc,
.get_event_mask_code = pfm_gen_powerpc_get_event_mask_code,
.get_cycle_event = pfm_gen_powerpc_get_cycle_event,
.get_inst_retired_event = pfm_gen_powerpc_get_inst_retired
}
#define PFMLIB_UNKNOWN_PMU
Definition: pfmlib.h:222
static int pfm_gen_powerpc_get_cycle_event(pfmlib_event_t *e)
static void pfm_gen_powerpc_get_event_counters(unsigned int event, pfmlib_regmask_t *counters)
static int pfm_gen_powerpc_dispatch_events(pfmlib_input_param_t *input, void *model_input, pfmlib_output_param_t *output, void *model_output)
static void pfm_gen_powerpc_get_impl_pmcs(pfmlib_regmask_t *impl_pmcs)
static unsigned int pfm_gen_powerpc_get_num_event_masks(unsigned int event)
static void pfm_gen_powerpc_get_impl_counters(pfmlib_regmask_t *impl_counters)
static char * pfm_gen_powerpc_get_event_mask_name(unsigned int event, unsigned int mask)
static int pfm_gen_powerpc_get_event_mask_desc(unsigned int event, unsigned int mask, char **desc)
static int pfm_gen_powerpc_get_event_code(unsigned int event, unsigned int pmd, int *code)
static int pfm_gen_powerpc_pmu_detect(void)
static int pfm_gen_powerpc_get_inst_retired(pfmlib_event_t *e)
static int pfm_gen_powerpc_get_event_desc(unsigned int event, char **desc)
static char * pfm_gen_powerpc_get_event_name(unsigned int event)
static void pfm_gen_powerpc_get_hw_counter_width(unsigned int *width)
static int pfm_gen_powerpc_get_event_mask_code(unsigned int event, unsigned int mask, unsigned int *code)

gen_powerpc_support

Definition at line 832 of file pfmlib_gen_powerpc.c.

◆ gq_pmd_priv_vec

unsigned gq_pmd_priv_vec[8]
static
Initial value:
= {
0x0f0e,
0x0f0e,
0x0f0e,
0x0f0e,
0x0f0e,
0x0f0e,
0x0f0e,
0x0f0e
}

Definition at line 228 of file pfmlib_gen_powerpc.c.

◆ gr_pmd_priv_vec

unsigned gr_pmd_priv_vec[6]
static
Initial value:
= {
0x0f0e,
0x0f0e,
0x0f0e,
0x0f0e,
0x0f0e,
0x0f0e,
}

Definition at line 239 of file pfmlib_gen_powerpc.c.

◆ groups

const pmg_power_group_t* groups
static

Definition at line 89 of file pfmlib_gen_powerpc.c.

◆ gs_pmd_priv_vec

unsigned gs_pmd_priv_vec[6]
static
Initial value:
= {
0x0f0e,
0x0f0e,
0x0f0e,
0x0f0e,
0x0800,
0x0800,
}

Definition at line 248 of file pfmlib_gen_powerpc.c.

◆ mmcr0_counter_mask

unsigned long long* mmcr0_counter_mask
static

Definition at line 83 of file pfmlib_gen_powerpc.c.

◆ mmcr0_counter_off_val

unsigned long long* mmcr0_counter_off_val
static

Definition at line 85 of file pfmlib_gen_powerpc.c.

◆ mmcr0_fc5_6_mask

unsigned long long mmcr0_fc5_6_mask
static

Definition at line 82 of file pfmlib_gen_powerpc.c.

◆ mmcr1_counter_mask

unsigned long long* mmcr1_counter_mask
static

Definition at line 84 of file pfmlib_gen_powerpc.c.

◆ mmcr1_counter_off_val

unsigned long long* mmcr1_counter_off_val
static

Definition at line 86 of file pfmlib_gen_powerpc.c.

◆ num_group_vec

◆ pe

const pme_power_entry_t* pe
static

Definition at line 88 of file pfmlib_gen_powerpc.c.

◆ pmd_priv_vec

unsigned* pmd_priv_vec

Definition at line 80 of file pfmlib_gen_powerpc.c.

◆ power4_mmcr0_counter_mask

unsigned long long power4_mmcr0_counter_mask[POWER4_NUM_EVENT_COUNTERS]
static
Initial value:
= {
0x1fUL << (63 - 55),
0x1fUL << (63 - 62),
0,
0,
0,
0,
0,
0
}

Definition at line 258 of file pfmlib_gen_powerpc.c.

◆ power4_mmcr0_counter_off_val

unsigned long long power4_mmcr0_counter_off_val[POWER4_NUM_EVENT_COUNTERS]
static
Initial value:
= {
0,
0,
0,
0,
0,
0,
0,
0
}

Definition at line 279 of file pfmlib_gen_powerpc.c.

◆ power4_mmcr1_counter_mask

unsigned long long power4_mmcr1_counter_mask[POWER4_NUM_EVENT_COUNTERS]
static
Initial value:
= {
0,
0,
0x1fUL << (63 - 36),
0x1fUL << (63 - 41),
0x1fUL << (63 - 46),
0x1fUL << (63 - 51),
0x1fUL << (63 - 56),
0x1fUL << (63 - 61)
}

Definition at line 268 of file pfmlib_gen_powerpc.c.

◆ power4_mmcr1_counter_off_val

unsigned long long power4_mmcr1_counter_off_val[POWER4_NUM_EVENT_COUNTERS]
static
Initial value:
= {
0,
0,
0,
0,
0,
0,
0,
0
}

Definition at line 289 of file pfmlib_gen_powerpc.c.

◆ power5_mmcr0_counter_mask

unsigned long long power5_mmcr0_counter_mask[POWER5_NUM_EVENT_COUNTERS]
static
Initial value:
= {
0,
0,
0,
0,
0,
0
}

Definition at line 322 of file pfmlib_gen_powerpc.c.

◆ power5_mmcr0_counter_off_val

unsigned long long power5_mmcr0_counter_off_val[POWER5_NUM_EVENT_COUNTERS]
static
Initial value:
= {
0,
0,
0,
0,
0,
0
}

Definition at line 339 of file pfmlib_gen_powerpc.c.

◆ power5_mmcr1_counter_mask

unsigned long long power5_mmcr1_counter_mask[POWER5_NUM_EVENT_COUNTERS]
static
Initial value:
= {
0xffUL << (63 - 39),
0xffUL << (63 - 47),
0xffUL << (63 - 55),
0xffUL << (63 - 63),
0,
0
}

Definition at line 330 of file pfmlib_gen_powerpc.c.

◆ power5_mmcr1_counter_off_val

unsigned long long power5_mmcr1_counter_off_val[POWER5_NUM_EVENT_COUNTERS]
static
Initial value:
= {
0,
0,
0,
0,
0,
0
}

Definition at line 348 of file pfmlib_gen_powerpc.c.

◆ ppc970_mmcr0_counter_off_val

unsigned long long ppc970_mmcr0_counter_off_val[POWER4_NUM_EVENT_COUNTERS]
static
Initial value:
= {
0x8UL << (63 - 55),
0x8UL << (63 - 62),
0,
0,
0,
0,
0,
0
}

Definition at line 300 of file pfmlib_gen_powerpc.c.

◆ ppc970_mmcr1_counter_off_val

unsigned long long ppc970_mmcr1_counter_off_val[POWER4_NUM_EVENT_COUNTERS]
static
Initial value:
= {
0,
0,
0x8UL << (63 - 36),
0x8UL << (63 - 41),
0x8UL << (63 - 46),
0x8UL << (63 - 51),
0x8UL << (63 - 56),
0x8UL << (63 - 61)
}

Definition at line 310 of file pfmlib_gen_powerpc.c.