PAPI 7.1.0.0
Loading...
Searching...
No Matches
perfctr-x86.c File Reference
Include dependency graph for perfctr-x86.c:

Go to the source code of this file.

Macros

#define P4_VEC   "SSE"
 
#define P4_FPU   " X87 SSE_DP"
 
#define AMD_FPU   "SPECULATIVE"
 
#define P4_REPLAY_REAL_MASK   0x00000003
 

Functions

int _perfctr_init_component (int)
 
int _perfctr_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
void _perfctr_dispatch_timer (int signal, hwd_siginfo_t *si, void *context)
 
int _perfctr_init_thread (hwd_context_t *ctx)
 
int _perfctr_shutdown_thread (hwd_context_t *ctx)
 
static int is_pentium4 (void)
 
static void print_alloc (X86_reg_alloc_t *a)
 
void print_control (const struct perfctr_cpu_control *control)
 
static int _x86_init_control_state (hwd_control_state_t *ptr)
 
int _x86_set_domain (hwd_control_state_t *cntrl, int domain)
 
static int _bpt_map_avail (hwd_reg_alloc_t *dst, int ctr)
 
static void _bpt_map_set (hwd_reg_alloc_t *dst, int ctr)
 
static int _bpt_map_exclusive (hwd_reg_alloc_t *dst)
 
static int _bpt_map_shared (hwd_reg_alloc_t *dst, hwd_reg_alloc_t *src)
 
static void _bpt_map_preempt (hwd_reg_alloc_t *dst, hwd_reg_alloc_t *src)
 
static void _bpt_map_update (hwd_reg_alloc_t *dst, hwd_reg_alloc_t *src)
 
static int _x86_allocate_registers (EventSetInfo_t *ESI)
 
static void clear_cs_events (hwd_control_state_t *this_state)
 
static int _x86_update_control_state (hwd_control_state_t *this_state, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
static int _x86_start (hwd_context_t *ctx, hwd_control_state_t *state)
 
static int _x86_stop (hwd_context_t *ctx, hwd_control_state_t *state)
 
static int _x86_read (hwd_context_t *ctx, hwd_control_state_t *spc, long long **dp, int flags)
 
static int _x86_reset (hwd_context_t *ctx, hwd_control_state_t *cntrl)
 
static void swap_events (EventSetInfo_t *ESI, struct hwd_pmc_control *contr, int cntr1, int cntr2)
 
static int _x86_set_overflow (EventSetInfo_t *ESI, int EventIndex, int threshold)
 
static int _x86_stop_profiling (ThreadInfo_t *master, EventSetInfo_t *ESI)
 
static int _pfm_get_counter_info (unsigned int event, unsigned int *selector, int *code)
 
int _papi_libpfm_ntv_code_to_bits_perfctr (unsigned int EventCode, hwd_register_t *newbits)
 

Variables

papi_mdi_t _papi_hwi_system_info
 
papi_vector_t _perfctr_vector
 
pentium4_escr_reg_t pentium4_escrs []
 
pentium4_cccr_reg_t pentium4_cccrs []
 
pentium4_event_t pentium4_events []
 
static pentium4_replay_regs_t p4_replay_regs []
 
static int pfm2intel []
 

Macro Definition Documentation

◆ AMD_FPU

#define AMD_FPU   "SPECULATIVE"

Definition at line 72 of file perfctr-x86.c.

◆ P4_FPU

#define P4_FPU   " X87 SSE_DP"

Definition at line 61 of file perfctr-x86.c.

◆ P4_REPLAY_REAL_MASK

#define P4_REPLAY_REAL_MASK   0x00000003

Definition at line 903 of file perfctr-x86.c.

◆ P4_VEC

#define P4_VEC   "SSE"

Definition at line 51 of file perfctr-x86.c.

Function Documentation

◆ _bpt_map_avail()

static int _bpt_map_avail ( hwd_reg_alloc_t dst,
int  ctr 
)
static

Definition at line 266 of file perfctr-x86.c.

267{
268 return ( int ) ( dst->ra_selector & ( 1 << ctr ) );
269}

◆ _bpt_map_exclusive()

static int _bpt_map_exclusive ( hwd_reg_alloc_t dst)
static

Definition at line 295 of file perfctr-x86.c.

296{
297 return ( dst->ra_rank == 1 );
298}

◆ _bpt_map_preempt()

static void _bpt_map_preempt ( hwd_reg_alloc_t dst,
hwd_reg_alloc_t src 
)
static

Definition at line 343 of file perfctr-x86.c.

344{
345 int i;
346 unsigned shared;
347
348 if ( is_pentium4() ) {
349#ifdef DEBUG
350 SUBDBG( "src, dst\n" );
351 print_alloc( src );
352 print_alloc( dst );
353#endif
354
355 /* check for a pebs conflict */
356 /* pebs enables must both be non-zero */
357 i = ( ( ( dst->ra_bits.pebs_enable && src->ra_bits.pebs_enable ) &&
358 /* and not equal to each other */
359 ( dst->ra_bits.pebs_enable != src->ra_bits.pebs_enable ) ) ||
360 /* same for pebs_matrix_vert */
361 ( ( dst->ra_bits.pebs_matrix_vert &&
362 src->ra_bits.pebs_matrix_vert )
363 && ( dst->ra_bits.pebs_matrix_vert !=
364 src->ra_bits.pebs_matrix_vert ) ) );
365 if ( i ) {
366 SUBDBG( "pebs conflict! clearing selector\n" );
367 dst->ra_selector = 0;
368 return;
369 } else {
370 /* remove counters referenced by any shared escrs */
371 if ( ( dst->ra_escr[0] == src->ra_escr[0] ) &&
372 ( ( int ) dst->ra_escr[0] != -1 ) ) {
373 dst->ra_selector &= ~dst->ra_bits.counter[0];
374 dst->ra_escr[0] = -1;
375 }
376 if ( ( dst->ra_escr[1] == src->ra_escr[1] ) &&
377 ( ( int ) dst->ra_escr[1] != -1 ) ) {
378 dst->ra_selector &= ~dst->ra_bits.counter[1];
379 dst->ra_escr[1] = -1;
380 }
381
382 /* remove any remaining shared counters */
383 shared = ( dst->ra_selector & src->ra_selector );
384 if ( shared )
385 dst->ra_selector ^= shared;
386 }
387 /* recompute rank */
388 for ( i = 0, dst->ra_rank = 0; i < MAX_COUNTERS; i++ )
389 if ( dst->ra_selector & ( 1 << i ) )
390 dst->ra_rank++;
391#ifdef DEBUG
392 SUBDBG( "new dst\n" );
393 print_alloc( dst );
394#endif
395 } else {
396 shared = dst->ra_selector & src->ra_selector;
397 if ( shared )
398 dst->ra_selector ^= shared;
399 for ( i = 0, dst->ra_rank = 0; i < MAX_COUNTERS; i++ )
400 if ( dst->ra_selector & ( 1 << i ) )
401 dst->ra_rank++;
402 }
403}
int i
#define SUBDBG(format, args...)
Definition: papi_debug.h:64
static int is_pentium4(void)
Definition: perfctr-x86.c:75
static void print_alloc(X86_reg_alloc_t *a)
Definition: perfctr-x86.c:87
#define MAX_COUNTERS
Definition: perfctr-x86.h:8
Here is the call graph for this function:

◆ _bpt_map_set()

static void _bpt_map_set ( hwd_reg_alloc_t dst,
int  ctr 
)
static

Definition at line 275 of file perfctr-x86.c.

276{
277 dst->ra_selector = ( unsigned int ) ( 1 << ctr );
278 dst->ra_rank = 1;
279
280 if ( is_pentium4() ) {
281 /* Pentium 4 requires that both an escr and a counter are selected.
282 Find which counter mask contains this counter.
283 Set the opposite escr to empty (-1) */
284 if ( dst->ra_bits.counter[0] & dst->ra_selector )
285 dst->ra_escr[1] = -1;
286 else
287 dst->ra_escr[0] = -1;
288 }
289}
int
Definition: sde_internal.h:89
Here is the call graph for this function:

◆ _bpt_map_shared()

static int _bpt_map_shared ( hwd_reg_alloc_t dst,
hwd_reg_alloc_t src 
)
static

Definition at line 305 of file perfctr-x86.c.

306{
307 if ( is_pentium4() ) {
308 int retval1, retval2;
309 /* Pentium 4 needs to check for conflict of both counters and esc registers */
310 /* selectors must share bits */
311 retval1 = ( ( dst->ra_selector & src->ra_selector ) ||
312 /* or escrs must equal each other and not be set to -1 */
313 ( ( dst->ra_escr[0] == src->ra_escr[0] ) &&
314 ( ( int ) dst->ra_escr[0] != -1 ) ) ||
315 ( ( dst->ra_escr[1] == src->ra_escr[1] ) &&
316 ( ( int ) dst->ra_escr[1] != -1 ) ) );
317 /* Pentium 4 also needs to check for conflict on pebs registers */
318 /* pebs enables must both be non-zero */
319 retval2 =
320 ( ( ( dst->ra_bits.pebs_enable && src->ra_bits.pebs_enable ) &&
321 /* and not equal to each other */
322 ( dst->ra_bits.pebs_enable != src->ra_bits.pebs_enable ) ) ||
323 /* same for pebs_matrix_vert */
324 ( ( dst->ra_bits.pebs_matrix_vert &&
325 src->ra_bits.pebs_matrix_vert ) &&
326 ( dst->ra_bits.pebs_matrix_vert !=
327 src->ra_bits.pebs_matrix_vert ) ) );
328 if ( retval2 ) {
329 SUBDBG( "pebs conflict!\n" );
330 }
331 return ( retval1 | retval2 );
332 }
333
334 return ( int ) ( dst->ra_selector & src->ra_selector );
335}
Here is the call graph for this function:

◆ _bpt_map_update()

static void _bpt_map_update ( hwd_reg_alloc_t dst,
hwd_reg_alloc_t src 
)
static

Definition at line 406 of file perfctr-x86.c.

407{
408 dst->ra_selector = src->ra_selector;
409
410 if ( is_pentium4() ) {
411 dst->ra_escr[0] = src->ra_escr[0];
412 dst->ra_escr[1] = src->ra_escr[1];
413 }
414}
Here is the call graph for this function:

◆ _papi_libpfm_ntv_code_to_bits_perfctr()

int _papi_libpfm_ntv_code_to_bits_perfctr ( unsigned int  EventCode,
hwd_register_t newbits 
)

Definition at line 1015 of file perfctr-x86.c.

1017{
1018 unsigned int event, umask;
1019
1020 X86_register_t *bits = (X86_register_t *)newbits;
1021
1022 if ( is_pentium4() ) {
1023 pentium4_escr_value_t escr_value;
1024 pentium4_cccr_value_t cccr_value;
1025 unsigned int num_masks, replay_mask, unit_masks[12];
1026 unsigned int event_mask;
1027 unsigned int tag_value, tag_enable;
1028 unsigned int i;
1029 int j, escr, cccr, pmd;
1030
1031 if ( _pfm_decode_native_event( EventCode, &event, &umask ) != PAPI_OK )
1032 return PAPI_ENOEVNT;
1033
1034 /* for each allowed escr (1 or 2) find the allowed cccrs.
1035 for each allowed cccr find the pmd index
1036 convert to an intel counter number; or it into bits->counter */
1037 for ( i = 0; i < MAX_ESCRS_PER_EVENT; i++ ) {
1038 bits->counter[i] = 0;
1039 escr = pentium4_events[event].allowed_escrs[i];
1040 if ( escr < 0 ) {
1041 continue;
1042 }
1043
1044 bits->escr[i] = escr;
1045
1046 for ( j = 0; j < MAX_CCCRS_PER_ESCR; j++ ) {
1047 cccr = pentium4_escrs[escr].allowed_cccrs[j];
1048 if ( cccr < 0 ) {
1049 continue;
1050 }
1051
1052 pmd = pentium4_cccrs[cccr].pmd;
1053 bits->counter[i] |= ( 1 << pfm2intel[pmd] );
1054 }
1055 }
1056
1057 /* if there's only one valid escr, copy the values */
1058 if ( escr < 0 ) {
1059 bits->escr[1] = bits->escr[0];
1060 bits->counter[1] = bits->counter[0];
1061 }
1062
1063 /* Calculate the event-mask value. Invalid masks
1064 * specified by the caller are ignored. */
1065 tag_value = 0;
1066 tag_enable = 0;
1067 event_mask = _pfm_convert_umask( event, umask );
1068
1069 if ( event_mask & 0xF0000 ) {
1070 tag_enable = 1;
1071 tag_value = ( ( event_mask & 0xF0000 ) >> EVENT_MASK_BITS );
1072 }
1073
1074 event_mask &= 0x0FFFF; /* mask off possible tag bits */
1075
1076 /* Set up the ESCR and CCCR register values. */
1077 escr_value.val = 0;
1078 escr_value.bits.t1_usr = 0; /* controlled by kernel */
1079 escr_value.bits.t1_os = 0; /* controlled by kernel */
1080// escr_value.bits.t0_usr = (plm & PFM_PLM3) ? 1 : 0;
1081// escr_value.bits.t0_os = (plm & PFM_PLM0) ? 1 : 0;
1082 escr_value.bits.tag_enable = tag_enable;
1083 escr_value.bits.tag_value = tag_value;
1084 escr_value.bits.event_mask = event_mask;
1085 escr_value.bits.event_select = pentium4_events[event].event_select;
1086 escr_value.bits.reserved = 0;
1087
1088 /* initialize the proper bits in the cccr register */
1089 cccr_value.val = 0;
1090 cccr_value.bits.reserved1 = 0;
1091 cccr_value.bits.enable = 1;
1092 cccr_value.bits.escr_select = pentium4_events[event].escr_select;
1093 cccr_value.bits.active_thread = 3;
1094 /* FIXME: This is set to count when either logical
1095 * CPU is active. Need a way to distinguish
1096 * between logical CPUs when HT is enabled.
1097 * the docs say these bits should always
1098 * be set. */
1099 cccr_value.bits.compare = 0;
1100 /* FIXME: What do we do with "threshold" settings? */
1101 cccr_value.bits.complement = 0;
1102 /* FIXME: What do we do with "threshold" settings? */
1103 cccr_value.bits.threshold = 0;
1104 /* FIXME: What do we do with "threshold" settings? */
1105 cccr_value.bits.force_ovf = 0;
1106 /* FIXME: Do we want to allow "forcing" overflow
1107 * interrupts on all counter increments? */
1108 cccr_value.bits.ovf_pmi_t0 = 0;
1109 cccr_value.bits.ovf_pmi_t1 = 0;
1110 /* PMI taken care of by kernel typically */
1111 cccr_value.bits.reserved2 = 0;
1112 cccr_value.bits.cascade = 0;
1113 /* FIXME: How do we handle "cascading" counters? */
1114 cccr_value.bits.overflow = 0;
1115
1116 /* these flags are always zero, from what I can tell... */
1117 bits->pebs_enable = 0; /* flag for PEBS counting */
1118 bits->pebs_matrix_vert = 0;
1119 /* flag for PEBS_MATRIX_VERT, whatever that is */
1120
1121 /* ...unless the event is replay_event */
1122 if ( !strcmp( pentium4_events[event].name, "replay_event" ) ) {
1123 escr_value.bits.event_mask = event_mask & P4_REPLAY_REAL_MASK;
1124 num_masks = prepare_umask( umask, unit_masks );
1125 for ( i = 0; i < num_masks; i++ ) {
1126 replay_mask = unit_masks[i];
1127 if ( replay_mask > 1 && replay_mask < 11 ) {
1128 /* process each valid mask we find */
1129 bits->pebs_enable |= p4_replay_regs[replay_mask].enb;
1130 bits->pebs_matrix_vert |= p4_replay_regs[replay_mask].mat_vert;
1131 }
1132 }
1133 }
1134
1135 /* store the escr and cccr values */
1136 bits->event = escr_value.val;
1137 bits->cccr = cccr_value.val;
1138 bits->ireset = 0; /* I don't really know what this does */
1139 SUBDBG( "escr: 0x%lx; cccr: 0x%lx\n", escr_value.val, cccr_value.val );
1140 } else {
1141
1142 int ret, code;
1143
1144 if ( _pfm_decode_native_event( EventCode, &event, &umask ) != PAPI_OK )
1145 return PAPI_ENOEVNT;
1146
1147 if ( ( ret = _pfm_get_counter_info( event, &bits->selector,
1148 &code ) ) != PAPI_OK )
1149 return ret;
1150
1151 bits->counter_cmd=(int) (code | ((_pfm_convert_umask(event,umask))<< 8) );
1152
1153 SUBDBG( "selector: %#x\n", bits->selector );
1154 SUBDBG( "event: %#x; umask: %#x; code: %#x; cmd: %#x\n", event,
1155 umask, code, ( ( hwd_register_t * ) bits )->counter_cmd );
1156 }
1157
1158 return PAPI_OK;
1159}
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_ENOEVNT
Definition: f90papi.h:139
unsigned int _pfm_convert_umask(unsigned int event, unsigned int umask)
static int _pfm_get_counter_info(unsigned int event, unsigned int *selector, int *code)
Definition: perfctr-x86.c:970
#define P4_REPLAY_REAL_MASK
Definition: perfctr-x86.c:903
pentium4_escr_reg_t pentium4_escrs[]
pentium4_cccr_reg_t pentium4_cccrs[]
static int pfm2intel[]
Definition: perfctr-x86.c:958
pentium4_event_t pentium4_events[]
static pentium4_replay_regs_t p4_replay_regs[]
Definition: perfctr-x86.c:910
static int _pfm_decode_native_event(unsigned int EventCode, unsigned int *event, unsigned int *umask)
static int prepare_umask(unsigned int foo, unsigned int *values)
#define EVENT_MASK_BITS
#define MAX_CCCRS_PER_ESCR
#define MAX_ESCRS_PER_EVENT
const char * name
Definition: rocs.c:225
unsigned int selector
Definition: perfctr-x86.h:74
unsigned pebs_enable
Definition: perfctr-x86.h:81
unsigned ireset
Definition: perfctr-x86.h:83
unsigned counter[2]
Definition: perfctr-x86.h:77
unsigned event
Definition: perfctr-x86.h:80
unsigned pebs_matrix_vert
Definition: perfctr-x86.h:82
unsigned escr[2]
Definition: perfctr-x86.h:78
unsigned cccr
Definition: perfctr-x86.h:79
int allowed_cccrs[MAX_CCCRS_PER_ESCR]
int allowed_escrs[MAX_ESCRS_PER_EVENT]
unsigned long escr_select
unsigned long complement
unsigned long ovf_pmi_t0
unsigned long ovf_pmi_t1
unsigned long active_thread
struct pentium4_cccr_value_t::@86 bits
unsigned long tag_enable
unsigned long reserved
unsigned long event_select
struct pentium4_escr_value_t::@85 bits
unsigned long tag_value
unsigned long event_mask
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _perfctr_ctl()

int _perfctr_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)

Definition at line 295 of file perfctr.c.

296{
297 ( void ) ctx; /*unused */
298 switch ( code ) {
299 case PAPI_DOMAIN:
300 case PAPI_DEFDOM:
301#if defined(PPC64)
302 return ( _perfctr_vector.
303 set_domain( option->domain.ESI, option->domain.domain ) );
304#else
305 return ( _perfctr_vector.
306 set_domain( option->domain.ESI->ctl_state,
307 option->domain.domain ) );
308#endif
309 case PAPI_GRANUL:
310 case PAPI_DEFGRN:
311 return PAPI_ECMP;
312 case PAPI_ATTACH:
313 return ( attach( option->attach.ESI->ctl_state, option->attach.tid ) );
314 case PAPI_DETACH:
315 return ( detach( option->attach.ESI->ctl_state ) );
316 case PAPI_DEF_ITIMER:
317 {
318 /* flags are currently ignored, eventually the flags will be able
319 to specify whether or not we use POSIX itimers (clock_gettimer) */
320 if ( ( option->itimer.itimer_num == ITIMER_REAL ) &&
321 ( option->itimer.itimer_sig != SIGALRM ) )
322 return PAPI_EINVAL;
323 if ( ( option->itimer.itimer_num == ITIMER_VIRTUAL ) &&
324 ( option->itimer.itimer_sig != SIGVTALRM ) )
325 return PAPI_EINVAL;
326 if ( ( option->itimer.itimer_num == ITIMER_PROF ) &&
327 ( option->itimer.itimer_sig != SIGPROF ) )
328 return PAPI_EINVAL;
329 if ( option->itimer.ns > 0 )
330 option->itimer.ns = round_requested_ns( option->itimer.ns );
331 /* At this point, we assume the user knows what he or
332 she is doing, they maybe doing something arch specific */
333 return PAPI_OK;
334 }
335 case PAPI_DEF_MPX_NS:
336 {
337 option->multiplex.ns =
338 ( unsigned long ) round_requested_ns( ( int ) option->multiplex.
339 ns );
340 return ( PAPI_OK );
341 }
343 {
344 option->itimer.ns = round_requested_ns( option->itimer.ns );
345 return ( PAPI_OK );
346 }
347 default:
348 return ( PAPI_ENOSUPP );
349 }
350}
#define PAPI_DEFGRN
Definition: f90papi.h:26
#define PAPI_GRANUL
Definition: f90papi.h:179
#define PAPI_DETACH
Definition: f90papi.h:64
#define PAPI_ATTACH
Definition: f90papi.h:70
#define PAPI_EINVAL
Definition: f90papi.h:115
#define PAPI_ENOSUPP
Definition: f90papi.h:244
#define PAPI_DOMAIN
Definition: f90papi.h:159
#define PAPI_DEF_MPX_NS
Definition: f90papi.h:235
#define PAPI_ECMP
Definition: f90papi.h:214
#define PAPI_DEFDOM
Definition: f90papi.h:188
#define PAPI_DEF_ITIMER
Definition: papi.h:462
#define PAPI_DEF_ITIMER_NS
Definition: papi.h:463
static int set_domain(hwd_control_state_t *cntrl, unsigned int domain)
papi_vector_t _perfctr_vector
Definition: perfctr-x86.c:1163
static int attach(hwd_control_state_t *ctl, unsigned long tid)
Definition: perfctr.c:248
static int detach(hwd_control_state_t *ctl)
Definition: perfctr.c:277
static int round_requested_ns(int ns)
Definition: perfctr.c:284
long long int long long
Definition: sde_internal.h:85
hwd_control_state_t * ctl_state
EventSetInfo_t * ESI
unsigned long tid
EventSetInfo_t * ESI
_papi_int_domain_t domain
_papi_int_multiplex_t multiplex
_papi_int_attach_t attach
_papi_int_itimer_t itimer
Here is the call graph for this function:

◆ _perfctr_dispatch_timer()

void _perfctr_dispatch_timer ( int  signal,
hwd_siginfo_t si,
void *  context 
)

◆ _perfctr_init_component()

int _perfctr_init_component ( int  cidx)

Definition at line 107 of file perfctr.c.

108{
109 int retval;
110 struct perfctr_info info;
111 char abiv[PAPI_MIN_STR_LEN];
112
113#if defined(PERFCTR26)
114 int fd;
115#else
116 struct vperfctr *dev;
117#endif
118
119#if defined(PERFCTR26)
120 /* Get info from the kernel */
121 /* Use lower level calls per Mikael to get the perfctr info
122 without actually creating a new kernel-side state.
123 Also, close the fd immediately after retrieving the info.
124 This is much lighter weight and doesn't reserve the counter
125 resources. Also compatible with perfctr 2.6.14.
126 */
127 fd = _vperfctr_open( 0 );
128 if ( fd < 0 ) {
132 goto fn_fail;
133 }
134 retval = perfctr_info( fd, &info );
135 close( fd );
136 if ( retval < 0 ) {
140 goto fn_fail;
141 }
142
143 /* copy tsc multiplier to local variable */
144 /* this field appears in perfctr 2.6 and higher */
145 tb_scale_factor = ( long long ) info.tsc_to_cpu_mult;
146#else
147 /* Opened once for all threads. */
148 if ( ( dev = vperfctr_open( ) ) == NULL ) {
152 goto fn_fail;
153 }
154 SUBDBG( "_perfctr_init_component vperfctr_open = %p\n", dev );
155
156 /* Get info from the kernel */
157 retval = vperfctr_info( dev, &info );
158 if ( retval < 0 ) {
162 goto fn_fail;
163 }
164 vperfctr_close( dev );
165#endif
166
167 /* Fill in what we can of the papi_system_info. */
169 if ( retval != PAPI_OK )
170 goto fn_fail;
171
172 /* Setup memory info */
174 ( int ) info.cpu_type );
175 if ( retval )
176 goto fn_fail;
177
178 strcpy( _perfctr_vector.cmp_info.name,"perfctr.c" );
179 strcpy( _perfctr_vector.cmp_info.version, "$Revision$" );
180 sprintf( abiv, "0x%08X", info.abi_version );
182 strcpy( _perfctr_vector.cmp_info.kernel_version, info.driver_version );
186 if ( info.cpu_features & PERFCTR_FEATURE_RDPMC )
188 else
195#if !defined(PPC64)
196 /* AMD and Intel ia386 processors all support unit mask bits */
198#endif
199#if defined(PPC64)
202#else
204#endif
207 if ( info.cpu_features & PERFCTR_FEATURE_PCINT )
209 else
211 SUBDBG( "Hardware/OS %s support counter generated interrupts\n",
212 _perfctr_vector.cmp_info.hardware_intr ? "does" : "does not" );
213
215 PERFCTR_CPU_NAME( &info ) );
216 _papi_hwi_system_info.hw_info.model = ( int ) info.cpu_type;
217#if defined(PPC64)
219 if ( strlen( _papi_hwi_system_info.hw_info.vendor_string ) == 0 )
221#else
223 xlate_cpu_type_to_vendor( info.cpu_type );
224#endif
225
226 /* Setup presets last. Some platforms depend on earlier info */
227#if !defined(PPC64)
228// retval = setup_p3_vector_table(vtable);
229 if ( !retval )
231#else
232 /* Setup native and preset events */
233// retval = ppc64_setup_vector_table(vtable);
234 if ( !retval )
236 if ( !retval )
237 retval = setup_ppc64_presets( info.cpu_type, cidx );
238#endif
239
240 fn_exit:
241 _papi_hwd[cidx]->cmp_info.disabled = retval;
242 return retval;
243 fn_fail:
244 goto fn_exit;
245}
papi_os_vector_t _papi_os_vector
Definition: aix.c:1288
int close(int fd)
Definition: appio.c:179
struct papi_vectors * _papi_hwd[]
#define PAPI_DOM_USER
Definition: f90papi.h:174
#define PAPI_MIN_STR_LEN
Definition: f90papi.h:208
#define PAPI_VENDOR_IBM
Definition: f90papi.h:61
#define PAPI_DOM_KERNEL
Definition: f90papi.h:254
#define PAPI_DOM_SUPERVISOR
Definition: f90papi.h:109
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define PAPI_ESYS
Definition: f90papi.h:136
#define PAPI_GRN_THR
Definition: f90papi.h:265
int _papi_libpfm_init(papi_vector_t *my_vector, int cidx)
static int cidx
int setup_ppc64_presets(int cputype)
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
#define VOPEN_ERROR
Definition: perfctr-x86.h:62
#define VINFO_ERROR
Definition: perfctr-x86.h:64
static int xlate_cpu_type_to_vendor(unsigned perfctr_cpu_type)
Definition: perfctr.c:55
#define PERFCTR_CPU_NAME
Definition: perfctr.c:49
#define PERFCTR_CPU_NRCTRS
Definition: perfctr.c:50
long long tb_scale_factor
Definition: perfctr.c:104
int perfctr_ppc64_setup_native_table()
Definition: ppc64_events.c:73
if(file==NULL) goto out
unsigned int fast_virtual_timer
Definition: papi.h:657
int default_granularity
Definition: papi.h:644
unsigned int cntr_umasks
Definition: papi.h:660
unsigned int fast_counter_read
Definition: papi.h:655
int available_granularities
Definition: papi.h:645
char support_version[PAPI_MIN_STR_LEN]
Definition: papi.h:632
char kernel_version[PAPI_MIN_STR_LEN]
Definition: papi.h:633
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:627
unsigned int attach
Definition: papi.h:658
unsigned int attach_must_ptrace
Definition: papi.h:659
char disabled_reason[PAPI_HUGE_STR_LEN]
Definition: papi.h:634
char version[PAPI_MIN_STR_LEN]
Definition: papi.h:631
unsigned int fast_real_timer
Definition: papi.h:656
unsigned int hardware_intr
Definition: papi.h:650
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:782
int model
Definition: papi.h:783
int vendor
Definition: papi.h:781
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:784
PAPI_hw_info_t hw_info
int(* get_system_info)(papi_mdi_t *mdi)
Definition: papi_vector.h:68
int(* get_memory_info)(PAPI_hw_info_t *, int)
Definition: papi_vector.h:69
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:

◆ _perfctr_init_thread()

int _perfctr_init_thread ( hwd_context_t ctx)

Definition at line 386 of file perfctr.c.

387{
388 struct vperfctr_control tmp;
389 int error;
390
391 /* Initialize our thread/process pointer. */
392 if ( ( ctx->perfctr = vperfctr_open( ) ) == NULL ) {
393#ifdef VPERFCTR_OPEN_CREAT_EXCL
394 /* New versions of perfctr have this, which allows us to
395 get a previously created context, i.e. one created after
396 a fork and now we're inside a new process that has been exec'd */
397 if ( errno ) {
398 if ( ( ctx->perfctr = vperfctr_open_mode( 0 ) ) == NULL ) {
399 return PAPI_ESYS;
400 }
401 } else {
402 return PAPI_ESYS;
403 }
404#else
405 return PAPI_ESYS;
406#endif
407 }
408 SUBDBG( "_papi_hwd_init vperfctr_open() = %p\n", ctx->perfctr );
409
410 /* Initialize the per thread/process virtualized TSC */
411 memset( &tmp, 0x0, sizeof ( tmp ) );
412 tmp.cpu_control.tsc_on = 1;
413
414#ifdef VPERFCTR_CONTROL_CLOEXEC
415 tmp.flags = VPERFCTR_CONTROL_CLOEXEC;
416 SUBDBG( "close on exec\t\t\t%u\n", tmp.flags );
417#endif
418
419 /* Start the per thread/process virtualized TSC */
420 error = vperfctr_control( ctx->perfctr, &tmp );
421 if ( error < 0 ) {
422 SUBDBG( "starting virtualized TSC; vperfctr_control returns %d\n",
423 error );
424 return PAPI_ESYS;
425 }
426
427 return PAPI_OK;
428}
double tmp
int errno

◆ _perfctr_shutdown_thread()

int _perfctr_shutdown_thread ( hwd_context_t ctx)

Definition at line 434 of file perfctr.c.

435{
436#ifdef DEBUG
437 int retval = vperfctr_unlink( ctx->perfctr );
438 SUBDBG( "_papi_hwd_shutdown vperfctr_unlink(%p) = %d\n", ctx->perfctr,
439 retval );
440#else
441 vperfctr_unlink( ctx->perfctr );
442#endif
443 vperfctr_close( ctx->perfctr );
444 SUBDBG( "_perfctr_shutdown vperfctr_close(%p)\n", ctx->perfctr );
445 memset( ctx, 0x0, sizeof ( hwd_context_t ) );
446 return ( PAPI_OK );
447}

◆ _pfm_get_counter_info()

static int _pfm_get_counter_info ( unsigned int  event,
unsigned int selector,
int code 
)
static

Definition at line 970 of file perfctr-x86.c.

971{
972 pfmlib_regmask_t cnt, impl;
973 unsigned int num;
974 unsigned int i, first = 1;
975 int ret;
976
977 if ( ( ret = pfm_get_event_counters( event, &cnt ) ) != PFMLIB_SUCCESS ) {
978 PAPIERROR( "pfm_get_event_counters(%d,%p): %s", event, &cnt,
979 pfm_strerror( ret ) );
980 return PAPI_ESYS;
981 }
982 if ( ( ret = pfm_get_num_counters( &num ) ) != PFMLIB_SUCCESS ) {
983 PAPIERROR( "pfm_get_num_counters(%p): %s", num, pfm_strerror( ret ) );
984 return PAPI_ESYS;
985 }
986 if ( ( ret = pfm_get_impl_counters( &impl ) ) != PFMLIB_SUCCESS ) {
987 PAPIERROR( "pfm_get_impl_counters(%p): %s", &impl,
988 pfm_strerror( ret ) );
989 return PAPI_ESYS;
990 }
991
992 *selector = 0;
993 for ( i = 0; num; i++ ) {
994 if ( pfm_regmask_isset( &impl, i ) )
995 num--;
996 if ( pfm_regmask_isset( &cnt, i ) ) {
997 if ( first ) {
998 if ( ( ret =
1000 code ) ) !=
1001 PFMLIB_SUCCESS ) {
1002 PAPIERROR( "pfm_get_event_code_counter(%d, %d, %p): %s",
1003 event, i, code, pfm_strerror( ret ) );
1004 return PAPI_ESYS;
1005 }
1006 first = 0;
1007 }
1008 *selector |= 1 << i;
1009 }
1010 }
1011 return PAPI_OK;
1012}
void PAPIERROR(char *format,...)
pfm_err_t pfm_get_event_counters(unsigned int idx, pfmlib_regmask_t *counters)
char * pfm_strerror(int code)
pfm_err_t pfm_get_event_code_counter(unsigned int idx, unsigned int cnt, int *code)
#define PFMLIB_SUCCESS
Definition: pfmlib.h:283
pfm_err_t pfm_get_impl_counters(pfmlib_regmask_t *impl_counters)
static int pfm_regmask_isset(pfmlib_regmask_t *h, unsigned int b)
Definition: pfmlib.h:313
pfm_err_t pfm_get_num_counters(unsigned int *num)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _x86_allocate_registers()

static int _x86_allocate_registers ( EventSetInfo_t ESI)
static

Definition at line 418 of file perfctr-x86.c.

419{
420 int i, j, natNum;
421 hwd_reg_alloc_t event_list[MAX_COUNTERS];
422 hwd_register_t *ptr;
423
424 /* Initialize the local structure needed
425 for counter allocation and optimization. */
426 natNum = ESI->NativeCount;
427
428 if ( is_pentium4() ) {
429 SUBDBG( "native event count: %d\n", natNum );
430 }
431
432 for ( i = 0; i < natNum; i++ ) {
433 /* retrieve the mapping information about this native event */
435 ni_event, &event_list[i].ra_bits );
436
437 if ( is_pentium4() ) {
438 /* combine counter bit masks for both esc registers into selector */
439 event_list[i].ra_selector =
440 event_list[i].ra_bits.counter[0] | event_list[i].ra_bits.
441 counter[1];
442 } else {
443 /* make sure register allocator only looks at legal registers */
444 event_list[i].ra_selector =
445 event_list[i].ra_bits.selector & ALLCNTRS;
446#ifdef PERFCTR_X86_INTEL_CORE2
448 PERFCTR_X86_INTEL_CORE2 )
449 event_list[i].ra_selector |=
450 ( ( event_list[i].ra_bits.
451 selector >> 16 ) << 2 ) & ALLCNTRS;
452#endif
453 }
454 /* calculate native event rank, which is no. of counters it can live on */
455 event_list[i].ra_rank = 0;
456 for ( j = 0; j < MAX_COUNTERS; j++ ) {
457 if ( event_list[i].ra_selector & ( 1 << j ) ) {
458 event_list[i].ra_rank++;
459 }
460 }
461
462 if ( is_pentium4() ) {
463 event_list[i].ra_escr[0] = event_list[i].ra_bits.escr[0];
464 event_list[i].ra_escr[1] = event_list[i].ra_bits.escr[1];
465#ifdef DEBUG
466 SUBDBG( "i: %d\n", i );
467 print_alloc( &event_list[i] );
468#endif
469 }
470 }
471 if ( _papi_bipartite_alloc( event_list, natNum, ESI->CmpIdx ) ) { /* successfully mapped */
472 for ( i = 0; i < natNum; i++ ) {
473#ifdef PERFCTR_X86_INTEL_CORE2
475 PERFCTR_X86_INTEL_CORE2 )
476 event_list[i].ra_bits.selector = event_list[i].ra_selector;
477#endif
478#ifdef DEBUG
479 if ( is_pentium4() ) {
480 SUBDBG( "i: %d\n", i );
481 print_alloc( &event_list[i] );
482 }
483#endif
484 /* Copy all info about this native event to the NativeInfo struct */
485 ptr = ESI->NativeInfoArray[i].ni_bits;
486 *ptr = event_list[i].ra_bits;
487
488 if ( is_pentium4() ) {
489 /* The selector contains the counter bit position. Turn it into a number
490 and store it in the first counter value, zeroing the second. */
491 ptr->counter[0] = ffs( event_list[i].ra_selector ) - 1;
492 ptr->counter[1] = 0;
493 }
494
495 /* Array order on perfctr is event ADD order, not counter #... */
497 }
498 return PAPI_OK;
499 } else
500 return PAPI_ECNFLCT;
501}
#define PAPI_ECNFLCT
Definition: f90papi.h:234
static int _papi_bipartite_alloc(hwd_reg_alloc_t *event_list, int count, int cidx)
int _papi_libpfm_ntv_code_to_bits_perfctr(unsigned int EventCode, hwd_register_t *newbits)
Definition: perfctr-x86.c:1015
#define ALLCNTRS
Definition: perfctr-x86.h:35
NativeInfo_t * NativeInfoArray
hwd_register_t * ni_bits
Here is the call graph for this function:

◆ _x86_init_control_state()

static int _x86_init_control_state ( hwd_control_state_t ptr)
static

Definition at line 119 of file perfctr-x86.c.

120{
121 int i, def_mode = 0;
122
123 if ( is_pentium4() ) {
125 def_mode |= ESCR_T0_USR;
127 def_mode |= ESCR_T0_OS;
128
129 for ( i = 0; i < _perfctr_vector.cmp_info.num_cntrs; i++ ) {
130 ptr->control.cpu_control.evntsel_aux[i] |= def_mode;
131 }
132 ptr->control.cpu_control.tsc_on = 1;
133 ptr->control.cpu_control.nractrs = 0;
134 ptr->control.cpu_control.nrictrs = 0;
135
136#ifdef VPERFCTR_CONTROL_CLOEXEC
137 ptr->control.flags = VPERFCTR_CONTROL_CLOEXEC;
138 SUBDBG( "close on exec\t\t\t%u\n", ptr->control.flags );
139#endif
140 } else {
141
143 def_mode |= PERF_USR;
145 def_mode |= PERF_OS;
146
147 ptr->allocated_registers.selector = 0;
149 case PERFCTR_X86_GENERIC:
150 case PERFCTR_X86_WINCHIP_C6:
151 case PERFCTR_X86_WINCHIP_2:
152 case PERFCTR_X86_VIA_C3:
153 case PERFCTR_X86_INTEL_P5:
154 case PERFCTR_X86_INTEL_P5MMX:
155 case PERFCTR_X86_INTEL_PII:
156 case PERFCTR_X86_INTEL_P6:
157 case PERFCTR_X86_INTEL_PIII:
158#ifdef PERFCTR_X86_INTEL_CORE
159 case PERFCTR_X86_INTEL_CORE:
160#endif
161#ifdef PERFCTR_X86_INTEL_PENTM
162 case PERFCTR_X86_INTEL_PENTM:
163#endif
164 ptr->control.cpu_control.evntsel[0] |= PERF_ENABLE;
165 for ( i = 0; i < _perfctr_vector.cmp_info.num_cntrs; i++ ) {
166 ptr->control.cpu_control.evntsel[i] |= def_mode;
167 ptr->control.cpu_control.pmc_map[i] = ( unsigned int ) i;
168 }
169 break;
170#ifdef PERFCTR_X86_INTEL_CORE2
171 case PERFCTR_X86_INTEL_CORE2:
172#endif
173#ifdef PERFCTR_X86_INTEL_ATOM
174 case PERFCTR_X86_INTEL_ATOM:
175#endif
176#ifdef PERFCTR_X86_INTEL_NHLM
177 case PERFCTR_X86_INTEL_NHLM:
178#endif
179#ifdef PERFCTR_X86_INTEL_WSTMR
180 case PERFCTR_X86_INTEL_WSTMR:
181#endif
182#ifdef PERFCTR_X86_AMD_K8
183 case PERFCTR_X86_AMD_K8:
184#endif
185#ifdef PERFCTR_X86_AMD_K8C
186 case PERFCTR_X86_AMD_K8C:
187#endif
188#ifdef PERFCTR_X86_AMD_FAM10H /* this is defined in perfctr 2.6.29 */
189 case PERFCTR_X86_AMD_FAM10H:
190#endif
191 case PERFCTR_X86_AMD_K7:
192 for ( i = 0; i < _perfctr_vector.cmp_info.num_cntrs; i++ ) {
193 ptr->control.cpu_control.evntsel[i] |= PERF_ENABLE | def_mode;
194 ptr->control.cpu_control.pmc_map[i] = ( unsigned int ) i;
195 }
196 break;
197 }
198#ifdef VPERFCTR_CONTROL_CLOEXEC
199 ptr->control.flags = VPERFCTR_CONTROL_CLOEXEC;
200 SUBDBG( "close on exec\t\t\t%u\n", ptr->control.flags );
201#endif
202
203 /* Make sure the TSC is always on */
204 ptr->control.cpu_control.tsc_on = 1;
205 }
206 return ( PAPI_OK );
207}
papi_vector_t _perfctr_vector
Definition: perfctr-x86.c:1163
#define ESCR_T0_USR
Definition: perfctr-x86.h:17
#define PERF_OS
Definition: perfctr-x86.h:56
#define PERF_ENABLE
Definition: perfctr-x86.h:52
#define PERF_USR
Definition: perfctr-x86.h:57
#define ESCR_T0_OS
Definition: perfctr-x86.h:16
Here is the call graph for this function:

◆ _x86_read()

static int _x86_read ( hwd_context_t ctx,
hwd_control_state_t spc,
long long **  dp,
int  flags 
)
static

Definition at line 701 of file perfctr-x86.c.

703{
704 if ( flags & PAPI_PAUSED ) {
705 vperfctr_read_state( ctx->perfctr, &spc->state, NULL );
706 if ( !is_pentium4() ) {
707 unsigned int i = 0;
708 for ( i = 0;
709 i <
710 spc->control.cpu_control.nractrs +
711 spc->control.cpu_control.nrictrs; i++ ) {
712 SUBDBG( "vperfctr_read_state: counter %d = %lld\n", i,
713 spc->state.pmc[i] );
714 }
715 }
716 } else {
717 SUBDBG( "vperfctr_read_ctrs\n" );
718 if ( spc->rvperfctr != NULL ) {
719 rvperfctr_read_ctrs( spc->rvperfctr, &spc->state );
720 } else {
721 vperfctr_read_ctrs( ctx->perfctr, &spc->state );
722 }
723 }
724 *dp = ( long long * ) spc->state.pmc;
725#ifdef DEBUG
726 {
727 if ( ISLEVEL( DEBUG_SUBSTRATE ) ) {
728 unsigned int i;
729 if ( is_pentium4() ) {
730 for ( i = 0; i < spc->control.cpu_control.nractrs; i++ ) {
731 SUBDBG( "raw val hardware index %d is %lld\n", i,
732 ( long long ) spc->state.pmc[i] );
733 }
734 } else {
735 for ( i = 0;
736 i <
737 spc->control.cpu_control.nractrs +
738 spc->control.cpu_control.nrictrs; i++ ) {
739 SUBDBG( "raw val hardware index %d is %lld\n", i,
740 ( long long ) spc->state.pmc[i] );
741 }
742 }
743 }
744 }
745#endif
746 return ( PAPI_OK );
747}
#define PAPI_PAUSED
Definition: f90papi.h:25
#define DEBUG_SUBSTRATE
Definition: papi_debug.h:27
#define ISLEVEL(a)
Definition: papi_debug.h:55
Here is the call graph for this function:

◆ _x86_reset()

static int _x86_reset ( hwd_context_t ctx,
hwd_control_state_t cntrl 
)
static

Definition at line 750 of file perfctr-x86.c.

751{
752 return ( _x86_start( ctx, cntrl ) );
753}
static int _x86_start(hwd_context_t *ctx, hwd_control_state_t *state)
Definition: perfctr-x86.c:653
Here is the call graph for this function:

◆ _x86_set_domain()

int _x86_set_domain ( hwd_control_state_t cntrl,
int  domain 
)

Definition at line 210 of file perfctr-x86.c.

211{
212 int i, did = 0;
213 int num_cntrs = _perfctr_vector.cmp_info.num_cntrs;
214
215 /* Clear the current domain set for this event set */
216 /* We don't touch the Enable bit in this code */
217 if ( is_pentium4() ) {
218 for ( i = 0; i < _perfctr_vector.cmp_info.num_cntrs; i++ ) {
219 cntrl->control.cpu_control.evntsel_aux[i] &=
220 ~( ESCR_T0_OS | ESCR_T0_USR );
221 }
222
223 if ( domain & PAPI_DOM_USER ) {
224 did = 1;
225 for ( i = 0; i < _perfctr_vector.cmp_info.num_cntrs; i++ ) {
226 cntrl->control.cpu_control.evntsel_aux[i] |= ESCR_T0_USR;
227 }
228 }
229
230 if ( domain & PAPI_DOM_KERNEL ) {
231 did = 1;
232 for ( i = 0; i < _perfctr_vector.cmp_info.num_cntrs; i++ ) {
233 cntrl->control.cpu_control.evntsel_aux[i] |= ESCR_T0_OS;
234 }
235 }
236 } else {
237 for ( i = 0; i < num_cntrs; i++ ) {
238 cntrl->control.cpu_control.evntsel[i] &= ~( PERF_OS | PERF_USR );
239 }
240
241 if ( domain & PAPI_DOM_USER ) {
242 did = 1;
243 for ( i = 0; i < num_cntrs; i++ ) {
244 cntrl->control.cpu_control.evntsel[i] |= PERF_USR;
245 }
246 }
247
248 if ( domain & PAPI_DOM_KERNEL ) {
249 did = 1;
250 for ( i = 0; i < num_cntrs; i++ ) {
251 cntrl->control.cpu_control.evntsel[i] |= PERF_OS;
252 }
253 }
254 }
255
256 if ( !did )
257 return ( PAPI_EINVAL );
258 else
259 return ( PAPI_OK );
260}
Here is the call graph for this function:

◆ _x86_set_overflow()

static int _x86_set_overflow ( EventSetInfo_t ESI,
int  EventIndex,
int  threshold 
)
static

Definition at line 805 of file perfctr-x86.c.

