54 #define EVT_LINE_BUF_SIZE 4096 56 typedef struct command_flags
63 char *
name, *istr, *xstr;
76 printf(
"This is the PAPI native avail program.\n" );
77 printf(
"It provides availability and details about PAPI Native Events.\n" );
78 printf(
"Usage: %s [options]\n", argv[0] );
79 printf(
"Options:\n\n" );
80 printf(
"\nGeneral command options:\n" );
81 printf(
"\t-h, --help print this help message\n" );
82 printf(
"\t-c, --check attempts to add each event\n");
83 printf(
"\t-e EVENTNAME display detailed information about named native event\n" );
84 printf(
"\t-i EVENTSTR include only event names that contain EVENTSTR\n" );
85 printf(
"\t-x EVENTSTR exclude any event names that contain EVENTSTR\n" );
86 printf(
"\t--noqual suppress display of event qualifiers (mask and flag) information\n" );
87 printf(
"\nProcessor-specific options:\n");
88 printf(
"\t--darr display events supporting Data Address Range Restriction\n" );
89 printf(
"\t--dear display Data Event Address Register events only\n" );
90 printf(
"\t--iarr display events supporting Instruction Address Range Restriction\n" );
91 printf(
"\t--iear display Instruction Event Address Register events only\n" );
92 printf(
"\t--opcm display events supporting OpCode Matching\n" );
93 printf(
"\t--nogroups suppress display of Event grouping information\n" );
100 return ( ( arg == NULL ) || ( strlen( arg ) == 0 ) || ( arg[0] ==
'-' ) );
113 for (
i = 1;
i < argc;
i++ ) {
114 if ( !strcmp( argv[
i],
"--darr" ) )
116 else if ( !strcmp( argv[
i],
"--dear" ) )
118 else if ( !strcmp( argv[
i],
"--iarr" ) )
120 else if ( !strcmp( argv[
i],
"--iear" ) )
122 else if ( !strcmp( argv[
i],
"--opcm" ) )
124 else if ( !strcmp( argv[
i],
"--noqual" ) )
126 else if ( !strcmp( argv[
i],
"--nogroups" ) )
128 else if ( !strcmp( argv[
i],
"-e" ) ) {
133 printf(
"Invalid argument for -e\n");
136 }
else if ( !strcmp( argv[
i],
"-i" ) ) {
141 printf(
"Invalid argument for -i\n");
144 }
else if ( !strcmp( argv[
i],
"-x" ) ) {
149 printf(
"Invalid argument for -x\n");
152 }
else if ( strstr( argv[
i],
"-h" ) ) {
154 }
else if ( !strcmp( argv[
i],
"-c" ) || !strcmp( argv[
i],
"--check" ) ) {
157 printf(
"%s is not supported\n", argv[
i] );
172 while ( spaces-- > 0 )
196 printf(
"********** Call to destroy eventset failed when trying to check event '%s' **********\n", info->
symbol);
206 unsigned int i, j = 0;
208 char event_line_units[100];
213 sprintf(event_line_buffer,
"| %-73s|\n", info->
symbol);
217 sprintf(event_line_buffer,
"| %-73s%4s|\n", info->
symbol,
"<-->");
228 printf (
"Event or mask description has been truncated.\n");
235 strcat(event_line_buffer,
"| " );
238 strcat( event_line_buffer, &info->
long_descr[j]);
240 strcat( event_line_buffer,
"|\n" );
245 int k = strlen(event_line_buffer);
246 strncat( event_line_buffer, &info->
long_descr[j],
i );
247 event_line_buffer[k+
i] =
'\0';
248 strcat( event_line_buffer,
"|\n" );
255 event_line_units[0] =
'\0';
256 if (info->
units[0] != 0) {
257 sprintf(event_line_units,
"| Units: %-66s|\n", info->
units );
261 int out_buf_used = 0;
279 fprintf(stderr,
"Error! Allocation of output buffer memory failed.\n");
296 if (val_flag_ptr != NULL) {
299 *(val_flag_ptr+1) =
'N';
300 *(val_flag_ptr+2) =
'A';
305 *(val_flag_ptr+1) =
' ';
306 *(val_flag_ptr+2) =
' ';
307 *(val_flag_ptr+3) =
' ';
325 if ((ptr=strstr(info->
symbol,
":::"))) {
328 }
else if ((ptr=strstr(info->
symbol,
"::"))) {
335 if ( ( pmask = strchr( ptr,
':' ) ) == NULL ) {
338 memmove( info->
symbol, pmask, ( strlen(pmask) + 1 ) *
sizeof(
char) );
345 if ( pmask == NULL ) {
349 memmove( info->
long_descr, pmask, (strlen(pmask) + 1) *
sizeof(
char) );
359 int num_cmp_events = 0;
370 fprintf(stderr,
"Error! PAPI_library_init\n");
380 else if ( flags.
darr )
382 else if ( flags.
iear )
384 else if ( flags.
iarr )
386 else if ( flags.
opcm )
393 fprintf(stderr,
"Error! PAPI_set_debug\n");
399 fprintf(stderr,
"Error! PAPI_get_hardware_info\n");
407 printf(
"Event name: %s\n", info.
symbol);
408 printf(
"Description: %s\n", info.
long_descr );
412 if ((ptr=strstr(flags.
name,
":::"))) {
415 }
else if ((ptr=strstr(flags.
name,
"::"))) {
423 if ( !strchr( ptr,
':' ) ) {
425 printf(
"\nQualifiers: Name -- Description\n" );
438 printf(
"Sorry, an event by the name '%s' could not be found.\n",
440 printf(
"Is it typed correctly?\n\n");
452 for ( cid = 0; cid < numcmp; cid++ ) {
459 printf(
"===============================================================================\n" );
460 printf(
" Native Events in Component: %s\n",component->
name);
461 printf(
"===============================================================================\n" );
474 memset( &info, 0,
sizeof ( info ) );
487 if (num_cmp_events) {
488 printf(
"--------------------------------------------------------------------------------\n" );
511 printf(
"Groups: " );
537 if (strlen(first_event_mask_string) == 0) {
538 strcpy (first_event_mask_string, info.
symbol);
556 strcpy (info.
symbol, first_event_mask_string);
557 strcat (info.
symbol,
":cpu=1");
563 strcpy (info.
symbol, first_event_mask_string);
564 char *wptr = strrchr (info.
symbol,
':');
567 strcat (info.
symbol,
":ff=64:cpu=1");
578 if (num_cmp_events != 0) {
579 printf(
"--------------------------------------------------------------------------------\n" );
581 printf(
"\nTotal events reported: %d\n",
num_events );
584 printf(
"\nNo events detected! Check papi_component_avail to find out why.\n");
static void check_event(PAPI_event_info_t *info)
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
static void parse_args(int argc, char **argv, command_flags_t *f)
char units[PAPI_MIN_STR_LEN]
int PAPI_num_components(void)
int PAPI_enum_event(int *EventCode, int modifier)
char long_descr[PAPI_HUGE_STR_LEN]
int PAPI_event_name_to_code(const char *in, int *out)
Return codes and api definitions.
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
add PAPI preset or native hardware event by name to an EventSet
static int parse_event_qualifiers(PAPI_event_info_t *info)
int main(int argc, char **argv)
int PAPI_library_init(int version)
Create a new empty PAPI EventSet.
#define PAPI_NTV_GROUP_SHIFT
static int no_str_arg(char *arg)
static void print_help(char **argv)
char symbol[PAPI_HUGE_STR_LEN]
#define PAPI_HUGE_STR_LEN
static void space_pad(char *str, int spaces)
char name[PAPI_MAX_STR_LEN]
unsigned int event_output_buffer_size
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
unsigned int event_available
#define PAPI_NTV_GROUP_AND_MASK
char * event_output_buffer
int PAPI_destroy_eventset(int *EventSet)
int PAPI_remove_named_event(int EventSet, const char *EventName)
#define EVT_LINE_BUF_SIZE
static void print_event_output(int val_flag)
int PAPI_set_debug(int level)
static int format_event_output(PAPI_event_info_t *info, int offset)