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

Go to the source code of this file.

Functions

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

Function Documentation

int main ( int  argc,
char **  argv 
)
Author
Jose Pedro Oliveira

test case for the linux-infiniband component Adapted from its counterpart in the net component.

Definition at line 22 of file infiniband_list_events.c.

23 {
24  int retval,cid,numcmp;
25  int total_events=0;
26  int code;
28  int r;
29  const PAPI_component_info_t *cmpinfo = NULL;
30 
31  /* Set TESTS_QUIET variable */
32  tests_quiet( argc, argv );
33 
34  /* PAPI Initialization */
36  if ( retval != PAPI_VER_CURRENT ) {
37  test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
38  }
39 
40  if (!TESTS_QUIET) {
41  printf("Listing all infiniband events\n");
42  }
43 
44  numcmp = PAPI_num_components();
45 
46  for(cid=0; cid<numcmp; cid++) {
47 
48  if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
49  test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n",-1);
50  }
51 
52  if ( strstr(cmpinfo->name, "infiniband") == NULL) {
53  continue;
54  }
55 
56  if (!TESTS_QUIET) {
57  printf("Component %d (%d) - %d events - %s\n",
58  cid, cmpinfo->CmpIdx,
59  cmpinfo->num_native_events, cmpinfo->name);
60  }
61  if (cmpinfo->disabled) {
62  test_skip(__FILE__,__LINE__,"Component infiniband is disabled", 0);
63  continue;
64  }
65 
66  code = PAPI_NATIVE_MASK;
67 
68  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
69  while ( r == PAPI_OK ) {
70 
71  retval = PAPI_event_code_to_name( code, event_name );
72  if ( retval != PAPI_OK ) {
73  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
74  }
75 
76  if (!TESTS_QUIET) {
77  printf("%#x %s\n", code, event_name);
78  }
79 
80  total_events++;
81 
82  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
83  }
84 
85  }
86 
87  if (total_events==0) {
88  test_skip(__FILE__,__LINE__,"No infiniband events found", 0);
89  }
90 
91  test_pass( __FILE__ );
92 
93  return 0;
94 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:629
#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
return PAPI_OK
Definition: linux-nvml.c:497
int int argc
Definition: iozone.c:1609
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
int PAPI_library_init(int version)
Definition: papi.c:500
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
printf("\tTry: -i 0 -i 1 \n\n")
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: papi.h:465
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225

Here is the call graph for this function: