PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lustre_basic.c
Go to the documentation of this file.
1 
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include "papi_test.h"
14 
15 #define NUM_EVENTS 1
16 
17 int main (int argc, char **argv)
18 {
19 
20  int retval,cid,numcmp;
21  int EventSet = PAPI_NULL;
22  long long values[NUM_EVENTS];
23  int code;
25  int total_events=0;
26  int r;
27  const PAPI_component_info_t *cmpinfo = NULL;
28 
29  /* Set TESTS_QUIET variable */
30  tests_quiet( argc, argv );
31 
32  /* PAPI Initialization */
34  if ( retval != PAPI_VER_CURRENT ) {
35  test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
36  }
37 
38  if (!TESTS_QUIET) {
39  printf("Trying all lustre events\n");
40  }
41 
42  numcmp = PAPI_num_components();
43 
44  for(cid=0; cid<numcmp; cid++) {
45 
46  if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
47  test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n", 0);
48  }
49 
50  if (strstr(cmpinfo->name,"lustre")) {
51  if (!TESTS_QUIET) printf("\tFound lustre component %d - %s\n", cid, cmpinfo->name);
52  }
53  else {
54  continue;
55  }
56 
57  code = PAPI_NATIVE_MASK;
58 
59  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
60 
61  while ( r == PAPI_OK ) {
62  retval = PAPI_event_code_to_name( code, event_name );
63  if ( retval != PAPI_OK ) {
64  printf("Error translating %#x\n",code);
65  test_fail( __FILE__, __LINE__,
66  "PAPI_event_code_to_name", retval );
67  }
68 
69  if (!TESTS_QUIET) printf(" %s ",event_name);
70 
71  EventSet = PAPI_NULL;
72 
73  retval = PAPI_create_eventset( &EventSet );
74  if (retval != PAPI_OK) {
75  test_fail(__FILE__, __LINE__,
76  "PAPI_create_eventset()",retval);
77  }
78 
79  retval = PAPI_add_event( EventSet, code );
80  if (retval != PAPI_OK) {
81  test_fail(__FILE__, __LINE__,
82  "PAPI_add_event()",retval);
83  }
84 
85  retval = PAPI_start( EventSet);
86  if (retval != PAPI_OK) {
87  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
88  }
89 
90  retval = PAPI_stop( EventSet, values);
91  if (retval != PAPI_OK) {
92  test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
93  }
94 
95  if (!TESTS_QUIET) printf(" value: %lld\n",values[0]);
96 
97  retval = PAPI_cleanup_eventset( EventSet );
98  if (retval != PAPI_OK) {
99  test_fail(__FILE__, __LINE__,
100  "PAPI_cleanup_eventset()",retval);
101  }
102 
103  retval = PAPI_destroy_eventset( &EventSet );
104  if (retval != PAPI_OK) {
105  test_fail(__FILE__, __LINE__,
106  "PAPI_destroy_eventset()",retval);
107  }
108 
109  total_events++;
110 
111  r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
112  }
113  }
114 
115  if (total_events==0) {
116  test_skip(__FILE__,__LINE__,"No lustre events found",0);
117  }
118 
119  if (!TESTS_QUIET) {
120  printf("Note: for this test the values are expected to all be 0 as no I/O happens during the test.\n");
121  }
122 
123  test_pass( __FILE__, NULL, 0 );
124 
125  return 0;
126 }
127 
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:626
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2258
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:807
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1622
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
#define PAPI_NULL
Definition: papi.h:290
int EventSet
Definition: data_range.c:25
int PAPI_num_components(void)
Definition: papi.c:4326
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:497
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1324
#define NUM_EVENTS
Tests basic lustre functionality.
Definition: lustre_basic.c:15
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2834
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:926
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1971
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
int PAPI_start(int EventSet)
Definition: papi.c:2053
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:223
int main(int argc, char **argv)
List all appio events codes and names.