PAPI  5.4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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

int main ( int  argc,
char **  argv 
)

Definition at line 10 of file remove_events.c.

11 {
12  int retval;
13  int EventSet = PAPI_NULL;
14  long long values1[2],values2[2];
15  char *event_names[] = {"PAPI_TOT_CYC","PAPI_TOT_INS"};
16  char add_event_str[PAPI_MAX_STR_LEN];
17  double instructions_error;
18  long long old_instructions;
19 
20  /* Set TESTS_QUIET variable */
21  tests_quiet( argc, argv );
22 
23  /* Init the PAPI library */
25  if ( retval != PAPI_VER_CURRENT ) {
26  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
27  }
28 
29  /* Create an empty event set */
30  retval = PAPI_create_eventset( &EventSet );
31  if ( retval != PAPI_OK ) {
32  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
33  }
34 
35  /* add the events named above */
36  retval = PAPI_add_named_event( EventSet, event_names[0] );
37  if ( retval != PAPI_OK ) {
38  sprintf( add_event_str, "PAPI_add_named_event[%s]", event_names[0] );
39  test_fail( __FILE__, __LINE__, add_event_str, retval );
40  }
41 
42  retval = PAPI_add_named_event( EventSet, event_names[1] );
43  if ( retval != PAPI_OK ) {
44  sprintf( add_event_str, "PAPI_add_named_event[%s]", event_names[1] );
45  test_fail( __FILE__, __LINE__, add_event_str, retval );
46  }
47 
48  /* Start PAPI */
49  retval = PAPI_start( EventSet );
50  if ( retval != PAPI_OK ) {
51  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
52  }
53 
54  /* our test code */
56 
57  /* Stop PAPI */
58  retval = PAPI_stop( EventSet, values1 );
59  if ( retval != PAPI_OK ) {
60  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
61  }
62 
63 
64  old_instructions=values1[1];
65 
66  if ( !TESTS_QUIET ) {
67 
68  printf( "========================\n" );
69 
70  /* cycles is first, other event second */
71  sprintf( add_event_str, "%-12s : \t", event_names[0] );
72  printf( TAB1, add_event_str, values1[0] );
73  sprintf( add_event_str, "%-12s : \t", event_names[1] );
74  printf( TAB1, add_event_str, values1[1] );
75  }
76 
77 
78  /* remove PAPI_TOT_CYC */
79  retval = PAPI_remove_named_event( EventSet, event_names[0] );
80  if ( retval != PAPI_OK ) {
81  sprintf( add_event_str, "PAPI_add_named_event[%s]", event_names[0] );
82  test_fail( __FILE__, __LINE__, add_event_str, retval );
83  }
84 
85 
86  /* Start PAPI */
87  retval = PAPI_start( EventSet );
88  if ( retval != PAPI_OK ) {
89  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
90  }
91 
92  /* our test code */
94 
95  /* Stop PAPI */
96  retval = PAPI_stop( EventSet, values2 );
97  if ( retval != PAPI_OK ) {
98  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
99  }
100 
101 
102  /* test if after removing the event, the second event */
103  /* still points to the proper native event */
104 
105  /* this only works if IPC != 1 */
106 
107  if ( !TESTS_QUIET ) {
108 
109  printf( "==========================\n" );
110  printf( "After removing PAP_TOT_CYC\n");
111  sprintf( add_event_str, "%-12s : \t", event_names[1] );
112  printf( TAB1, add_event_str, values2[0] );
113 
114  instructions_error=((double)old_instructions - (double)values2[0])/
115  (double)old_instructions;
116  if (instructions_error>10.0) {
117  printf("Error of %.2f%%\n",instructions_error);
118  test_fail( __FILE__, __LINE__, "validation", 0 );
119  }
120 
121  }
122  test_pass( __FILE__, NULL, 0 );
123 
124  return 0;
125 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2258
#define NUM_FLOPS
int PAPI_add_named_event(int EventSet, char *EventName)
Definition: papi.c:1835
#define PAPI_NULL
Definition: papi.h:290
#define TAB1
Definition: papi_test.h:112
int EventSet
Definition: data_range.c:25
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
static double
Definition: fileop.c:1281
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1424
void do_flops(int n)
Definition: multiplex.c:23
#define PAPI_MAX_STR_LEN
Definition: papi.h:463
int PAPI_start(int EventSet)
Definition: papi.c:2053
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223
int PAPI_remove_named_event(int EventSet, char *EventName)
Definition: papi.c:1919

Here is the call graph for this function: