PAPI 7.1.0.0
Loading...
Searching...
No Matches
tests/perf_event_uncore.c File Reference
Include dependency graph for tests/perf_event_uncore.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 17 of file tests/perf_event_uncore.c.

17 {
18
19 int retval,quiet;
20 int EventSet = PAPI_NULL;
21 long long values[1];
22 char *uncore_event_tmp=NULL;
23 char uncore_event[BUFSIZ];
24 char event_name[BUFSIZ];
25 int uncore_cidx=-1;
26 const PAPI_component_info_t *info;
27
28 /* Set TESTS_QUIET variable */
29 quiet = tests_quiet( argc, argv );
30
31 if (!quiet) {
32 printf("Testing the :cpu=0 way of attaching an uncore event to a core\n");
33 }
34
35 /* Init the PAPI library */
37 if ( retval != PAPI_VER_CURRENT ) {
38 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
39 }
40
41 /* Find the uncore PMU */
42 uncore_cidx=PAPI_get_component_index("perf_event_uncore");
43 if (uncore_cidx<0) {
44 if (!quiet) {
45 printf("perf_event_uncore component not found\n");
46 }
47 test_skip(__FILE__,__LINE__,"perf_event_uncore component not found",0);
48 }
49
50 /* Check if component disabled */
51 info=PAPI_get_component_info(uncore_cidx);
52 if (info->disabled) {
53 if (!quiet) {
54 printf("perf_event_uncore component is disabled\n");
55 }
56 test_skip(__FILE__,__LINE__,"uncore component disabled",0);
57 }
58
59 /* Get a relevant event name */
60 uncore_event_tmp=get_uncore_event(event_name, BUFSIZ);
61 if (uncore_event_tmp==NULL) {
62 if (!quiet) {
63 printf("uncore event name not available\n");
64 }
65 test_skip( __FILE__, __LINE__,
66 "PAPI does not support uncore on this processor",
68 }
69
70 sprintf(uncore_event,"%s:cpu=0",uncore_event_tmp);
71
72 /* Create an eventset */
74 if (retval != PAPI_OK) {
75 test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
76 }
77
78 /* Add our uncore event */
79 retval = PAPI_add_named_event(EventSet, uncore_event);
80 if (retval != PAPI_OK) {
81 if ( !quiet ) {
82 printf("Error trying to use event %s\n", uncore_event);
83 }
84 test_fail(__FILE__, __LINE__, "adding uncore event",retval);
85 }
86
87 /* Start PAPI */
89 if ( retval != PAPI_OK ) {
90 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
91 }
92
93 /* our work code */
95
96 /* Stop PAPI */
98 if ( retval != PAPI_OK ) {
99 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
100 }
101
102 if ( !quiet ) {
103 printf("\tUsing event %s\n",uncore_event);
104 printf("\t%s: %lld\n",uncore_event,values[0]);
105 }
106
107 test_pass( __FILE__ );
108
109 return 0;
110}
add PAPI preset or native hardware event by name to an EventSet
Create a new empty PAPI EventSet.
returns the component index for the named component
get information about a specific software component
initialize the PAPI library.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_ENOSUPP
Definition: f90papi.h:244
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void do_flops(int n)
Definition: multiplex.c:23
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 * get_uncore_event(char *event, int size)
int quiet
Definition: rapl_overflow.c:19
#define NUM_FLOPS
Definition: sdsc-mpx.c:24
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: