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

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 List all appio events codes and names. More...
 

Function Documentation

int main ( int  argc,
char **  argv 
)
Author
Tushar Mohan (adapted for appio from original linux-net code)

test case for the appio component

Definition at line 19 of file appio_list_events.c.

20 {
21  int retval,cid,numcmp;
22  int total_events=0;
23  int code;
25  int r;
26  const PAPI_component_info_t *cmpinfo = NULL;
27 
28  /* Set TESTS_QUIET variable */
29  tests_quiet( argc, argv );
30 
31  /* PAPI Initialization */
33  if ( retval != PAPI_VER_CURRENT ) {
34  test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
35  }
36 
37  if (!TESTS_QUIET) {
38  printf("Listing all appio events\n");
39  }
40 
41  numcmp = PAPI_num_components();
42 
43  for(cid=0; cid<numcmp; cid++) {
44 
45  if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
46  test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n",-1);
47  }
48 
49  if ( strstr(cmpinfo->name, "appio") == NULL) {
50  continue;
51  }
52 
53  if (!TESTS_QUIET) {
54  printf("Component %d (%d) - %d events - %s\n",
55  cid, cmpinfo->CmpIdx,
56  cmpinfo->num_native_events, cmpinfo->name);
57  }
58 
59  code = PAPI_NATIVE_MASK;
60 
61  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
62  while ( r == PAPI_OK ) {
63 
64  retval = PAPI_event_code_to_name( code, event_name );
65  if ( retval != PAPI_OK ) {
66  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
67  }
68 
69  if (!TESTS_QUIET) {
70  printf("%#x %s\n", code, event_name);
71  }
72 
73  total_events++;
74 
75  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
76  }
77 
78  }
79 
80  if (total_events==0) {
81  test_skip(__FILE__,__LINE__,"No appio events found", 0);
82  }
83 
84  test_pass( __FILE__, NULL, 0 );
85 
86  return 0;
87 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:625
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:805
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
int PAPI_num_components(void)
Definition: papi.c:4285
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
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:495
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1311
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function: