PAPI  5.4.1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
avail.c File Reference
Include dependency graph for avail.c:

Go to the source code of this file.

Functions

static char * is_derived (PAPI_event_info_t *info)
 
static void print_help (char **argv)
 
static int parse_unit_masks (PAPI_event_info_t *info)
 
int main (int argc, char **argv)
 

Variables

int TESTS_QUIET
 

Function Documentation

static char* is_derived ( PAPI_event_info_t info)
static

Definition at line 170 of file avail.c.

171 {
172  if ( strlen( info->derived ) == 0 )
173  return ( "No" );
174  else if ( strcmp( info->derived, "NOT_DERIVED" ) == 0 )
175  return ( "No" );
176  else if ( strcmp( info->derived, "DERIVED_CMPD" ) == 0 )
177  return ( "No" );
178  else
179  return ( "Yes" );
180 }
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:992

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 229 of file avail.c.

230 {
231  int args, i, j, k;
232  int retval;
233  unsigned int filter = 0;
234  int print_event_info = 0;
235  char *name = NULL;
236  int print_avail_only = PAPI_ENUM_EVENTS;
237  int print_tabular = 1;
238  PAPI_event_info_t info;
239  const PAPI_hw_info_t *hwinfo = NULL;
240  int tot_count = 0;
241  int avail_count = 0;
242  int deriv_count = 0;
243  int event_code;
244 
245  PAPI_event_info_t n_info;
246 
247  /* Set TESTS_QUIET variable */
248 
249  tests_quiet( argc, argv );
250 
251  /* Parse command line arguments */
252 
253  for( args = 1; args < argc; args++ ) {
254  if ( strstr( argv[args], "-e" ) ) {
255  print_event_info = 1;
256  name = argv[args + 1];
257  if ( ( name == NULL ) || ( strlen( name ) == 0 ) ) {
258  print_help( argv );
259  exit( 1 );
260  }
261  } else if ( strstr( argv[args], "-a" ) )
262  print_avail_only = PAPI_PRESET_ENUM_AVAIL;
263  else if ( strstr( argv[args], "-d" ) )
264  print_tabular = 0;
265  else if ( strstr( argv[args], "-h" ) ) {
266  print_help( argv );
267  exit( 1 );
268  } else if ( strstr( argv[args], "--br" ) )
269  filter |= PAPI_PRESET_BIT_BR;
270  else if ( strstr( argv[args], "--cache" ) )
271  filter |= PAPI_PRESET_BIT_CACH;
272  else if ( strstr( argv[args], "--cnd" ) )
273  filter |= PAPI_PRESET_BIT_CND;
274  else if ( strstr( argv[args], "--fp" ) )
275  filter |= PAPI_PRESET_BIT_FP;
276  else if ( strstr( argv[args], "--ins" ) )
277  filter |= PAPI_PRESET_BIT_INS;
278  else if ( strstr( argv[args], "--idl" ) )
279  filter |= PAPI_PRESET_BIT_IDL;
280  else if ( strstr( argv[args], "--l1" ) )
281  filter |= PAPI_PRESET_BIT_L1;
282  else if ( strstr( argv[args], "--l2" ) )
283  filter |= PAPI_PRESET_BIT_L2;
284  else if ( strstr( argv[args], "--l3" ) )
285  filter |= PAPI_PRESET_BIT_L3;
286  else if ( strstr( argv[args], "--mem" ) )
287  filter |= PAPI_PRESET_BIT_BR;
288  else if ( strstr( argv[args], "--msc" ) )
289  filter |= PAPI_PRESET_BIT_MSC;
290  else if ( strstr( argv[args], "--tlb" ) )
291  filter |= PAPI_PRESET_BIT_TLB;
292  }
293 
294  if ( filter == 0 ) {
295  filter = ( unsigned int ) ( -1 );
296  }
297 
298  /* Init PAPI */
299 
301  if ( retval != PAPI_VER_CURRENT ) {
302  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
303  }
304 
305  if ( !TESTS_QUIET ) {
306  retval = PAPI_set_debug( PAPI_VERB_ECONT );
307  if ( retval != PAPI_OK ) {
308  test_fail( __FILE__, __LINE__, "PAPI_set_debug", retval );
309  }
310 
311  retval=papi_print_header("Available PAPI preset and user defined events plus hardware information.\n",
312  &hwinfo );
313  if ( retval != PAPI_OK ) {
314  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
315  }
316 
317  /* Code for info on just one event */
318 
319  if ( print_event_info ) {
320 
321  if ( PAPI_event_name_to_code( name, &event_code ) == PAPI_OK ) {
322  if ( PAPI_get_event_info( event_code, &info ) == PAPI_OK ) {
323 
324  if ( event_code & PAPI_PRESET_MASK ) {
325  printf( "%-30s%s\n%-30s%#-10x\n%-30s%d\n",
326  "Event name:", info.symbol, "Event Code:",
327  info.event_code, "Number of Native Events:",
328  info.count );
329  printf( "%-29s|%s|\n%-29s|%s|\n%-29s|%s|\n",
330  "Short Description:", info.short_descr,
331  "Long Description:", info.long_descr,
332  "Developer's Notes:", info.note );
333  printf( "%-29s|%s|\n%-29s|%s|\n", "Derived Type:",
334  info.derived, "Postfix Processing String:",
335  info.postfix );
336 
337  for( j = 0; j < ( int ) info.count; j++ ) {
338  printf( " Native Code[%d]: %#x |%s|\n", j,
339  info.code[j], info.name[j] );
340  PAPI_get_event_info( (int) info.code[j], &n_info );
341  printf(" Number of Register Values: %d\n", n_info.count );
342  for( k = 0; k < ( int ) n_info.count; k++ ) {
343  printf( " Register[%2d]: %#08x |%s|\n", k,
344  n_info.code[k], n_info.name[k] );
345  }
346  printf( " Native Event Description: |%s|\n\n",
347  n_info.long_descr );
348  }
349  } else { /* must be a native event code */
350  printf( "%-30s%s\n%-30s%#-10x\n%-30s%d\n",
351  "Event name:", info.symbol, "Event Code:",
352  info.event_code, "Number of Register Values:",
353  info.count );
354  printf( "%-29s|%s|\n", "Description:", info.long_descr );
355  for ( k = 0; k < ( int ) info.count; k++ ) {
356  printf( " Register[%2d]: %#08x |%s|\n", k,
357  info.code[k], info.name[k] );
358  }
359 
360  /* if unit masks exist but none are specified, process all */
361  if ( !strchr( name, ':' ) ) {
362  if ( 1 ) {
363  if ( PAPI_enum_event( &event_code, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK ) {
364  printf( "\nUnit Masks:\n" );
365  do {
366  retval = PAPI_get_event_info(event_code, &info );
367  if ( retval == PAPI_OK ) {
368  if ( parse_unit_masks( &info ) ) {
369  printf( "%-29s|%s|%s|\n",
370  " Mask Info:", info.symbol,
371  info.long_descr );
372  for ( k = 0; k < ( int ) info.count;k++ ) {
373  printf( " Register[%2d]: %#08x |%s|\n",
374  k, info.code[k], info.name[k] );
375  }
376  }
377  }
378  } while ( PAPI_enum_event( &event_code,
380  }
381  }
382  }
383  }
384  }
385  } else {
386  printf( "Sorry, an event by the name '%s' could not be found.\n"
387  " Is it typed correctly?\n\n", name );
388  }
389  } else {
390 
391  /* Print *ALL* Events */
392 
393  for (i=0 ; i<2 ; i++) {
394  // set the event code to fetch preset events the first time through loop and user events the second time through the loop
395  // also print heading to show which kind of events follow
396  if (i== 0) {
397  event_code = 0 | PAPI_PRESET_MASK;
398  printf( "================================================================================\n" );
399  printf( " PAPI Preset Events\n" );
400  printf( "================================================================================\n" );
401  } else {
402  event_code = 0 | PAPI_UE_MASK;
403  printf( "\n"); // put a blank line after the presets before strarting the user events
404  printf( "================================================================================\n" );
405  printf( " User Defined Events\n" );
406  printf( "================================================================================\n" );
407  }
408 
409  /* For consistency, always ASK FOR the first event */
410  PAPI_enum_event( &event_code, PAPI_ENUM_FIRST );
411 
412  if ( print_tabular ) {
413  printf( " Name Code " );
414  if ( !print_avail_only ) {
415  printf( "Avail " );
416  }
417  printf( "Deriv Description (Note)\n" );
418  } else {
419  printf( "%-13s%-11s%-8s%-16s\n |Long Description|\n"
420  " |Developer's Notes|\n |Derived|\n |PostFix|\n"
421  " Native Code[n]: <hex> |name|\n",
422  "Symbol", "Event Code", "Count", "|Short Description|" );
423  }
424  do {
425  if ( PAPI_get_event_info( event_code, &info ) == PAPI_OK ) {
426  if ( print_tabular ) {
427  // if this is a user defined event or its a preset and matches the preset event filters, display its information
428  if ( (i==1) || (filter & info.event_type)) {
429  if ( print_avail_only ) {
430  if ( info.count ) {
431  printf( "%-13s%#x %-5s%s",
432  info.symbol,
433  info.event_code,
434  is_derived( &info ), info.long_descr );
435  }
436  if ( info.note[0] ) {
437  printf( " (%s)", info.note );
438  }
439  printf( "\n" );
440  } else {
441  printf( "%-13s%#x %-6s%-4s %s",
442  info.symbol,
443  info.event_code,
444  ( info.count ? "Yes" : "No" ),
445  is_derived( &info ), info.long_descr );
446  if ( info.note[0] ) {
447  printf( " (%s)", info.note );
448  }
449  printf( "\n" );
450  }
451  tot_count++;
452  if ( info.count ) {
453  avail_count++;
454  }
455  if ( !strcmp( is_derived( &info ), "Yes" ) ) {
456  deriv_count++;
457  }
458  }
459  } else {
460  if ( ( print_avail_only && info.count ) ||
461  ( print_avail_only == 0 ) ) {
462  printf( "%s\t%#x\t%d\t|%s|\n |%s|\n"
463  " |%s|\n |%s|\n |%s|\n",
464  info.symbol, info.event_code, info.count,
465  info.short_descr, info.long_descr, info.note,
466  info.derived, info.postfix );
467  for ( j = 0; j < ( int ) info.count; j++ ) {
468  printf( " Native Code[%d]: %#x |%s|\n", j,
469  info.code[j], info.name[j] );
470  }
471  }
472  tot_count++;
473  if ( info.count ) {
474  avail_count++;
475  }
476  if ( !strcmp( is_derived( &info ), "Yes" ) ) {
477  deriv_count++;
478  }
479  }
480  }
481  } while (PAPI_enum_event( &event_code, print_avail_only ) == PAPI_OK);
482  }
483  }
484  printf( "--------------------------------------------------------------------------------\n" );
485  if ( !print_event_info ) {
486  if ( print_avail_only ) {
487  printf( "Of %d available events, %d ", avail_count, deriv_count );
488  } else {
489  printf( "Of %d possible events, %d are available, of which %d ",
490  tot_count, avail_count, deriv_count );
491  }
492  if ( deriv_count == 1 ) {
493  printf( "is derived.\n\n" );
494  } else {
495  printf( "are derived.\n\n" );
496  }
497  }
498  }
499  test_pass( __FILE__, NULL, 0 );
500  exit( 1 );
501 
502 }
unsigned int count
Definition: papi.h:984
#define PAPI_PRESET_BIT_TLB
Definition: papi.h:520
#define PAPI_PRESET_BIT_L3
Definition: papi.h:519
#define PAPI_VERB_ECONT
Definition: papi.h:387
Hardware info structure.
Definition: papi.h:777
int papi_print_header(char *prompt, const PAPI_hw_info_t **hwinfo)
Definition: test_utils.c:21
#define PAPI_PRESET_BIT_L1
Definition: papi.h:517
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
int PAPI_enum_event(int *EventCode, int modifier)
Definition: papi.c:1161
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define PAPI_PRESET_MASK
char note[PAPI_HUGE_STR_LEN]
Definition: papi.h:1010
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:844
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:500
int i
Definition: fileop.c:140
int k
Definition: iozone.c:19136
char short_descr[PAPI_MIN_STR_LEN]
Definition: papi.h:964
unsigned int event_type
Definition: papi.h:989
#define PAPI_PRESET_BIT_MSC
Definition: papi.h:510
#define PAPI_PRESET_BIT_BR
Definition: papi.h:513
static void print_help(char **argv)
Definition: avail.c:183
static char * is_derived(PAPI_event_info_t *info)
Definition: avail.c:170
#define PAPI_PRESET_BIT_INS
Definition: papi.h:511
unsigned int code[PAPI_MAX_INFO_TERMS]
Definition: papi.h:1000
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1013
char * name
Definition: iozone.c:23648
#define PAPI_PRESET_BIT_FP
Definition: papi.h:521
int
Definition: iozone.c:18528
#define PAPI_PRESET_BIT_CACH
Definition: papi.h:516
#define PAPI_PRESET_BIT_CND
Definition: papi.h:514
#define PAPI_PRESET_BIT_IDL
Definition: papi.h:512
#define PAPI_UE_MASK
long j
Definition: iozone.c:19135
unsigned int event_code
Definition: papi.h:961
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:992
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223
char postfix[PAPI_2MAX_STR_LEN]
Definition: papi.h:995
static int parse_unit_masks(PAPI_event_info_t *info)
Definition: avail.c:211
void exit()
int PAPI_set_debug(int level)
Definition: papi.c:3117
char name[PAPI_MAX_INFO_TERMS][PAPI_2MAX_STR_LEN]
Definition: papi.h:1006
#define PAPI_PRESET_BIT_L2
Definition: papi.h:518

Here is the call graph for this function:

static int parse_unit_masks ( PAPI_event_info_t info)
static

Definition at line 211 of file avail.c.

212 {
213  char *pmask;
214 
215  if ( ( pmask = strchr( info->symbol, ':' ) ) == NULL ) {
216  return ( 0 );
217  }
218  memmove( info->symbol, pmask, ( strlen( pmask ) + 1 ) * sizeof ( char ) );
219  pmask = strchr( info->long_descr, ':' );
220  if ( pmask == NULL )
221  info->long_descr[0] = 0;
222  else
223  memmove( info->long_descr, pmask + sizeof ( char ),
224  ( strlen( pmask ) + 1 ) * sizeof ( char ) );
225  return ( 1 );
226 }
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
again struct sockaddr sizeof(struct sockaddr_in))

Here is the call graph for this function:

Here is the caller graph for this function:

static void print_help ( char **  argv)
static

Definition at line 183 of file avail.c.

184 {
185  printf( "Usage: %s [options]\n", argv[0] );
186  printf( "Options:\n\n" );
187  printf( "General command options:\n" );
188  printf( "\t-a, --avail Display only available PAPI preset and user defined events\n" );
189  printf( "\t-d, --detail Display detailed information about events\n" );
190  printf( "\t-e EVENTNAME Display detail information about specified event\n" );
191  printf( "\t-h, --help Print this help message\n" );
192  printf( "\nEvent filtering options:\n" );
193  printf( "\t--br Display branch related PAPI preset events\n" );
194  printf( "\t--cache Display cache related PAPI preset events\n" );
195  printf( "\t--cnd Display conditional PAPI preset events\n" );
196  printf( "\t--fp Display Floating Point related PAPI preset events\n" );
197  printf( "\t--ins Display instruction related PAPI preset events\n" );
198  printf( "\t--idl Display Stalled or Idle PAPI preset events\n" );
199  printf( "\t--l1 Display level 1 cache related PAPI preset events\n" );
200  printf( "\t--l2 Display level 2 cache related PAPI preset events\n" );
201  printf( "\t--l3 Display level 3 cache related PAPI preset events\n" );
202  printf( "\t--mem Display memory related PAPI preset events\n" );
203  printf( "\t--msc Display miscellaneous PAPI preset events\n" );
204  printf( "\t--tlb Display Translation Lookaside Buffer PAPI preset events\n" );
205  printf( "\n" );
206  printf( "This program provides information about PAPI preset and user defined events.\n" );
207  printf( "PAPI preset event filters can be combined in a logical OR.\n" );
208 }
#define printf
Definition: papi_test.h:125
char ** argv
Definition: iozone.c:1610

Here is the caller graph for this function:

Variable Documentation

int TESTS_QUIET

Definition at line 11 of file test_utils.c.