PAPI 7.1.0.0
Loading...
Searching...
No Matches
appio_list_events.c
Go to the documentation of this file.
1/****************************/
2/* THIS IS OPEN SOURCE CODE */
3/****************************/
4
15#include <stdio.h>
16#include <stdlib.h>
17#include <string.h>
18
19#include "papi.h"
20#include "papi_test.h"
21
22int main (int argc, char **argv)
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 appio 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, "appio") == 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
62 code = PAPI_NATIVE_MASK;
63
64 r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
65 while ( r == PAPI_OK ) {
66
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 %s\n", code, event_name);
74 }
75
76 total_events++;
77
78 r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
79 }
80
81 }
82
83 if (total_events==0) {
84 test_skip(__FILE__,__LINE__,"No appio events found", 0);
85 }
86
87 test_pass( __FILE__ );
88
89 return 0;
90}
91
92// vim:set ai ts=4 sw=4 sts=4 et:
Enumerate PAPI preset or native events for a given component.
Convert a numeric hardware event code to a name.
get information about a specific software component
initialize the PAPI library.
Get the number of components available on the system.
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
int TESTS_QUIET
Definition: test_utils.c:18
#define PAPI_NATIVE_MASK
Return codes and api definitions.
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int main()
Definition: pernode.c:20
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:627
int retval
Definition: zero_fork.c:53