PAPI 7.1.0.0
Loading...
Searching...
No Matches
remove_events.c File Reference
Include dependency graph for remove_events.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 15 of file remove_events.c.

16{
17 int retval;
18 int EventSet = PAPI_NULL;
19 long long values1[2],values2[2];
20 const char *event_names[] = {"PAPI_TOT_CYC","PAPI_TOT_INS"};
21 char add_event_str[PAPI_MAX_STR_LEN];
22 double instructions_error;
23 long long old_instructions;
24 int quiet;
25
26 /* Set TESTS_QUIET variable */
27 quiet = tests_quiet( argc, argv );
28
29 /* Init the PAPI library */
31 if ( retval != PAPI_VER_CURRENT ) {
32 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
33 }
34
35 /* Create an empty event set */
37 if ( retval != PAPI_OK ) {
38 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
39 }
40
41 /* add the events named above */
43 if ( retval != PAPI_OK ) {
44 sprintf( add_event_str, "PAPI_add_named_event[%s]", event_names[0] );
45 if (!quiet) printf("Trouble %s\n",add_event_str);
46 test_skip( __FILE__, __LINE__, add_event_str, retval );
47 }
48
50 if ( retval != PAPI_OK ) {
51 sprintf( add_event_str, "PAPI_add_named_event[%s]", event_names[1] );
52 test_fail( __FILE__, __LINE__, add_event_str, retval );
53 }
54
55 /* Start PAPI */
57 if ( retval != PAPI_OK ) {
58 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
59 }
60
61 /* our test code */
63
64 /* Stop PAPI */
65 retval = PAPI_stop( EventSet, values1 );
66 if ( retval != PAPI_OK ) {
67 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
68 }
69
70
71 old_instructions=values1[1];
72
73 if ( !quiet ) {
74
75 printf( "========================\n" );
76
77 /* cycles is first, other event second */
78 sprintf( add_event_str, "%-12s : \t", event_names[0] );
79 printf( TAB1, add_event_str, values1[0] );
80 sprintf( add_event_str, "%-12s : \t", event_names[1] );
81 printf( TAB1, add_event_str, values1[1] );
82 }
83
84
85 /* remove PAPI_TOT_CYC */
87 if ( retval != PAPI_OK ) {
88 sprintf( add_event_str, "PAPI_add_named_event[%s]", event_names[0] );
89 test_fail( __FILE__, __LINE__, add_event_str, retval );
90 }
91
92
93 /* Start PAPI */
95 if ( retval != PAPI_OK ) {
96 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
97 }
98
99 /* our test code */
101
102 /* Stop PAPI */
103 retval = PAPI_stop( EventSet, values2 );
104 if ( retval != PAPI_OK ) {
105 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
106 }
107
108
109 /* test if after removing the event, the second event */
110 /* still points to the proper native event */
111
112 /* this only works if IPC != 1 */
113
114 if ( !quiet ) {
115
116 printf( "==========================\n" );
117 printf( "After removing PAP_TOT_CYC\n");
118 sprintf( add_event_str, "%-12s : \t", event_names[1] );
119 printf( TAB1, add_event_str, values2[0] );
120
121 instructions_error=((double)old_instructions - (double)values2[0])/
122 (double)old_instructions;
123 if (instructions_error>10.0) {
124 printf("Error of %.2f%%\n",instructions_error);
125 test_fail( __FILE__, __LINE__, "validation", 0 );
126 }
127
128 }
129 test_pass( __FILE__ );
130
131 return 0;
132}
static const char * event_names[2]
Definition: Gamum.c:27
add PAPI preset or native hardware event by name to an EventSet
Create a new empty PAPI EventSet.
initialize the PAPI library.
removes a named hardware event from a PAPI event set.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
static int EventSet
Definition: init_fini.c:8
void do_flops(int n)
Definition: multiplex.c:23
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
#define TAB1
Definition: papi_test.h:98
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 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: