PAPI 7.1.0.0
Loading...
Searching...
No Matches
all_native_events.c File Reference
Include dependency graph for all_native_events.c:

Go to the source code of this file.

Functions

static int check_event (int event_code, char *name, int quiet)
 
int main (int argc, char **argv)
 

Function Documentation

◆ check_event()

static int check_event ( int  event_code,
char *  name,
int  quiet 
)
static

Definition at line 23 of file all_native_events.c.

24{
25 int retval;
26 long long values;
27 int EventSet = PAPI_NULL;
28
29 /* Possibly there was an older issue with the */
30 /* REPLAY_EVENT:BR_MSP on Pentium4 ??? */
31
32 /* Create an eventset */
34 if ( retval != PAPI_OK ) {
35 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
36 }
37
38 /* Add the event */
39 retval = PAPI_add_event( EventSet, event_code );
40 if ( retval != PAPI_OK ) {
41 if (!quiet) printf( "Error adding %s %d\n", name, retval );
42 return retval;
43 }
44
45 /* Start the event */
47 if ( retval != PAPI_OK ) {
48 PAPI_perror( "PAPI_start" );
49 } else {
51 if ( retval != PAPI_OK ) {
52 PAPI_perror( "PAPI_stop" );
53 return retval;
54 } else {
55 if (!quiet) printf( "Added and Stopped %s successfully.\n", name );
56 }
57 }
58
59 /* Cleanup the eventset */
61 if (retval != PAPI_OK ) {
62 test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval);
63 }
64
65 /* Destroy the eventset */
67 if (retval != PAPI_OK ) {
68 test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval);
69 }
70
71 return PAPI_OK;
72}
add PAPI preset or native hardware event to an event set
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
Produces a string on standard error, describing the last library error.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
int quiet
Definition: rapl_overflow.c:19
const char * name
Definition: rocs.c:225
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 75 of file all_native_events.c.

76{
77
78 int i, k, add_count = 0, err_count = 0;
79 int retval;
80 PAPI_event_info_t info, info1;
81 const PAPI_hw_info_t *hwinfo = NULL;
82 const PAPI_component_info_t* cmpinfo;
83 int event_code;
84 int numcmp, cid;
85 int quiet;
86
87 /* Set quiet variable */
88 quiet=tests_quiet( argc, argv );
89
90 /* Init PAPI library */
92 if ( retval != PAPI_VER_CURRENT ) {
93 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
94 }
95
96 if (!quiet) {
97 printf("Test case ALL_NATIVE_EVENTS: Available "
98 "native events and hardware "
99 "information.\n");
100 }
101
102 hwinfo=PAPI_get_hardware_info();
103 if ( hwinfo == NULL ) {
104 test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
105 }
106
107 numcmp = PAPI_num_components( );
108
109 int rocm_id = PAPI_get_component_index("rocm");
110
111 /* Loop through all components */
112 for( cid = 0; cid < numcmp; cid++ ) {
113
114 if (cid == rocm_id) {
115 /* skip rocm component due to a bug in rocprofiler that
116 * crashes PAPI if multiple GPUs are present */
117 continue;
118 }
119
120 cmpinfo = PAPI_get_component_info( cid );
121 if (cmpinfo == NULL) {
122 test_fail( __FILE__, __LINE__, "PAPI_get_component_info", 2 );
123 }
124
125 /* Skip disabled components */
126 if (cmpinfo->disabled != PAPI_OK && cmpinfo->disabled != PAPI_EDELAY_INIT) {
127 if (!quiet) {
128 printf( "Name: %-23s %s\n",
129 cmpinfo->name ,cmpinfo->description);
130 printf(" \\-> Disabled: %s\n",
131 cmpinfo->disabled_reason);
132 }
133 continue;
134 }
135
136 /* For platform independence, always ASK FOR the first event */
137 /* Don't just assume it'll be the first numeric value */
138 i = 0 | PAPI_NATIVE_MASK;
140
141 do {
142 retval = PAPI_get_event_info( i, &info );
143 event_code = ( int ) info.event_code;
144 if ( check_event( event_code, info.symbol, quiet ) == PAPI_OK) {
145 add_count++;
146 }
147 else {
148 err_count++;
149 }
150
151 /* We used to skip OFFCORE and UNCORE events */
152 /* Why? */
153
154 /* Enumerate all umasks */
155 k = i;
157 do {
158 retval = PAPI_get_event_info( k, &info1 );
159 event_code = ( int ) info1.event_code;
160 if ( check_event( event_code, info1.symbol, quiet ) == PAPI_OK ) {
161 add_count++;
162 }
163 else {
164 err_count++;
165 }
166 } while ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_UMASKS, cid ) == PAPI_OK );
167 }
168
169 } while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cid ) == PAPI_OK );
170
171 }
172
173 if (!quiet) {
174 printf( "\n\nSuccessfully found and added %d events "
175 "(in %d eventsets).\n",
176 add_count , add_count);
177 }
178
179 if ( err_count ) {
180 if (!quiet) printf( "Failed to add %d events.\n", err_count );
181 }
182
183 if ( add_count <= 0 ) {
184 test_fail( __FILE__, __LINE__, "No events added", 1 );
185 }
186
187 test_pass( __FILE__ );
188
189 return 0;
190}
int i
static int check_event(int event_code, char *name, int quiet)
Enumerate PAPI preset or native events for a given component.
returns the component index for the named component
get information about a specific software component
Get the event's name and description info.
get information about the system hardware
initialize the PAPI library.
Get the number of components available on the system.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_EDELAY_INIT
Definition: f90papi.h:271
#define PAPI_NTV_ENUM_UMASKS
Definition: f90papi.h:66
#define PAPI_NATIVE_MASK
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
if(file==NULL) goto out
int
Definition: sde_internal.h:89
char description[PAPI_MAX_STR_LEN]
Definition: papi.h:630
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:627
char disabled_reason[PAPI_HUGE_STR_LEN]
Definition: papi.h:634
unsigned int event_code
Definition: papi.h:958
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
Hardware info structure.
Definition: papi.h:774
Here is the call graph for this function: