PAPI  5.7.0.0
infiniband_umad_list_events.c
Go to the documentation of this file.
1 /****************************/
2 /* THIS IS OPEN SOURCE CODE */
3 /****************************/
4 
18 #include <stdio.h>
19 #include <stdlib.h>
20 
21 #include "papi.h"
22 #include "papi_test.h"
23 #include <string.h> // Needed for 'strstr' used below.
24 
25 int main (int argc, char **argv)
26 {
27  int retval,cid,numcmp;
28  int total_events=0;
29  int code;
31  int r;
32  const PAPI_component_info_t *cmpinfo = NULL;
33 
34  /* Set TESTS_QUIET variable */
35  tests_quiet( argc, argv );
36 
37  /* PAPI Initialization */
39  if ( retval != PAPI_VER_CURRENT ) {
40  test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
41  }
42 
43  if (!TESTS_QUIET) {
44  printf("Listing all net events\n");
45  }
46 
47  numcmp = PAPI_num_components();
48 
49  for(cid=0; cid<numcmp; cid++) {
50 
51  if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
52  test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n",-1);
53  }
54 
55  if ( strstr(cmpinfo->name, "infiniband") == NULL) {
56  continue;
57  }
58 
59  if (!TESTS_QUIET) {
60  printf("Component %d (%d) - %d events - %s\n",
61  cid, cmpinfo->CmpIdx,
62  cmpinfo->num_native_events, cmpinfo->name);
63  }
64 
65  code = PAPI_NATIVE_MASK;
66 
67  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
68  while ( r == PAPI_OK ) {
69 
71  if ( retval != PAPI_OK ) {
72  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
73  }
74 
75  if (!TESTS_QUIET) {
76  printf("%#x %s\n", code, event_name);
77  }
78 
79  total_events++;
80 
81  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
82  }
83 
84  }
85 
86  if (total_events==0) {
87  test_skip(__FILE__,__LINE__,"No net events found", 0);
88  }
89 
90  test_pass( __FILE__ );
91 
92  return 0;
93 }
94 
95 // vim:set ai ts=4 sw=4 sts=4 et:
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_OK
Definition: fpapi.h:105
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:796
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_num_components(void)
Definition: papi.c:4387
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int retval
Definition: zero_fork.c:53
Return codes and api definitions.
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:561
int PAPI_library_init(int version)
Definition: papi.c:500
int main(int argc, char **argv)
List all net events codes and names.
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:630
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1357
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
int TESTS_QUIET
Definition: test_utils.c:18
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43