PAPI 7.1.0.0
Loading...
Searching...
No Matches
pfmlib_priv.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2002-2006 Hewlett-Packard Development Company, L.P.
3 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
17 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
20 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * This file is part of libpfm, a performance monitoring support library for
23 * applications on Linux/ia64.
24 */
25#ifndef __PFMLIB_PRIV_H__
26#define __PFMLIB_PRIV_H__
27
28#include <perfmon/pfmlib.h>
29
30#include "pfmlib_priv_comp.h"
31
32typedef struct {
33 char *pmu_name;
34 int pmu_type; /* must remain int, using -1 */
35 unsigned int pme_count; /* number of events */
36 unsigned int pmd_count; /* number of PMD registers */
37 unsigned int pmc_count; /* number of PMC registers */
38 unsigned int num_cnt; /* number of counters (counting PMD registers) */
39 unsigned int flags;
40 int (*get_event_code)(unsigned int i, unsigned int cnt, int *code);
41 int (*get_event_mask_code)(unsigned int i, unsigned int mask_idx, unsigned int *code);
42 char *(*get_event_name)(unsigned int i);
43 char *(*get_event_mask_name)(unsigned int event_idx, unsigned int mask_idx);
44 void (*get_event_counters)(unsigned int i, pfmlib_regmask_t *counters);
45 unsigned int (*get_num_event_masks)(unsigned int event_idx);
46 int (*dispatch_events)(pfmlib_input_param_t *p, void *model_in, pfmlib_output_param_t *q, void *model_out);
47 int (*pmu_detect)(void);
48 int (*pmu_init)(void);
49 void (*get_impl_pmcs)(pfmlib_regmask_t *impl_pmcs);
50 void (*get_impl_pmds)(pfmlib_regmask_t *impl_pmds);
51 void (*get_impl_counters)(pfmlib_regmask_t *impl_counters);
52 void (*get_hw_counter_width)(unsigned int *width);
53 int (*get_event_desc)(unsigned int i, char **buf);
54 int (*get_event_mask_desc)(unsigned int event_idx, unsigned int mask_idx, char **buf);
55 int (*get_cycle_event)(pfmlib_event_t *e);
56 int (*get_inst_retired_event)(pfmlib_event_t *e);
57 int (*has_umask_default)(unsigned int i); /* optional */
59
60#define PFMLIB_MULT_CODE_EVENT 0x1 /* more than one code per event (depending on counter) */
61
62#define PFMLIB_CNT_FIRST -1 /* return code for event on first counter */
63
64#define PFMLIB_NO_EVT (~0U) /* no event index associated with event */
65
66typedef struct {
69 int options_env_set; /* 1 if options set by env variables */
71
72#define PFMLIB_INITIALIZED() (pfm_config.current != NULL)
73
75
76#define PFMLIB_DEBUG() pfm_config.options.pfm_debug
77#define PFMLIB_VERBOSE() pfm_config.options.pfm_verbose
78#define pfm_current pfm_config.current
79
80extern void __pfm_vbprintf(const char *fmt,...);
82
83/*
84 * provided by OS-specific module
85 */
86extern int __pfm_getcpuinfo_attr(const char *attr, char *ret_buf, size_t maxlen);
87extern void pfm_init_syscalls(void);
88
89#ifdef PFMLIB_DEBUG
90#define DPRINT(fmt, a...) \
91 do { \
92 if (pfm_config.options.pfm_debug) { \
93 fprintf(libpfm_fp, "%s (%s.%d): " fmt, __FILE__, __func__, __LINE__, ## a); } \
94 } while (0)
95#else
96#define DPRINT(a)
97#endif
98
99#define ALIGN_DOWN(a,p) ((a) & ~((1UL<<(p))-1))
100#define ALIGN_UP(a,p) ((((a) + ((1UL<<(p))-1))) & ~((1UL<<(p))-1))
101
124
125static inline unsigned int pfm_num_masks(int e)
126{
127 if (pfm_current->get_num_event_masks == NULL)
128 return 0;
129 return pfm_current->get_num_event_masks(e);
130}
131
132extern FILE *libpfm_fp;
133extern int forced_pmu;
134extern int _pfmlib_sys_base; /* syscall base */
135extern int _pfmlib_major_version; /* kernel perfmon major version */
136extern int _pfmlib_minor_version; /* kernel perfmon minor version */
137extern void pfm_init_syscalls(void);
138
139static inline int
141{
142 if (!_pfmlib_sys_base)
144 return _pfmlib_sys_base;
145}
146#endif /* __PFMLIB_PRIV_H__ */
int i
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
Definition: do_loops.c:12
pfm_pmu_support_t itanium2_support
pfm_pmu_support_t intel_nhm_support
pfm_pmu_support_t sparc_support
Definition: pfmlib_sparc.c:519
pfm_pmu_support_t itanium_support
pfm_pmu_support_t montecito_support
void __pfm_vbprintf(const char *fmt,...)
Definition: pfmlib_priv.c:52
#define pfm_current
Definition: pfmlib_priv.h:78
int __pfm_getcpuinfo_attr(const char *attr, char *ret_buf, size_t maxlen)
pfm_pmu_support_t generic_mips64_support
pfm_pmu_support_t amd64_support
Definition: pfmlib_amd64.c:98
pfm_pmu_support_t i386_pii_support
pfm_pmu_support_t i386_pm_support
pfm_pmu_support_t core_support
Definition: pfmlib_core.c:903
static int _pfmlib_get_sys_base()
Definition: pfmlib_priv.h:140
static unsigned int pfm_num_masks(int e)
Definition: pfmlib_priv.h:125
pfm_pmu_support_t generic_ia64_support
int __pfm_check_event(pfmlib_event_t *e)
Definition: pfmlib_priv.c:65
pfm_pmu_support_t i386_ppro_support
pfm_pmu_support_t intel_atom_support
pfm_pmu_support_t i386_p6_support
pfm_config_t pfm_config
void pfm_init_syscalls(void)
pfm_pmu_support_t crayx2_support
int _pfmlib_sys_base
pfm_pmu_support_t gen_powerpc_support
int forced_pmu
pfm_pmu_support_t cell_support
Definition: pfmlib_cell.c:675
pfm_pmu_support_t sicortex_support
FILE * libpfm_fp
Definition: pfmlib_priv.c:42
pfm_pmu_support_t intel_wsm_support
pfm_pmu_support_t gen_ia32_support
int _pfmlib_major_version
pfm_pmu_support_t coreduo_support
int _pfmlib_minor_version
pfm_pmu_support_t pentium4_support
static char * get_event_desc(int event)
Definition: pfmlib_sparc.c:73
const char * fmt
Definition: pscanf.h:10
int
Definition: sde_internal.h:89
int options_env_set
Definition: pfmlib_priv.h:69
pfm_pmu_support_t * current
Definition: pfmlib_priv.h:68
pfmlib_options_t options
Definition: pfmlib_priv.h:67
unsigned int pmc_count
Definition: pfmlib_priv.h:37
unsigned int flags
Definition: pfmlib_priv.h:39
unsigned int num_cnt
Definition: pfmlib_priv.h:38
unsigned int pmd_count
Definition: pfmlib_priv.h:36
unsigned int pme_count
Definition: pfmlib_priv.h:35