PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
zero_flip.c File Reference
Include dependency graph for zero_flip.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 27 of file zero_flip.c.

28 {
29  int retval, eventcnt, events[2], i, tmp;
31  int PAPI_event;
32  long long values1[2], values2[2];
33  long long elapsed_us, elapsed_cyc;
34  char event_name[PAPI_MAX_STR_LEN], add_event_str[PAPI_MAX_STR_LEN];
35  int quiet;
36 
37  /* Set TESTS_QUIET variable */
38  quiet = tests_quiet( argc, argv );
39 
41  if ( retval != PAPI_VER_CURRENT )
42  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
43 
44  /* query and set up the right instruction to monitor */
46  PAPI_event = PAPI_FP_OPS;
47  else
48  PAPI_event = PAPI_TOT_INS;
49 
50  retval = PAPI_event_code_to_name( PAPI_event, event_name );
51  if ( retval != PAPI_OK )
52  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
53  sprintf( add_event_str, "PAPI_add_event[%s]", event_name );
54 
55  retval = PAPI_create_eventset( &EventSet1 );
56  if ( retval != PAPI_OK )
57  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
58 
59  /* Add the events */
60  if (!quiet) printf( "Adding: %s\n", event_name );
61  retval = PAPI_add_event( EventSet1, PAPI_event );
62  if ( retval != PAPI_OK ) {
63  if (!quiet) printf("Trouble adding event\n");
64  test_skip( __FILE__, __LINE__, "PAPI_add_event", retval );
65  }
66 
67  retval = PAPI_add_event( EventSet1, PAPI_TOT_CYC );
68  if ( retval != PAPI_OK )
69  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
70 
71  /* Add them reversed to EventSet2 */
72 
73  retval = PAPI_create_eventset( &EventSet2 );
74  if ( retval != PAPI_OK )
75  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
76 
77  eventcnt = 2;
78  retval = PAPI_list_events( EventSet1, events, &eventcnt );
79  if ( retval != PAPI_OK )
80  test_fail( __FILE__, __LINE__, "PAPI_list_events", retval );
81 
82  for ( i = eventcnt - 1; i >= 0; i-- ) {
83  retval = PAPI_event_code_to_name( events[i], event_name );
84  if ( retval != PAPI_OK )
85  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
86 
87  retval = PAPI_add_event( EventSet2, events[i] );
88  if ( retval != PAPI_OK )
89  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
90  }
91 
92  elapsed_us = PAPI_get_real_usec( );
93 
94  elapsed_cyc = PAPI_get_real_cyc( );
95 
96  retval = PAPI_start( EventSet1 );
97  if ( retval != PAPI_OK )
98  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
99 
100  do_flops( NUM_FLOPS );
101 
102  retval = PAPI_stop( EventSet1, values1 );
103  if ( retval != PAPI_OK )
104  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
105 
106  retval = PAPI_start( EventSet2 );
107  if ( retval != PAPI_OK )
108  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
109 
110  do_flops( NUM_FLOPS );
111 
112  retval = PAPI_stop( EventSet2, values2 );
113  if ( retval != PAPI_OK )
114  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
115 
116  elapsed_us = PAPI_get_real_usec( ) - elapsed_us;
117 
118  elapsed_cyc = PAPI_get_real_cyc( ) - elapsed_cyc;
119 
120  retval = PAPI_cleanup_eventset( EventSet1 ); /* JT */
121  if ( retval != PAPI_OK )
122  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
123 
124  retval = PAPI_destroy_eventset( &EventSet1 );
125  if ( retval != PAPI_OK )
126  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
127 
128  retval = PAPI_cleanup_eventset( EventSet2 ); /* JT */
129  if ( retval != PAPI_OK )
130  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
131 
132  retval = PAPI_destroy_eventset( &EventSet2 );
133  if ( retval != PAPI_OK )
134  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
135 
136  if ( !quiet ) {
137  printf( "Test case 0: start, stop.\n" );
138  printf( "-----------------------------------------------\n" );
139  tmp = PAPI_get_opt( PAPI_DEFDOM, NULL );
140  printf( "Default domain is: %d (%s)\n", tmp,
141  stringify_all_domains( tmp ) );
142  tmp = PAPI_get_opt( PAPI_DEFGRN, NULL );
143  printf( "Default granularity is: %d (%s)\n", tmp,
144  stringify_granularity( tmp ) );
145  printf( "Using %d iterations of c += a*b\n", NUM_FLOPS );
146  printf
147  ( "-------------------------------------------------------------------------\n" );
148 
149  printf( "Test type : \t 1\t 2\n" );
150 
151  sprintf( add_event_str, "%-12s : \t", event_name );
152  printf( TAB2, add_event_str, values1[0], values2[1] );
153  printf( TAB2, "PAPI_TOT_CYC : \t", values1[1], values2[0] );
154  printf( TAB1, "Real usec : \t", elapsed_us );
155  printf( TAB1, "Real cycles : \t", elapsed_cyc );
156 
157  printf
158  ( "-------------------------------------------------------------------------\n" );
159 
160  printf( "Verification: none\n" );
161  }
162 
163  test_pass( __FILE__ );
164 
165  return 0;
166 
167 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
int PAPI_event[2]
Definition: data_range.c:30
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
#define PAPI_FP_OPS
char * stringify_granularity(int granularity)
Definition: test_utils.c:353
#define PAPI_NULL
Definition: papi.h:292
#define TAB1
Definition: papi_test.h:88
#define PAPI_TOT_INS
return PAPI_OK
Definition: linux-nvml.c:497
#define NUM_FLOPS
Definition: sdsc-mpx.c:24
int int argc
Definition: iozone.c:1609
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char events[MAX_EVENTS][BUFSIZ]
char ** argv
Definition: iozone.c:1610
int PAPI_library_init(int version)
Definition: papi.c:500
int i
Definition: fileop.c:140
char * stringify_all_domains(int domains)
Definition: test_utils.c:293
int quiet
Definition: rapl_overflow.c:18
#define PAPI_TOT_CYC
#define TAB2
Definition: papi_test.h:89
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4143
long long elapsed_cyc
Definition: zero_fork.c:50
#define PAPI_DEFGRN
Definition: papi.h:434
int EventSet2
Definition: rapl_overflow.c:16
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2890
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
void do_flops(int n)
Definition: multiplex.c:23
int PAPI_query_event(int EventCode)
Definition: papi.c:684
long long PAPI_get_real_usec(void)
Definition: papi.c:6264
printf("\tTry: -i 0 -i 1 \n\n")
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
#define PAPI_DEFDOM
Definition: papi.h:432
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:2014
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
long long PAPI_get_real_cyc(void)
Definition: papi.c:6217
int PAPI_start(int EventSet)
Definition: papi.c:2096
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
long long elapsed_us
Definition: zero_fork.c:50
#define PAPI_VER_CURRENT
Definition: papi.h:225
int EventSet1
Definition: zero_fork.c:47
int PAPI_list_events(int EventSet, int *Events, int *number)
Definition: papi.c:6001

Here is the call graph for this function: