PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mx_elapsed.c
Go to the documentation of this file.
1 
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 
15 #include "papi.h"
16 #include "papi_test.h"
17 
18 #define NUM_EVENTS 3
19 
20 int main (int argc, char **argv)
21 {
22 
23  int retval,cid,numcmp,our_cmp;
24  int EventSet = PAPI_NULL;
25  long long values[NUM_EVENTS];
26  int code;
27  const PAPI_component_info_t *cmpinfo = NULL;
28  int quiet=0;
29 
30  /* Set quiet variable */
31  quiet=tests_quiet( argc, argv );
32 
33  /* PAPI Initialization */
35  if ( retval != PAPI_VER_CURRENT ) {
36  test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
37  }
38 
39  if (!quiet) {
40  printf("Trying mutiple reads in MX component\n");
41  }
42 
43  numcmp = PAPI_num_components();
44  our_cmp=-1;
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", 0);
50  }
51 
52  if (strstr(cmpinfo->name,"mx")) {
53  if (!quiet) printf("\tFound Myrinet component %d - %s\n", cid, cmpinfo->name);
54  our_cmp=cid;
55  break;
56  }
57 
58  }
59 
60  if (our_cmp<0) {
61  test_skip(__FILE__, __LINE__,"MX component not found\n", 0);
62  }
63 
64  if (cmpinfo->num_native_events<=0) {
65  test_skip(__FILE__, __LINE__,"MX component not found\n", 0);
66  }
67 
68 
69  EventSet = PAPI_NULL;
70 
71  retval = PAPI_create_eventset( &EventSet );
72  if (retval != PAPI_OK) {
73  test_fail(__FILE__, __LINE__,
74  "PAPI_create_eventset()",retval);
75  }
76 
77  retval=PAPI_event_name_to_code("mx:::COUNTERS_UPTIME",&code);
78  if (retval!=PAPI_OK) {
79  test_fail(__FILE__, __LINE__,
80  "could not add event COUNTERS_UPTIME",retval);
81  }
82 
83  retval = PAPI_add_event( EventSet, code );
84  if (retval != PAPI_OK) {
85  test_fail(__FILE__, __LINE__,
86  "PAPI_add_event()",retval);
87  }
88 
89  retval=PAPI_event_name_to_code("mx:::PUSH_OBSOLETE",&code);
90  if (retval!=PAPI_OK) {
91  test_fail(__FILE__, __LINE__,
92  "could not add event PUSH_OBSOLETE",retval);
93  }
94 
95  retval = PAPI_add_event( EventSet, code );
96  if (retval != PAPI_OK) {
97  test_fail(__FILE__, __LINE__,
98  "PAPI_add_event()",retval);
99  }
100 
101  retval=PAPI_event_name_to_code("mx:::PKT_MISROUTED",&code);
102  if (retval!=PAPI_OK) {
103  test_fail(__FILE__, __LINE__,
104  "could not add event PKT_MISROUTED",retval);
105  }
106 
107  retval = PAPI_add_event( EventSet, code );
108  if (retval != PAPI_OK) {
109  test_fail(__FILE__, __LINE__,
110  "PAPI_add_event()",retval);
111  }
112 
113  retval = PAPI_start( EventSet);
114  if (retval != PAPI_OK) {
115  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
116  }
117 
118  retval = PAPI_read( EventSet, values);
119  if (retval != PAPI_OK) {
120  test_fail(__FILE__, __LINE__, "PAPI_read()",retval);
121  }
122 
123  if (!quiet) printf("%lld %lld %lld\n",values[0],values[1],values[2]);
124 
125  retval = PAPI_stop( EventSet, values);
126  if (retval != PAPI_OK) {
127  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
128  }
129 
130  if (!quiet) printf("%lld %lld %lld\n",values[0],values[1],values[2]);
131 
132 
133 
134  test_pass( __FILE__ );
135 
136  return 0;
137 }
138 
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:629
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
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_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
#define PAPI_NULL
Definition: papi.h:292
int PAPI_num_components(void)
Definition: papi.c:4387
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
int PAPI_event_name_to_code(const char *in, int *out)
Definition: papi.c:1004
int int argc
Definition: iozone.c:1609
Return codes and api definitions.
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
#define NUM_EVENTS
Tests basic mx myrinet functionality.
Definition: mx_elapsed.c:18
int PAPI_library_init(int version)
Definition: papi.c:500
int quiet
Definition: rapl_overflow.c:18
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
printf("\tTry: -i 0 -i 1 \n\n")
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
int PAPI_read(int EventSet, long long *values)
Definition: papi.c:2559
int PAPI_start(int EventSet)
Definition: papi.c:2096
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225
int main(int argc, char **argv)
List all appio events codes and names.