This is an example component, it demos the component interface and implements three example counters.
More...
Go to the source code of this file.
|
| static void | example_hardware_reset (example_context_t *ctx) |
| |
| static long long | example_hardware_read (int which_one, example_context_t *ctx) |
| |
| static int | example_hardware_write (int which_one, example_context_t *ctx, long long value) |
| |
| static int | detect_example (void) |
| |
| static int | _example_init_component (int cidx) |
| |
| static int | _example_init_thread (hwd_context_t *ctx) |
| |
| static int | _example_init_control_state (hwd_control_state_t *ctl) |
| |
| static int | _example_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *native, int count, hwd_context_t *ctx) |
| |
| static int | _example_start (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | _example_stop (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | _example_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **events, int flags) |
| |
| static int | _example_write (hwd_context_t *ctx, hwd_control_state_t *ctl, long long *events) |
| |
| static int | _example_reset (hwd_context_t *ctx, hwd_control_state_t *ctl) |
| |
| static int | _example_shutdown_component (void) |
| |
| static int | _example_shutdown_thread (hwd_context_t *ctx) |
| |
| static int | _example_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option) |
| |
| static int | _example_set_domain (hwd_control_state_t *cntrl, int domain) |
| |
| static int | _example_ntv_enum_events (unsigned int *EventCode, int modifier) |
| |
| static int | _example_ntv_code_to_name (unsigned int EventCode, char *name, int len) |
| |
| static int | _example_ntv_code_to_descr (unsigned int EventCode, char *descr, int len) |
| |
◆ EXAMPLE_AUTOINC_REG
| #define EXAMPLE_AUTOINC_REG 2 |
◆ EXAMPLE_CONSTANT_REG
| #define EXAMPLE_CONSTANT_REG 1 |
◆ EXAMPLE_GLOBAL_AUTOINC_REG
| #define EXAMPLE_GLOBAL_AUTOINC_REG 3 |
◆ EXAMPLE_MAX_MULTIPLEX_COUNTERS
| #define EXAMPLE_MAX_MULTIPLEX_COUNTERS 4 |
◆ EXAMPLE_MAX_SIMULTANEOUS_COUNTERS
| #define EXAMPLE_MAX_SIMULTANEOUS_COUNTERS 3 |
This driver supports three counters counting at once
Definition at line 28 of file example.c.
◆ EXAMPLE_TOTAL_EVENTS
| #define EXAMPLE_TOTAL_EVENTS 4 |
◆ EXAMPLE_ZERO_REG
| #define EXAMPLE_ZERO_REG 0 |
◆ _example_ctl()
This function sets various options in the component
- Parameters
-
| [in] | ctx | – hardware context |
| [in] | code | valid are PAPI_SET_DEFDOM, PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL and PAPI_SET_INHERIT |
| [in] | option | – options to be set |
Definition at line 461 of file example.c.
468 SUBDBG(
"example_ctl..." );
#define SUBDBG(format, args...)
◆ _example_init_component()
| static int _example_init_component |
( |
int |
cidx | ) |
|
|
static |
Initialize hardware counters, setup the function vector table and get hardware information, this routine is called when the PAPI process is initialized (IE PAPI_library_init)
Definition at line 187 of file example.c.
190 SUBDBG(
"_example_init_component..." );
207 PAPIERROR(
"malloc():Could not get memory for events table" );
217 "This is an example counter, that always returns 0" );
222 "This is an example counter, that always returns a constant value of 42" );
227 "This is an example counter, that reports a per-thread auto-incrementing value" );
232 "This is an example counter, that reports a global auto-incrementing value" );
static int detect_example(void)
PAPI_component_info_t cmp_info
papi_vector_t _example_vector
#define EXAMPLE_TOTAL_EVENTS
#define SUBDBG(format, args...)
void PAPIERROR(char *format,...)
static example_native_event_entry_t * example_native_table
#define papi_calloc(a, b)
◆ _example_init_control_state()
Setup a counter control state. In general a control state holds the hardware info for an EventSet.
Definition at line 268 of file example.c.
270 SUBDBG(
"example_init_control_state... %p\n", ctl );
#define SUBDBG(format, args...)
◆ _example_init_thread()
This is called whenever a thread is initialized
Definition at line 248 of file example.c.
255 SUBDBG(
"_example_init_thread %p...", ctx );
#define SUBDBG(format, args...)
◆ _example_ntv_code_to_descr()
| static int _example_ntv_code_to_descr |
( |
unsigned int |
EventCode, |
|
|
char * |
descr, |
|
|
int |
len |
|
) |
| |
|
static |
Takes a native event code and passes back the event description
- Parameters
-
| EventCode | is the native event code |
| descr | is a pointer for the description to be copied to |
| len | is the size of the descr string |
Definition at line 588 of file example.c.
static example_native_event_entry_t * example_native_table
◆ _example_ntv_code_to_name()
| static int _example_ntv_code_to_name |
( |
unsigned int |
EventCode, |
|
|
char * |
name, |
|
|
int |
len |
|
) |
| |
|
static |
Takes a native event code and passes back the name
- Parameters
-
| EventCode | is the native event code |
| name | is a pointer for the name to be copied to |
| len | is the size of the name string |
Definition at line 567 of file example.c.
static example_native_event_entry_t * example_native_table
◆ _example_ntv_enum_events()
| static int _example_ntv_enum_events |
( |
unsigned int * |
EventCode, |
|
|
int |
modifier |
|
) |
| |
|
static |
Enumerate Native Events
- Parameters
-
| EventCode | is the event of interest |
| modifier | is one of PAPI_ENUM_FIRST, PAPI_ENUM_EVENTS If your component has attribute masks then these need to be handled here as well. |
Definition at line 525 of file example.c.
530 switch ( modifier ) {
547 *EventCode = *EventCode + 1;
◆ _example_read()
Triggered by PAPI_read()
Definition at line 356 of file example.c.
365 SUBDBG(
"example_read... %p %d", ctx, flags );
int which_counter[EXAMPLE_MAX_SIMULTANEOUS_COUNTERS]
static long long example_hardware_read(int which_one, example_context_t *ctx)
char events[MAX_EVENTS][BUFSIZ]
long long counter[EXAMPLE_MAX_MULTIPLEX_COUNTERS]
#define SUBDBG(format, args...)
◆ _example_reset()
Triggered by PAPI_reset() but only if the EventSet is currently running
Definition at line 411 of file example.c.
416 SUBDBG(
"example_reset ctx=%p ctrl=%p...", ctx, ctl );
#define SUBDBG(format, args...)
static void example_hardware_reset(example_context_t *ctx)
◆ _example_set_domain()
This function has to set the bits needed to count different domains In particular: PAPI_DOM_USER, PAPI_DOM_KERNEL PAPI_DOM_OTHER By default return PAPI_EINVAL if none of those are specified and PAPI_OK with success PAPI_DOM_USER is only user context is counted PAPI_DOM_KERNEL is only the Kernel/OS context is counted PAPI_DOM_OTHER is Exception/transient mode (like user TLB misses) PAPI_DOM_ALL is all of the domains
Definition at line 483 of file example.c.
488 SUBDBG(
"example_set_domain..." );
491 SUBDBG(
" PAPI_DOM_USER " );
495 SUBDBG(
" PAPI_DOM_KERNEL " );
499 SUBDBG(
" PAPI_DOM_OTHER " );
503 SUBDBG(
" PAPI_DOM_ALL " );
#define SUBDBG(format, args...)
◆ _example_shutdown_component()
| static int _example_shutdown_component |
( |
void |
| ) |
|
|
static |
Triggered by PAPI_shutdown()
Definition at line 426 of file example.c.
429 SUBDBG(
"example_shutdown_component..." );
#define SUBDBG(format, args...)
static example_native_event_entry_t * example_native_table
◆ _example_shutdown_thread()
Called at thread shutdown
Definition at line 440 of file example.c.
445 SUBDBG(
"example_shutdown_thread... %p", ctx );
#define SUBDBG(format, args...)
◆ _example_start()
◆ _example_stop()
Triggered by PAPI_stop()
Definition at line 337 of file example.c.
343 SUBDBG(
"example_stop %p %p...", ctx, ctl );
#define SUBDBG(format, args...)
◆ _example_update_control_state()
Triggered by eventset operations like add or remove
Definition at line 281 of file example.c.
292 SUBDBG(
"_example_update_control_state %p %p...", ctl, ctx );
int which_counter[EXAMPLE_MAX_SIMULTANEOUS_COUNTERS]
#define SUBDBG(format, args...)
◆ _example_write()
Triggered by PAPI_write(), but only if the counters are running
Definition at line 385 of file example.c.
394 SUBDBG(
"example_write... %p %p", ctx, ctl );
int which_counter[EXAMPLE_MAX_SIMULTANEOUS_COUNTERS]
static int example_hardware_write(int which_one, example_context_t *ctx, long long value)
char events[MAX_EVENTS][BUFSIZ]
#define SUBDBG(format, args...)
◆ detect_example()
| static int detect_example |
( |
void |
| ) |
|
|
static |
◆ example_hardware_read()
Code that reads event values.
Definition at line 121 of file example.c.
125 switch ( which_one ) {
139 fprintf(stderr,
"Invalid counter read %#x\n",which_one );
static long long example_global_autoinc_value
#define EXAMPLE_GLOBAL_AUTOINC_REG
#define EXAMPLE_AUTOINC_REG
#define EXAMPLE_CONSTANT_REG
◆ example_hardware_reset()
Code that resets the hardware.
Definition at line 108 of file example.c.
static long long example_global_autoinc_value
◆ example_hardware_write()
| static int example_hardware_write |
( |
int |
which_one, |
|
|
example_context_t * |
ctx, |
|
|
long long |
value |
|
) |
| |
|
static |
Code that writes event values.
Definition at line 148 of file example.c.
153 switch ( which_one ) {
164 perror(
"Invalid counter write" );
static long long example_global_autoinc_value
#define EXAMPLE_GLOBAL_AUTOINC_REG
#define EXAMPLE_AUTOINC_REG
#define EXAMPLE_CONSTANT_REG
◆ _example_vector
Vector that points to entry points for our component
Definition at line 33 of file example.c.
◆ example_global_autoinc_value
| long long example_global_autoinc_value = 0 |
|
static |
◆ example_native_table
This table contains the native events
Definition at line 87 of file example.c.
◆ num_events
number of events in the table
Definition at line 90 of file example.c.