|
Packit |
577717 |
// Define the papi_avail man page contents.
|
|
Packit |
577717 |
/**
|
|
Packit |
577717 |
* file papi_avail.c
|
|
Packit |
577717 |
* @brief papi_avail utility.
|
|
Packit |
577717 |
* @page papi_avail
|
|
Packit |
577717 |
* @section Name
|
|
Packit |
577717 |
* papi_avail - provides availability and detailed information for PAPI preset and user defined events.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @section Synopsis
|
|
Packit |
577717 |
* papi_avail [-adht] [-e event]
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @section Description
|
|
Packit |
577717 |
* papi_avail is a PAPI utility program that reports information about the
|
|
Packit |
577717 |
* current PAPI installation and supported preset and user defined events.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @section Options
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* -h Display help information about this utility.
|
|
Packit |
577717 |
* -a Display only the available PAPI events.
|
|
Packit |
577717 |
* -c Display only the available PAPI events after a check.
|
|
Packit |
577717 |
* -d Display PAPI event information in a more detailed format.
|
|
Packit |
577717 |
* -e < event > Display detailed event information for the named event.
|
|
Packit |
577717 |
* This event can be a preset event, a user defined event, or a native event.
|
|
Packit |
577717 |
* If the event is a preset or a user defined event the output shows a list of native
|
|
Packit |
577717 |
* events the event is based on and the formula that is used to compute the events final value.\n
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Event filtering options
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* --br Display branch related PAPI preset events
|
|
Packit |
577717 |
* --cache Display cache related PAPI preset events
|
|
Packit |
577717 |
* --cnd Display conditional PAPI preset events
|
|
Packit |
577717 |
* --fp Display Floating Point related PAPI preset events
|
|
Packit |
577717 |
* --ins Display instruction related PAPI preset events
|
|
Packit |
577717 |
* --idl Display Stalled or Idle PAPI preset events
|
|
Packit |
577717 |
* --l1 Display level 1 cache related PAPI preset events
|
|
Packit |
577717 |
* --l2 Display level 2 cache related PAPI preset events
|
|
Packit |
577717 |
* --l3 Display level 3 cache related PAPI preset events
|
|
Packit |
577717 |
* --mem Display memory related PAPI preset events
|
|
Packit |
577717 |
* --msc Display miscellaneous PAPI preset events
|
|
Packit |
577717 |
* --tlb Display Translation Lookaside Buffer PAPI preset events
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @section Bugs
|
|
Packit |
577717 |
* There are no known bugs in this utility.
|
|
Packit |
577717 |
* If you find a bug, it should be reported to the PAPI Mailing List at <ptools-perfapi@icl.utk.edu>.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @see PAPI_derived_event_files
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
// Define the PAPI_derived_event_files man page contents.
|
|
Packit |
577717 |
/**
|
|
Packit |
577717 |
* @page PAPI_derived_event_files
|
|
Packit |
577717 |
* @brief Describes derived event definition file syntax.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @section main Derived Events
|
|
Packit |
577717 |
* PAPI provides the ability to define events whose value will be derived from multiple native events. The list of native
|
|
Packit |
577717 |
* events to be used in a derived event and a formula which describes how to use them is provided in an event definition file.
|
|
Packit |
577717 |
* The PAPI team provides an event definition file which describes all of the supported PAPI preset events. PAPI also allows
|
|
Packit |
577717 |
* a user to provide an event definition file that describes a set of user defined events which can extend the events PAPI
|
|
Packit |
577717 |
* normally supports.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* This page documents the syntax of the commands which can appear in an event definition file.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @subsection rules General Rules:
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Blank lines are ignored.
|
|
Packit |
577717 |
* Lines that begin with '#' are comments (they are also ignored).
|
|
Packit |
577717 |
* Names shown inside < > below represent values that must be provided by the user.
|
|
Packit |
577717 |
* If a user provided value contains white space, it must be protected with quotes.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @subsection commands Commands:
|
|
Packit |
577717 |
* @par CPU,\<pmuName\>
|
|
Packit |
577717 |
* Specifies a PMU name which controls if the PRESET and EVENT commands that follow this line should
|
|
Packit |
577717 |
* be processed. Multiple CPU commands can be entered without PRESET or EVENT commands between them to provide
|
|
Packit |
577717 |
* a list of PMU names to which the derived events that follow will apply. When a PMU name provided in the list
|
|
Packit |
577717 |
* matches a PMU name known to the running system, the events which follow will be created. If none of the PMU
|
|
Packit |
577717 |
* names provided in the list match a PMU name on the running system, the events which follow will be ignored.
|
|
Packit |
577717 |
* When a new CPU command follows either a PRESET or EVENT command, the PMU list is rebuilt.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @par PRESET,\<eventName\>,\<derivedType\>,\<eventAttr\>,LDESC,\"\<longDesc\>\",SDESC,\"\<shortDesc\>\",NOTE,\"\<note\>\"
|
|
Packit |
577717 |
* Declare a PAPI preset derived event.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @par EVENT,\<eventName\>,\<derivedType\>,\<eventAttr\>,LDESC,\"\<longDesc\>\",SDESC,\"\<shortDesc\>\",NOTE,\"\<note\>\"
|
|
Packit |
577717 |
* Declare a user defined derived event.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @par Where:
|
|
Packit |
577717 |
* @par pmuName:
|
|
Packit |
577717 |
* The PMU which the following events should apply to. A list of PMU names supported by your
|
|
Packit |
577717 |
* system can be obtained by running papi_component_avail on your system.
|
|
Packit |
577717 |
* @par eventName:
|
|
Packit |
577717 |
* Specifies the name used to identify this derived event. This name should be unique within the events on your system.
|
|
Packit |
577717 |
* @par derivedType:
|
|
Packit |
577717 |
* Specifies the kind of derived event being defined (see 'Derived Types' below).
|
|
Packit |
577717 |
* @par eventAttr:
|
|
Packit |
577717 |
* Specifies a formula and a list of base events that are used to compute the derived events value. The syntax
|
|
Packit |
577717 |
* of this field depends on the 'derivedType' specified above (see 'Derived Types' below).
|
|
Packit |
577717 |
* @par longDesc:
|
|
Packit |
577717 |
* Provides the long description of the event.
|
|
Packit |
577717 |
* @par shortDesc:
|
|
Packit |
577717 |
* Provides the short description of the event.
|
|
Packit |
577717 |
* @par note:
|
|
Packit |
577717 |
* Provides an event note.
|
|
Packit |
577717 |
* @par baseEvent (used below):
|
|
Packit |
577717 |
* Identifies an event on which this derived event is based. This may be a native event (possibly with event masks),
|
|
Packit |
577717 |
* an already known preset event, or an already known user event.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @subsection notes Notes:
|
|
Packit |
577717 |
* The PRESET command has traditionally been used in the PAPI provided preset definition file.
|
|
Packit |
577717 |
* The EVENT command is intended to be used in user defined event definition files. The code treats them
|
|
Packit |
577717 |
* the same so they are interchangeable and they can both be used in either event definition file.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @subsection types Derived Types:
|
|
Packit |
577717 |
* This describes values allowed in the 'derivedType' field of the PRESET and EVENT commands. It also
|
|
Packit |
577717 |
* shows the syntax of the 'eventAttr' field for each derived type supported by these commands.
|
|
Packit |
577717 |
* All of the derived events provide a list of one or more events which the derived event is based
|
|
Packit |
577717 |
* on (baseEvent). Some derived events provide a formula that specifies how to compute the derived
|
|
Packit |
577717 |
* events value using the baseEvents in the list. The following derived types are supported, the syntax
|
|
Packit |
577717 |
* of the 'eventAttr' parameter for each derived event type is shown in parentheses.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @par NOT_DERIVED (\<baseEvent\>):
|
|
Packit |
577717 |
* This derived type defines an alias for the existing event 'baseEvent'.
|
|
Packit |
577717 |
* @par DERIVED_ADD (\<baseEvent1\>,\<baseEvent2\>):
|
|
Packit |
577717 |
* This derived type defines a new event that will be the sum of two other
|
|
Packit |
577717 |
* events. It has a value of 'baseEvent1' plus 'baseEvent2'.
|
|
Packit |
577717 |
* @par DERIVED_PS (PAPI_TOT_CYC,\<baseEvent1\>):
|
|
Packit |
577717 |
* This derived type defines a new event that will report the number of 'baseEvent1' events which occurred
|
|
Packit |
577717 |
* per second. It has a value of ((('baseEvent1' * cpu_max_mhz) * 1000000 ) / PAPI_TOT_CYC). The user must
|
|
Packit |
577717 |
* provide PAPI_TOT_CYC as the first event of two events in the event list for this to work correctly.
|
|
Packit |
577717 |
* @par DERIVED_ADD_PS (PAPI_TOT_CYC,\<baseEvent1\>,\<baseEvent2\>):
|
|
Packit |
577717 |
* This derived type defines a new event that will add together two event counters and then report the number
|
|
Packit |
577717 |
* which occurred per second. It has a value of (((('baseEvent1' + baseEvent2) * cpu_max_mhz) * 1000000 ) / PAPI_TOT_CYC).
|
|
Packit |
577717 |
* The user must provide PAPI_TOT_CYC as the first event of three events in the event list for this to work correctly.
|
|
Packit |
577717 |
* @par DERIVED_CMPD (\<baseEvent1\>,\
|
|
Packit |
577717 |
* This derived type works much like the NOT_DERIVED type. It is rarely used and it looks like the code just returns
|
|
Packit |
577717 |
* a single value returned from the kernel. There is no calculation done to compute this events value. Not sure why
|
|
Packit |
577717 |
* multiple input events seem to be needed to use this event type.
|
|
Packit |
577717 |
* @par DERIVED_SUB (\<baseEvent1\>,\<baseEvent2\>):
|
|
Packit |
577717 |
* This derived type defines a new event that will be the difference between two other
|
|
Packit |
577717 |
* events. It has a value of 'baseEvent1' minus 'baseEvent2'.
|
|
Packit |
577717 |
* @par DERIVED_POSTFIX (\<pfFormula\>,\<baseEvent1\>,\<baseEvent2\>, ... ,\<baseEventn\>):
|
|
Packit |
577717 |
* This derived type defines a new event whose value is computed from several native events using
|
|
Packit |
577717 |
* a postfix (reverse polish notation) formula. Its value is the result of processing the postfix
|
|
Packit |
577717 |
* formula. The 'pfFormula' is of the form 'N0|N1|N2|5|*|+|-|' where the '|' acts as a token
|
|
Packit |
577717 |
* separator and the tokens N0, N1, and N2 are place holders that represent baseEvent0, baseEvent1,
|
|
Packit |
577717 |
* and baseEvent2 respectively.
|
|
Packit |
577717 |
* @par DERIVED_INFIX (\<ifFormula\>,\<baseEvent1\>,\<baseEvent2\>, ... ,\<baseEventn\>):
|
|
Packit |
577717 |
* This derived type defines a new event whose value is computed from several native events using
|
|
Packit |
577717 |
* an infix (algebraic notation) formula. Its value is the result of processing the infix
|
|
Packit |
577717 |
* formula. The 'ifFormula' is of the form 'N0-(N1+(N2*5))' where the tokens N0, N1, and N2
|
|
Packit |
577717 |
* are place holders that represent baseEvent0, baseEvent1, and baseEvent2 respectively.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* @subsection example Example:
|
|
Packit |
577717 |
* In the following example, the events PAPI_SP_OPS, USER_SP_OPS, and ALIAS_SP_OPS will all measure the same events and return
|
|
Packit |
577717 |
* the same value. They just demonstrate different ways to use the PRESET and EVENT event definition commands.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* # The following lines define pmu names that all share the following events
|
|
Packit |
577717 |
* CPU nhm
|
|
Packit |
577717 |
* CPU nhm-ex
|
|
Packit |
577717 |
* \# Events which should be defined for either of the above pmu types
|
|
Packit |
577717 |
* PRESET,PAPI_TOT_CYC,NOT_DERIVED,UNHALTED_CORE_CYCLES
|
|
Packit |
577717 |
* PRESET,PAPI_REF_CYC,NOT_DERIVED,UNHALTED_REFERENCE_CYCLES
|
|
Packit |
577717 |
* PRESET,PAPI_SP_OPS,DERIVED_POSTFIX,N0|N1|3|*|+|,FP_COMP_OPS_EXE:SSE_SINGLE_PRECISION,FP_COMP_OPS_EXE:SSE_FP_PACKED,NOTE,"Using a postfix formula"
|
|
Packit |
577717 |
* EVENT,USER_SP_OPS,DERIVED_INFIX,N0+(N1*3),FP_COMP_OPS_EXE:SSE_SINGLE_PRECISION,FP_COMP_OPS_EXE:SSE_FP_PACKED,NOTE,"Using the same formula in infix format"
|
|
Packit |
577717 |
* EVENT,ALIAS_SP_OPS,NOT_DERIVED,PAPI_SP_OPS,LDESC,"Alias for preset event PAPI_SP_OPS"
|
|
Packit |
577717 |
* # End of event definitions for above pmu names and start of a section for a new pmu name.
|
|
Packit |
577717 |
* CPU snb
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
#include <string.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include "papi.h"
|
|
Packit |
577717 |
#include "print_header.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static char *
|
|
Packit |
577717 |
is_derived( PAPI_event_info_t * info )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
if ( strlen( info->derived ) == 0 )
|
|
Packit |
577717 |
return ( "No" );
|
|
Packit |
577717 |
else if ( strcmp( info->derived, "NOT_DERIVED" ) == 0 )
|
|
Packit |
577717 |
return ( "No" );
|
|
Packit |
577717 |
else if ( strcmp( info->derived, "DERIVED_CMPD" ) == 0 )
|
|
Packit |
577717 |
return ( "No" );
|
|
Packit |
577717 |
else
|
|
Packit |
577717 |
return ( "Yes" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static void
|
|
Packit |
577717 |
print_help( char **argv )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
printf( "This is the PAPI avail program.\n" );
|
|
Packit |
577717 |
printf( "It provides availability and details about PAPI Presets and User-defined Events.\n" );
|
|
Packit |
577717 |
printf( "PAPI Preset Event filters can be combined in a logical OR.\n" );
|
|
Packit |
577717 |
printf( "Usage: %s [options]\n", argv[0] );
|
|
Packit |
577717 |
printf( "Options:\n\n" );
|
|
Packit |
577717 |
printf( "General command options:\n" );
|
|
Packit |
577717 |
printf( "\t-h, --help Print this help message\n" );
|
|
Packit |
577717 |
printf( "\t-a, --avail Display only available PAPI preset and user defined events\n" );
|
|
Packit |
577717 |
printf( "\t-c, --check Display only available PAPI preset and user defined events after an availability check\n" );
|
|
Packit |
577717 |
printf( "\t-d, --detail Display detailed information about events\n" );
|
|
Packit |
577717 |
printf( "\t-e EVENTNAME Display detail information about specified event\n" );
|
|
Packit |
577717 |
printf( "\nEvent filtering options:\n" );
|
|
Packit |
577717 |
printf( "\t--br Display branch related PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\t--cache Display cache related PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\t--cnd Display conditional PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\t--fp Display Floating Point related PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\t--ins Display instruction related PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\t--idl Display Stalled or Idle PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\t--l1 Display level 1 cache related PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\t--l2 Display level 2 cache related PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\t--l3 Display level 3 cache related PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\t--mem Display memory related PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\t--msc Display miscellaneous PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\t--tlb Display Translation Lookaside Buffer PAPI preset events\n" );
|
|
Packit |
577717 |
printf( "\n" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
parse_unit_masks( PAPI_event_info_t * info )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
char *pmask;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( ( pmask = strchr( info->symbol, ':' ) ) == NULL ) {
|
|
Packit |
577717 |
return ( 0 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
memmove( info->symbol, pmask, ( strlen( pmask ) + 1 ) * sizeof ( char ) );
|
|
Packit |
577717 |
pmask = strchr( info->long_descr, ':' );
|
|
Packit |
577717 |
if ( pmask == NULL )
|
|
Packit |
577717 |
info->long_descr[0] = 0;
|
|
Packit |
577717 |
else
|
|
Packit |
577717 |
memmove( info->long_descr, pmask + sizeof ( char ),
|
|
Packit |
577717 |
( strlen( pmask ) + 1 ) * sizeof ( char ) );
|
|
Packit |
577717 |
return 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
static int
|
|
Packit |
577717 |
checkCounter (int eventcode)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int EventSet = PAPI_NULL;
|
|
Packit |
577717 |
if (PAPI_create_eventset(&EventSet) != PAPI_OK)
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
if (PAPI_add_event (EventSet, eventcode) != PAPI_OK)
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
if (PAPI_cleanup_eventset (EventSet) != PAPI_OK)
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
if (PAPI_destroy_eventset (&EventSet) != PAPI_OK)
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
return 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
main( int argc, char **argv )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int args, i, j, k;
|
|
Packit |
577717 |
int retval;
|
|
Packit |
577717 |
unsigned int filter = 0;
|
|
Packit |
577717 |
int print_event_info = 0;
|
|
Packit |
577717 |
char *name = NULL;
|
|
Packit |
577717 |
int print_avail_only = PAPI_ENUM_EVENTS;
|
|
Packit |
577717 |
int print_tabular = 1;
|
|
Packit |
577717 |
PAPI_event_info_t info;
|
|
Packit |
577717 |
const PAPI_hw_info_t *hwinfo = NULL;
|
|
Packit |
577717 |
int tot_count = 0;
|
|
Packit |
577717 |
int avail_count = 0;
|
|
Packit |
577717 |
int deriv_count = 0;
|
|
Packit |
577717 |
int check_counter = 0;
|
|
Packit |
577717 |
int event_code;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
PAPI_event_info_t n_info;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Parse command line arguments */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for( args = 1; args < argc; args++ ) {
|
|
Packit |
577717 |
if ( strstr( argv[args], "-e" ) ) {
|
|
Packit |
577717 |
print_event_info = 1;
|
|
Packit |
577717 |
name = argv[args + 1];
|
|
Packit |
577717 |
if ( ( name == NULL ) || ( strlen( name ) == 0 ) ) {
|
|
Packit |
577717 |
print_help( argv );
|
|
Packit |
577717 |
exit( 1 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
else if ( strstr( argv[args], "-c" ) || strstr (argv[args], "--check") )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
print_avail_only = PAPI_PRESET_ENUM_AVAIL;
|
|
Packit |
577717 |
check_counter = 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
else if ( strstr( argv[args], "-a" ))
|
|
Packit |
577717 |
print_avail_only = PAPI_PRESET_ENUM_AVAIL;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "-d" ) )
|
|
Packit |
577717 |
print_tabular = 0;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "-h" ) ) {
|
|
Packit |
577717 |
print_help( argv );
|
|
Packit |
577717 |
exit( 1 );
|
|
Packit |
577717 |
} else if ( strstr( argv[args], "--br" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_BR;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "--cache" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_CACH;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "--cnd" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_CND;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "--fp" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_FP;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "--ins" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_INS;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "--idl" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_IDL;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "--l1" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_L1;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "--l2" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_L2;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "--l3" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_L3;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "--mem" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_BR;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "--msc" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_MSC;
|
|
Packit |
577717 |
else if ( strstr( argv[args], "--tlb" ) )
|
|
Packit |
577717 |
filter |= PAPI_PRESET_BIT_TLB;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( filter == 0 ) {
|
|
Packit |
577717 |
filter = ( unsigned int ) ( -1 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Init PAPI */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
retval = PAPI_library_init( PAPI_VER_CURRENT );
|
|
Packit |
577717 |
if ( retval != PAPI_VER_CURRENT ) {
|
|
Packit |
577717 |
fprintf(stderr,"Error! PAPI library mismatch!\n");
|
|
Packit |
577717 |
return 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
retval = PAPI_set_debug( PAPI_VERB_ECONT );
|
|
Packit |
577717 |
if ( retval != PAPI_OK ) {
|
|
Packit |
577717 |
fprintf(stderr,"Error with PAPI_set debug!\n");
|
|
Packit |
577717 |
return 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
retval=papi_print_header("Available PAPI preset and user defined events plus hardware information.\n",
|
|
Packit |
577717 |
&hwinfo );
|
|
Packit |
577717 |
if ( retval != PAPI_OK ) {
|
|
Packit |
577717 |
fprintf(stderr,"Error with PAPI_get_hardware_info!\n");
|
|
Packit |
577717 |
return 1;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Code for info on just one event */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( print_event_info ) {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( PAPI_event_name_to_code( name, &event_code ) == PAPI_OK ) {
|
|
Packit |
577717 |
if ( PAPI_get_event_info( event_code, &info ) == PAPI_OK ) {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( event_code & PAPI_PRESET_MASK ) {
|
|
Packit |
577717 |
printf( "%-30s%s\n%-30s%#-10x\n%-30s%d\n",
|
|
Packit |
577717 |
"Event name:", info.symbol, "Event Code:",
|
|
Packit |
577717 |
info.event_code, "Number of Native Events:",
|
|
Packit |
577717 |
info.count );
|
|
Packit |
577717 |
printf( "%-29s|%s|\n%-29s|%s|\n%-29s|%s|\n",
|
|
Packit |
577717 |
"Short Description:", info.short_descr,
|
|
Packit |
577717 |
"Long Description:", info.long_descr,
|
|
Packit |
577717 |
"Developer's Notes:", info.note );
|
|
Packit |
577717 |
printf( "%-29s|%s|\n%-29s|%s|\n", "Derived Type:",
|
|
Packit |
577717 |
info.derived, "Postfix Processing String:",
|
|
Packit |
577717 |
info.postfix );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for( j = 0; j < ( int ) info.count; j++ ) {
|
|
Packit |
577717 |
printf( " Native Code[%d]: %#x |%s|\n", j,
|
|
Packit |
577717 |
info.code[j], info.name[j] );
|
|
Packit |
577717 |
PAPI_get_event_info( (int) info.code[j], &n_info );
|
|
Packit |
577717 |
printf(" Number of Register Values: %d\n", n_info.count );
|
|
Packit |
577717 |
for( k = 0; k < ( int ) n_info.count; k++ ) {
|
|
Packit |
577717 |
printf( " Register[%2d]: %#08x |%s|\n", k,
|
|
Packit |
577717 |
n_info.code[k], n_info.name[k] );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
printf( " Native Event Description: |%s|\n\n",
|
|
Packit |
577717 |
n_info.long_descr );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else { /* must be a native event code */
|
|
Packit |
577717 |
printf( "%-30s%s\n%-30s%#-10x\n%-30s%d\n",
|
|
Packit |
577717 |
"Event name:", info.symbol, "Event Code:",
|
|
Packit |
577717 |
info.event_code, "Number of Register Values:",
|
|
Packit |
577717 |
info.count );
|
|
Packit |
577717 |
printf( "%-29s|%s|\n", "Description:", info.long_descr );
|
|
Packit |
577717 |
for ( k = 0; k < ( int ) info.count; k++ ) {
|
|
Packit |
577717 |
printf( " Register[%2d]: %#08x |%s|\n", k,
|
|
Packit |
577717 |
info.code[k], info.name[k] );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* if unit masks exist but none are specified, process all */
|
|
Packit |
577717 |
if ( !strchr( name, ':' ) ) {
|
|
Packit |
577717 |
if ( 1 ) {
|
|
Packit |
577717 |
if ( PAPI_enum_event( &event_code, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK ) {
|
|
Packit |
577717 |
printf( "\nUnit Masks:\n" );
|
|
Packit |
577717 |
do {
|
|
Packit |
577717 |
retval = PAPI_get_event_info(event_code, &info );
|
|
Packit |
577717 |
if ( retval == PAPI_OK ) {
|
|
Packit |
577717 |
if ( parse_unit_masks( &info ) ) {
|
|
Packit |
577717 |
printf( "%-29s|%s|%s|\n",
|
|
Packit |
577717 |
" Mask Info:", info.symbol,
|
|
Packit |
577717 |
info.long_descr );
|
|
Packit |
577717 |
for ( k = 0; k < ( int ) info.count;k++ ) {
|
|
Packit |
577717 |
printf( " Register[%2d]: %#08x |%s|\n",
|
|
Packit |
577717 |
k, info.code[k], info.name[k] );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} while ( PAPI_enum_event( &event_code,
|
|
Packit |
577717 |
PAPI_NTV_ENUM_UMASKS ) == PAPI_OK );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
printf( "Sorry, an event by the name '%s' could not be found.\n"
|
|
Packit |
577717 |
" Is it typed correctly?\n\n", name );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Print *ALL* Events */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
for (i=0 ; i<2 ; i++) {
|
|
Packit |
577717 |
// set the event code to fetch preset events the first time through loop and user events the second time through the loop
|
|
Packit |
577717 |
if (i== 0) {
|
|
Packit |
577717 |
event_code = 0 | PAPI_PRESET_MASK;
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
event_code = 0 | PAPI_UE_MASK;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* For consistency, always ASK FOR the first event, if there is not one then nothing to process */
|
|
Packit |
577717 |
if (PAPI_enum_event( &event_code, PAPI_ENUM_FIRST ) != PAPI_OK) {
|
|
Packit |
577717 |
continue;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
// print heading to show which kind of events follow
|
|
Packit |
577717 |
if (i== 0) {
|
|
Packit |
577717 |
printf( "================================================================================\n" );
|
|
Packit |
577717 |
printf( " PAPI Preset Events\n" );
|
|
Packit |
577717 |
printf( "================================================================================\n" );
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
printf( "\n"); // put a blank line after the presets before strarting the user events
|
|
Packit |
577717 |
printf( "================================================================================\n" );
|
|
Packit |
577717 |
printf( " User Defined Events\n" );
|
|
Packit |
577717 |
printf( "================================================================================\n" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( print_tabular ) {
|
|
Packit |
577717 |
printf( " Name Code " );
|
|
Packit |
577717 |
if ( !print_avail_only ) {
|
|
Packit |
577717 |
printf( "Avail " );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
printf( "Deriv Description (Note)\n" );
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
printf( "%-13s%-11s%-8s%-16s\n |Long Description|\n"
|
|
Packit |
577717 |
" |Developer's Notes|\n |Derived|\n |PostFix|\n"
|
|
Packit |
577717 |
" Native Code[n]: <hex> |name|\n",
|
|
Packit |
577717 |
"Symbol", "Event Code", "Count", "|Short Description|" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
do {
|
|
Packit |
577717 |
if ( PAPI_get_event_info( event_code, &info ) == PAPI_OK ) {
|
|
Packit |
577717 |
if ( print_tabular ) {
|
|
Packit |
577717 |
// if this is a user defined event or its a preset and matches the preset event filters, display its information
|
|
Packit |
577717 |
if ( (i==1) || (filter & info.event_type)) {
|
|
Packit |
577717 |
if ( print_avail_only ) {
|
|
Packit |
577717 |
if ( info.count ) {
|
|
Packit |
577717 |
if ( (check_counter && checkCounter (event_code)) || !check_counter)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
printf( "%-13s%#x %-5s%s",
|
|
Packit |
577717 |
info.symbol,
|
|
Packit |
577717 |
info.event_code,
|
|
Packit |
577717 |
is_derived( &info ), info.long_descr );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if ( info.note[0] ) {
|
|
Packit |
577717 |
printf( " (%s)", info.note );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
printf( "\n" );
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
printf( "%-13s%#x %-6s%-4s %s",
|
|
Packit |
577717 |
info.symbol,
|
|
Packit |
577717 |
info.event_code,
|
|
Packit |
577717 |
( info.count ? "Yes" : "No" ),
|
|
Packit |
577717 |
is_derived( &info ), info.long_descr );
|
|
Packit |
577717 |
if ( info.note[0] ) {
|
|
Packit |
577717 |
printf( " (%s)", info.note );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
printf( "\n" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
tot_count++;
|
|
Packit |
577717 |
if ( info.count ) {
|
|
Packit |
577717 |
if ((check_counter && checkCounter (event_code)) || !check_counter )
|
|
Packit |
577717 |
avail_count++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if ( !strcmp( is_derived( &info ), "Yes" ) ) {
|
|
Packit |
577717 |
deriv_count++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
if ( ( print_avail_only && info.count ) ||
|
|
Packit |
577717 |
( print_avail_only == 0 ) )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
if ((check_counter && checkCounter (event_code)) || !check_counter)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
printf( "%s\t%#x\t%d\t|%s|\n |%s|\n"
|
|
Packit |
577717 |
" |%s|\n |%s|\n |%s|\n",
|
|
Packit |
577717 |
info.symbol, info.event_code, info.count,
|
|
Packit |
577717 |
info.short_descr, info.long_descr, info.note,
|
|
Packit |
577717 |
info.derived, info.postfix );
|
|
Packit |
577717 |
for ( j = 0; j < ( int ) info.count; j++ ) {
|
|
Packit |
577717 |
printf( " Native Code[%d]: %#x |%s|\n", j,
|
|
Packit |
577717 |
info.code[j], info.name[j] );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
tot_count++;
|
|
Packit |
577717 |
if ( info.count ) {
|
|
Packit |
577717 |
if ((check_counter && checkCounter (event_code)) || !check_counter )
|
|
Packit |
577717 |
avail_count++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if ( !strcmp( is_derived( &info ), "Yes" ) ) {
|
|
Packit |
577717 |
deriv_count++;
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
} while (PAPI_enum_event( &event_code, print_avail_only ) == PAPI_OK);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
printf( "--------------------------------------------------------------------------------\n" );
|
|
Packit |
577717 |
if ( !print_event_info ) {
|
|
Packit |
577717 |
if ( print_avail_only ) {
|
|
Packit |
577717 |
printf( "Of %d available events, %d ", avail_count, deriv_count );
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
printf( "Of %d possible events, %d are available, of which %d ",
|
|
Packit |
577717 |
tot_count, avail_count, deriv_count );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
if ( deriv_count == 1 ) {
|
|
Packit |
577717 |
printf( "is derived.\n\n" );
|
|
Packit |
577717 |
} else {
|
|
Packit |
577717 |
printf( "are derived.\n\n" );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
}
|