806{
808 struct hwd_pmc_control *contr = &(ctl->control);
809 int i, ncntrs, nricntrs = 0, nracntrs = 0, retval = 0;
810 OVFDBG( "EventIndex=%d\n", EventIndex );
811
812#ifdef DEBUG
813 if ( is_pentium4() )
814 print_control( &(contr->cpu_control) );
815#endif
816
817 /* The correct event to overflow is EventIndex */
819 i = ESI->EventInfoArray[EventIndex].pos[0];
820
821 if ( i >= ncntrs ) {
822 PAPIERROR( "Selector id %d is larger than ncntrs %d", i, ncntrs );
823 return PAPI_EINVAL;
824 }
825
826 if ( threshold != 0 ) { /* Set an overflow threshold */
830 if ( retval != PAPI_OK )
831 return ( retval );
832
833 /* overflow interrupt occurs on the NEXT event after overflow occurs
834 thus we subtract 1 from the threshold. */
835 contr->cpu_control.ireset[i] = ( -threshold + 1 );
836
837 if ( is_pentium4() )
838 contr->cpu_control.evntsel[i] |= CCCR_OVF_PMI_T0;
839 else
840 contr->cpu_control.evntsel[i] |= PERF_INT_ENABLE;
841
842 contr->cpu_control.nrictrs++;
843 contr->cpu_control.nractrs--;
844 nricntrs = ( int ) contr->cpu_control.nrictrs;
845 nracntrs = ( int ) contr->cpu_control.nractrs;
847
848 /* move this event to the bottom part of the list if needed */
849 if ( i < nracntrs )
850 swap_events( ESI, contr, i, nracntrs );
851 OVFDBG( "Modified event set\n" );
852 } else {
853 if ( is_pentium4() && contr->cpu_control.evntsel[i] & CCCR_OVF_PMI_T0 ) {
854 contr->cpu_control.ireset[i] = 0;
855 contr->cpu_control.evntsel[i] &= ( ~CCCR_OVF_PMI_T0 );
856 contr->cpu_control.nrictrs--;
857 contr->cpu_control.nractrs++;
858 } else if ( !is_pentium4() &&
859 contr->cpu_control.evntsel[i] & PERF_INT_ENABLE ) {
860 contr->cpu_control.ireset[i] = 0;
861 contr->cpu_control.evntsel[i] &= ( ~PERF_INT_ENABLE );
862 contr->cpu_control.nrictrs--;
863 contr->cpu_control.nractrs++;
864 }
865
866 nricntrs = ( int ) contr->cpu_control.nrictrs;
867 nracntrs = ( int ) contr->cpu_control.nractrs;
868
869 /* move this event to the top part of the list if needed */
870 if ( i >= nracntrs )
871 swap_events( ESI, contr, i, nracntrs - 1 );
872
873 if ( !nricntrs )
874 contr->si_signo = 0;
875
876 OVFDBG( "Modified event set\n" );
877
879 }
880
881#ifdef DEBUG
882 if ( is_pentium4() )
883 print_control( &(contr->cpu_control) );
884#endif
885 OVFDBG( "End of call. Exit code: %d\n", retval );
886 return ( retval );
887}
int _papi_hwi_start_signal(int signal, int need_context, int cidx)
Definition: extras.c:403
int _papi_hwi_stop_signal(int signal)
Definition: extras.c:443
static int threshold
#define OVFDBG(format, args...)
Definition: papi_debug.h:69
#define NEED_CONTEXT
Definition: papi_internal.h:97
void print_control(const struct perfctr_cpu_control *control)
Definition: perfctr-x86.c:96
static void swap_events(EventSetInfo_t *ESI, struct hwd_pmc_control *contr, int cntr1, int cntr2)
Definition: perfctr-x86.c:762
#define PERF_INT_ENABLE
Definition: perfctr-x86.h:53
#define hwd_pmc_control
Definition: perfctr-x86.h:11
#define CCCR_OVF_PMI_T0
Definition: perfctr-x86.h:18
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
EventInfo_t * EventInfoArray
Here is the call graph for this function:

◆ _x86_start()

static int _x86_start ( hwd_context_t ctx,
hwd_control_state_t state 
)
static

Definition at line 653 of file perfctr-x86.c.

654{
655 int error;
656#ifdef DEBUG
657 print_control( &state->control.cpu_control );
658#endif
659
660 if ( state->rvperfctr != NULL ) {
661 if ( ( error =
662 rvperfctr_control( state->rvperfctr, &state->control ) ) < 0 ) {
663 SUBDBG( "rvperfctr_control returns: %d\n", error );
665 return ( PAPI_ESYS );
666 }
667 return ( PAPI_OK );
668 }
669
670 if ( ( error = vperfctr_control( ctx->perfctr, &state->control ) ) < 0 ) {
671 SUBDBG( "vperfctr_control returns: %d\n", error );
673 return ( PAPI_ESYS );
674 }
675 return ( PAPI_OK );
676}
bool state
Definition: papi_hl.c:155
#define VCNTRL_ERROR
Definition: perfctr-x86.h:65
#define RCNTRL_ERROR
Definition: perfctr-x86.h:66
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _x86_stop()

static int _x86_stop ( hwd_context_t ctx,
hwd_control_state_t state 
)
static

Definition at line 679 of file perfctr-x86.c.

680{
681 int error;
682
683 if ( state->rvperfctr != NULL ) {
684 if ( rvperfctr_stop( ( struct rvperfctr * ) ctx->perfctr ) < 0 ) {
686 return ( PAPI_ESYS );
687 }
688 return ( PAPI_OK );
689 }
690
691 error = vperfctr_stop( ctx->perfctr );
692 if ( error < 0 ) {
693 SUBDBG( "vperfctr_stop returns: %d\n", error );
695 return ( PAPI_ESYS );
696 }
697 return ( PAPI_OK );
698}
Here is the call graph for this function:

◆ _x86_stop_profiling()

static int _x86_stop_profiling ( ThreadInfo_t master,
EventSetInfo_t ESI 
)
static

Definition at line 890 of file perfctr-x86.c.

891{
892 ( void ) master; /*unused */
893 ( void ) ESI; /*unused */
894 return ( PAPI_OK );
895}

◆ _x86_update_control_state()

static int _x86_update_control_state ( hwd_control_state_t this_state,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)
static

Definition at line 550 of file perfctr-x86.c.

553{
554 ( void ) ctx; /*unused */
555 unsigned int i, k, retval = PAPI_OK;
556 hwd_register_t *bits,*bits2;
557 struct perfctr_cpu_control *cpu_control = &this_state->control.cpu_control;
558
559 /* clear out the events from the control state */
560 clear_cs_events( this_state );
561
562 if ( is_pentium4() ) {
563 /* fill the counters we're using */
564 for ( i = 0; i < ( unsigned int ) count; i++ ) {
565 /* dereference the mapping information about this native event */
566 bits = native[i].ni_bits;
567
568 /* Add counter control command values to eventset */
569 cpu_control->pmc_map[i] = bits->counter[0];
570 cpu_control->evntsel[i] = bits->cccr;
571 cpu_control->ireset[i] = bits->ireset;
572 cpu_control->pmc_map[i] |= FAST_RDPMC;
573 cpu_control->evntsel_aux[i] |= bits->event;
574
575 /* pebs_enable and pebs_matrix_vert are shared registers used for replay_events.
576 Replay_events count L1 and L2 cache events. There is only one of each for
577 the entire eventset. Therefore, there can be only one unique replay_event
578 per eventset. This means L1 and L2 can't be counted together. Which stinks.
579 This conflict should be trapped in the allocation scheme, but we'll test for it
580 here too, just in case. */
581 if ( bits->pebs_enable ) {
582 /* if pebs_enable isn't set, just copy */
583 if ( cpu_control->p4.pebs_enable == 0 ) {
584 cpu_control->p4.pebs_enable = bits->pebs_enable;
585 /* if pebs_enable conflicts, flag an error */
586 } else if ( cpu_control->p4.pebs_enable != bits->pebs_enable ) {
587 SUBDBG
588 ( "WARNING: P4_update_control_state -- pebs_enable conflict!" );
590 }
591 /* if pebs_enable == bits->pebs_enable, do nothing */
592 }
593 if ( bits->pebs_matrix_vert ) {
594 /* if pebs_matrix_vert isn't set, just copy */
595 if ( cpu_control->p4.pebs_matrix_vert == 0 ) {
596 cpu_control->p4.pebs_matrix_vert = bits->pebs_matrix_vert;
597 /* if pebs_matrix_vert conflicts, flag an error */
598 } else if ( cpu_control->p4.pebs_matrix_vert !=
599 bits->pebs_matrix_vert ) {
600 SUBDBG
601 ( "WARNING: P4_update_control_state -- pebs_matrix_vert conflict!" );
603 }
604 /* if pebs_matrix_vert == bits->pebs_matrix_vert, do nothing */
605 }
606 }
607 this_state->control.cpu_control.nractrs = count;
608
609 /* Make sure the TSC is always on */
610 this_state->control.cpu_control.tsc_on = 1;
611
612#ifdef DEBUG
613 print_control( &this_state->control.cpu_control );
614#endif
615 } else {
617#ifdef PERFCTR_X86_INTEL_CORE2
618 case PERFCTR_X86_INTEL_CORE2:
619 /* fill the counters we're using */
620 for ( i = 0; i < ( unsigned int ) count; i++ ) {
621 bits2 = native[i].ni_bits;
622 for ( k = 0; k < MAX_COUNTERS; k++ )
623 if ( bits2->selector & ( 1 << k ) ) {
624 break;
625 }
626 if ( k > 1 )
627 this_state->control.cpu_control.pmc_map[i] =
628 ( k - 2 ) | 0x40000000;
629 else
630 this_state->control.cpu_control.pmc_map[i] = k;
631
632 /* Add counter control command values to eventset */
633 this_state->control.cpu_control.evntsel[i] |=
634 bits2->counter_cmd;
635 }
636 break;
637#endif
638 default:
639 /* fill the counters we're using */
640 for ( i = 0; i < ( unsigned int ) count; i++ ) {
641 /* Add counter control command values to eventset */
642 bits2 = native[i].ni_bits;
643 this_state->control.cpu_control.evntsel[i] |=
644 bits2->counter_cmd;
645 }
646 }
647 this_state->control.cpu_control.nractrs = ( unsigned int ) count;
648 }
649 return retval;
650}
static long count
static int native
static void clear_cs_events(hwd_control_state_t *this_state)
Definition: perfctr-x86.c:504
#define FAST_RDPMC
Definition: perfctr-x86.h:19
int event[MAX_COUNTERS]
Definition: solaris-ultra.h:47
Here is the call graph for this function:

◆ clear_cs_events()

static void clear_cs_events ( hwd_control_state_t this_state)
static

Definition at line 504 of file perfctr-x86.c.

505{
506 unsigned int i, j;
507
508 /* total counters is sum of accumulating (nractrs) and interrupting (nrictrs) */
509 j = this_state->control.cpu_control.nractrs +
510 this_state->control.cpu_control.nrictrs;
511
512 /* Remove all counter control command values from eventset. */
513 for ( i = 0; i < j; i++ ) {
514 SUBDBG( "Clearing pmc event entry %d\n", i );
515 if ( is_pentium4() ) {
516 this_state->control.cpu_control.pmc_map[i] = 0;
517 this_state->control.cpu_control.evntsel[i] = 0;
518 this_state->control.cpu_control.evntsel_aux[i] =
519 this_state->control.cpu_control.
520 evntsel_aux[i] & ( ESCR_T0_OS | ESCR_T0_USR );
521 } else {
522 this_state->control.cpu_control.pmc_map[i] = i;
523 this_state->control.cpu_control.evntsel[i]
524 = this_state->control.cpu_control.
525 evntsel[i] & ( PERF_ENABLE | PERF_OS | PERF_USR );
526 }
527 this_state->control.cpu_control.ireset[i] = 0;
528 }
529
530 if ( is_pentium4() ) {
531 /* Clear pebs stuff */
532 this_state->control.cpu_control.p4.pebs_enable = 0;
533 this_state->control.cpu_control.p4.pebs_matrix_vert = 0;
534 }
535
536 /* clear both a and i counter counts */
537 this_state->control.cpu_control.nractrs = 0;
538 this_state->control.cpu_control.nrictrs = 0;
539
540#ifdef DEBUG
541 if ( is_pentium4() )
542 print_control( &this_state->control.cpu_control );
543#endif
544}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_pentium4()

static int is_pentium4 ( void  )
inlinestatic

Definition at line 75 of file perfctr-x86.c.

75 {
78 return 1;
79 }
80
81 return 0;
82
83}
#define PAPI_VENDOR_INTEL
Definition: f90papi.h:275
int cpuid_family
Definition: papi.h:786
Here is the caller graph for this function:

◆ print_alloc()

static void print_alloc ( X86_reg_alloc_t a)
static

Definition at line 87 of file perfctr-x86.c.

88{
89 SUBDBG( "X86_reg_alloc:\n" );
90 SUBDBG( " selector: %#x\n", a->ra_selector );
91 SUBDBG( " rank: %#x\n", a->ra_rank );
92 SUBDBG( " escr: %#x %#x\n", a->ra_escr[0], a->ra_escr[1] );
93}
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:38
Here is the caller graph for this function:

◆ print_control()

void print_control ( const struct perfctr_cpu_control *  control)

Definition at line 96 of file perfctr-x86.c.

97{
98 unsigned int i;
99 SUBDBG( "Control used:\n" );
100 SUBDBG( "tsc_on\t\t\t%u\n", control->tsc_on );
101 SUBDBG( "nractrs\t\t\t%u\n", control->nractrs );
102 SUBDBG( "nrictrs\t\t\t%u\n", control->nrictrs );
103
104 for ( i = 0; i < ( control->nractrs + control->nrictrs ); ++i ) {
105 if ( control->pmc_map[i] >= 18 ) {
106 SUBDBG( "pmc_map[%u]\t\t0x%08X\n", i, control->pmc_map[i] );
107 } else {
108 SUBDBG( "pmc_map[%u]\t\t%u\n", i, control->pmc_map[i] );
109 }
110 SUBDBG( "evntsel[%u]\t\t0x%08X\n", i, control->evntsel[i] );
111 if ( control->ireset[i] ) {
112 SUBDBG( "ireset[%u]\t%d\n", i, control->ireset[i] );
113 }
114 }
115}
Here is the caller graph for this function:

◆ swap_events()

static void swap_events ( EventSetInfo_t ESI,
struct hwd_pmc_control contr,
int  cntr1,
int  cntr2 
)
static

Definition at line 762 of file perfctr-x86.c.

764{
765 unsigned int ui;
766 int si, i, j;
767
768 for ( i = 0; i < ESI->NativeCount; i++ ) {
769 if ( ESI->NativeInfoArray[i].ni_position == cntr1 )
770 ESI->NativeInfoArray[i].ni_position = cntr2;
771 else if ( ESI->NativeInfoArray[i].ni_position == cntr2 )
772 ESI->NativeInfoArray[i].ni_position = cntr1;
773 }
774
775 for ( i = 0; i < ESI->NumberOfEvents; i++ ) {
776 for ( j = 0; ESI->EventInfoArray[i].pos[j] >= 0; j++ ) {
777 if ( ESI->EventInfoArray[i].pos[j] == cntr1 )
778 ESI->EventInfoArray[i].pos[j] = cntr2;
779 else if ( ESI->EventInfoArray[i].pos[j] == cntr2 )
780 ESI->EventInfoArray[i].pos[j] = cntr1;
781 }
782 }
783
784 ui = contr->cpu_control.pmc_map[cntr1];
785 contr->cpu_control.pmc_map[cntr1] = contr->cpu_control.pmc_map[cntr2];
786 contr->cpu_control.pmc_map[cntr2] = ui;
787
788 ui = contr->cpu_control.evntsel[cntr1];
789 contr->cpu_control.evntsel[cntr1] = contr->cpu_control.evntsel[cntr2];
790 contr->cpu_control.evntsel[cntr2] = ui;
791
792 if ( is_pentium4() ) {
793 ui = contr->cpu_control.evntsel_aux[cntr1];
794 contr->cpu_control.evntsel_aux[cntr1] =
795 contr->cpu_control.evntsel_aux[cntr2];
796 contr->cpu_control.evntsel_aux[cntr2] = ui;
797 }
798
799 si = contr->cpu_control.ireset[cntr1];
800 contr->cpu_control.ireset[cntr1] = contr->cpu_control.ireset[cntr2];
801 contr->cpu_control.ireset[cntr2] = si;
802}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _papi_hwi_system_info

papi_mdi_t _papi_hwi_system_info
extern

Definition at line 56 of file papi_internal.c.

◆ _perfctr_vector

papi_vector_t _perfctr_vector

Definition at line 1163 of file perfctr-x86.c.

◆ p4_replay_regs

pentium4_replay_regs_t p4_replay_regs[]
static

Definition at line 910 of file perfctr-x86.c.

◆ pentium4_cccrs

pentium4_cccr_reg_t pentium4_cccrs[]
extern

pentium4_cccrs

Array of counter-configuration-control registers that are available on Pentium4.

Definition at line 242 of file pentium4_events.h.

◆ pentium4_escrs

pentium4_escr_reg_t pentium4_escrs[]
extern

pentium4_escrs

Array of event-selection-control registers that are available on Pentium4.

Definition at line 51 of file pentium4_events.h.

◆ pentium4_events

pentium4_event_t pentium4_events[]
extern

pentium4_events

Array of events that can be counted on Pentium4.

Definition at line 607 of file pentium4_events.h.

◆ pfm2intel

int pfm2intel[]
static
Initial value:
=
{ 0, 1, 4, 5, 8, 9, 12, 13, 16, 2, 3, 6, 7, 10, 11, 14, 15, 17 }

Definition at line 958 of file perfctr-x86.c.