PAPI 7.1.0.0
Loading...
Searching...
No Matches
net_list_events.c File Reference
Include dependency graph for net_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.
 

Function Documentation

◆ main()

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

test case for the linux-net component

Definition at line 21 of file net_list_events.c.

22{
23 int retval,cid,numcmp;
24 int total_events=0;
25 int code;
27 int r;
28 const PAPI_component_info_t *cmpinfo = NULL;
29
30 /* Set TESTS_QUIET variable */
31 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 (!TESTS_QUIET) {
40 printf("Listing all net events\n");
41 }
42
43 numcmp = PAPI_num_components();
44
45 for(cid=0; cid<numcmp; cid++) {
46
47 if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
48 test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n",-1);
49 }
50
51 if ( strstr(cmpinfo->name, "net") == NULL) {
52 continue;
53 }
54
55 if (!TESTS_QUIET) {
56 printf("Component %d (%d) - %d events - %s\n",
57 cid, cmpinfo->CmpIdx,
58 cmpinfo->num_native_events, cmpinfo->name);
59 }
60
61 code = PAPI_NATIVE_MASK;
62
63 r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
64 while ( r == PAPI_OK ) {
65
67 if ( retval != PAPI_OK ) {
68 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
69 }
70
71 if (!TESTS_QUIET) {
72 printf("%#x %s\n", code, event_name);
73 }
74
75 total_events++;
76
77 r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
78 }
79
80 }
81
82 if (total_events==0) {
83 test_skip(__FILE__,__LINE__,"No net events found", 0);
84 }
85
86 test_pass( __FILE__ );
87
88 return 0;
89}
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
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
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:627
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: