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

Go to the source code of this file.

Macros

#define PINGADDR   "127.0.0.1"
 Prints the value of every net event (by code) More...
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

#define PINGADDR   "127.0.0.1"
Author
Jose Pedro Oliveira

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

Definition at line 19 of file infiniband_values_by_code.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 21 of file infiniband_values_by_code.c.

22 {
23  int retval,cid,numcmp;
24  int EventSet = PAPI_NULL;
25  long long value;
26  int code;
28  int total_events=0;
29  int r;
30  const PAPI_component_info_t *cmpinfo = NULL;
31 
32  /* Set TESTS_QUIET variable */
33  tests_quiet( argc, argv );
34 
35  /* PAPI Initialization */
37  if ( retval != PAPI_VER_CURRENT ) {
38  test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
39  }
40 
41  if (!TESTS_QUIET) {
42  printf("Trying all net events\n");
43  }
44 
45  numcmp = PAPI_num_components();
46 
47  for(cid=0; cid<numcmp; cid++) {
48 
49  if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
50  test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n",-1);
51  }
52 
53  if (!TESTS_QUIET) {
54  printf("Component %d - %d events - %s\n", cid,
55  cmpinfo->num_native_events, cmpinfo->name);
56  }
57 
58  if ( strstr(cmpinfo->name, "infiniband") == NULL) {
59  continue;
60  }
61 
62  code = PAPI_NATIVE_MASK;
63 
64  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
65  while ( r == PAPI_OK ) {
66 
67  retval = PAPI_event_code_to_name( code, event_name );
68  if ( retval != PAPI_OK ) {
69  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
70  }
71 
72  if (!TESTS_QUIET) {
73  printf("%#x %-24s = ", code, event_name);
74  }
75 
76  EventSet = PAPI_NULL;
77 
78  retval = PAPI_create_eventset( &EventSet );
79  if (retval != PAPI_OK) {
80  test_fail(__FILE__, __LINE__, "PAPI_create_eventset()", retval);
81  }
82 
83  retval = PAPI_add_event( EventSet, code );
84  if (retval != PAPI_OK) {
85  test_fail(__FILE__, __LINE__, "PAPI_add_event()", retval);
86  }
87 
88  retval = PAPI_start( EventSet );
89  if (retval != PAPI_OK) {
90  test_fail(__FILE__, __LINE__, "PAPI_start()", retval);
91  }
92 
93  if (strcmp(event_name, "_recv") == 0) {
94  /* XXX figure out a general method to generate some traffic
95  * for infiniband
96  * the operation should take more than one second in order
97  * to guarantee that the network counters are updated */
98  retval = system("ping -c 4 " PINGADDR " > /dev/null");
99  if (retval < 0) {
100  test_fail(__FILE__, __LINE__, "Unable to start ping", retval);
101  }
102  }
103 
104  retval = PAPI_stop( EventSet, &value );
105  if (retval != PAPI_OK) {
106  test_fail(__FILE__, __LINE__, "PAPI_stop()", retval);
107  }
108 
109  if (!TESTS_QUIET) printf("%lld\n", value);
110 
111  retval = PAPI_cleanup_eventset( EventSet );
112  if (retval != PAPI_OK) {
113  test_fail(__FILE__, __LINE__, "PAPI_cleanup_eventset()", retval);
114  }
115 
116  retval = PAPI_destroy_eventset( &EventSet );
117  if (retval != PAPI_OK) {
118  test_fail(__FILE__, __LINE__, "PAPI_destroy_eventset()", retval);
119  }
120 
121  total_events++;
122 
123  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
124  }
125 
126  }
127 
128  if (total_events==0) {
129  test_skip(__FILE__,__LINE__,"No net events found", 0);
130  }
131 
132  test_pass( __FILE__, NULL, 0 );
133 
134  return 0;
135 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:625
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:805
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
#define PAPI_NULL
Definition: fpapi.h:13
#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
void double value
Definition: iozone.c:18781
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
#define PINGADDR
Prints the value of every net event (by code)
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1311
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
int EventSet
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
int PAPI_start(int EventSet)
Definition: papi.c:2026
int system()
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function: