PAPI  5.3.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)
 

Variables

int TESTS_QUIET
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 21 of file zero_flip.c.

22 {
23  int retval, num_tests = 2, eventcnt, events[2], i, tmp;
25  int PAPI_event;
26  long long values1[2], values2[2];
27  long long elapsed_us, elapsed_cyc;
28  char event_name[PAPI_MAX_STR_LEN], add_event_str[PAPI_MAX_STR_LEN];
29 
30  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
31 
33  if ( retval != PAPI_VER_CURRENT )
34  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
35 
36  /* query and set up the right instruction to monitor */
38  PAPI_event = PAPI_FP_OPS;
39  else
40  PAPI_event = PAPI_TOT_INS;
41 
42  retval = PAPI_event_code_to_name( PAPI_event, event_name );
43  if ( retval != PAPI_OK )
44  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
45  sprintf( add_event_str, "PAPI_add_event[%s]", event_name );
46 
47  retval = PAPI_create_eventset( &EventSet1 );
48  if ( retval != PAPI_OK )
49  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
50 
51  /* Add the events */
52  printf( "Adding: %s\n", event_name );
53  retval = PAPI_add_event( EventSet1, PAPI_event );
54  if ( retval != PAPI_OK )
55  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
56 
57  retval = PAPI_add_event( EventSet1, PAPI_TOT_CYC );
58  if ( retval != PAPI_OK )
59  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
60 
61  /* Add them reversed to EventSet2 */
62 
63  retval = PAPI_create_eventset( &EventSet2 );
64  if ( retval != PAPI_OK )
65  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
66 
67  eventcnt = 2;
68  retval = PAPI_list_events( EventSet1, events, &eventcnt );
69  if ( retval != PAPI_OK )
70  test_fail( __FILE__, __LINE__, "PAPI_list_events", retval );
71 
72  for ( i = eventcnt - 1; i >= 0; i-- ) {
73  retval = PAPI_event_code_to_name( events[i], event_name );
74  if ( retval != PAPI_OK )
75  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
76 
77  retval = PAPI_add_event( EventSet2, events[i] );
78  if ( retval != PAPI_OK )
79  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
80  }
81 
82  elapsed_us = PAPI_get_real_usec( );
83 
84  elapsed_cyc = PAPI_get_real_cyc( );
85 
86  retval = PAPI_start( EventSet1 );
87  if ( retval != PAPI_OK )
88  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
89 
91 
92  retval = PAPI_stop( EventSet1, values1 );
93  if ( retval != PAPI_OK )
94  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
95 
96  retval = PAPI_start( EventSet2 );
97  if ( retval != PAPI_OK )
98  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
99 
100  do_flops( NUM_FLOPS );
101 
102  retval = PAPI_stop( EventSet2, values2 );
103  if ( retval != PAPI_OK )
104  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
105 
106  elapsed_us = PAPI_get_real_usec( ) - elapsed_us;
107 
108  elapsed_cyc = PAPI_get_real_cyc( ) - elapsed_cyc;
109 
110  retval = PAPI_cleanup_eventset( EventSet1 ); /* JT */
111  if ( retval != PAPI_OK )
112  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
113 
114  retval = PAPI_destroy_eventset( &EventSet1 );
115  if ( retval != PAPI_OK )
116  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
117 
118  retval = PAPI_cleanup_eventset( EventSet2 ); /* JT */
119  if ( retval != PAPI_OK )
120  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
121 
122  retval = PAPI_destroy_eventset( &EventSet2 );
123  if ( retval != PAPI_OK )
124  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
125 
126  if ( !TESTS_QUIET ) {
127  printf( "Test case 0: start, stop.\n" );
128  printf( "-----------------------------------------------\n" );
129  tmp = PAPI_get_opt( PAPI_DEFDOM, NULL );
130  printf( "Default domain is: %d (%s)\n", tmp,
131  stringify_all_domains( tmp ) );
132  tmp = PAPI_get_opt( PAPI_DEFGRN, NULL );
133  printf( "Default granularity is: %d (%s)\n", tmp,
134  stringify_granularity( tmp ) );
135  printf( "Using %d iterations of c += a*b\n", NUM_FLOPS );
136  printf
137  ( "-------------------------------------------------------------------------\n" );
138 
139  printf( "Test type : \t 1\t 2\n" );
140 
141  sprintf( add_event_str, "%-12s : \t", event_name );
142  printf( TAB2, add_event_str, values1[0], values2[1] );
143  printf( TAB2, "PAPI_TOT_CYC : \t", values1[1], values2[0] );
144  printf( TAB1, "Real usec : \t", elapsed_us );
145  printf( TAB1, "Real cycles : \t", elapsed_cyc );
146 
147  printf
148  ( "-------------------------------------------------------------------------\n" );
149 
150  printf( "Verification: none\n" );
151  }
152  test_pass( __FILE__, NULL, num_tests );
153  exit( 1 );
154 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2225
#define NUM_FLOPS
int PAPI_event[2]
Definition: data_range.c:24
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1597
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
char * stringify_granularity(int granularity)
Definition: test_utils.c:429
#define PAPI_TOT_INS
Definition: fpapi.h:185
#define TAB1
Definition: papi_test.h:112
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_FP_OPS
Definition: fpapi.h:237
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
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:495
int i
Definition: fileop.c:140
#define PAPI_TOT_CYC
Definition: fpapi.h:194
char * stringify_all_domains(int domains)
Definition: test_utils.c:369
#define TAB2
Definition: papi_test.h:113
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4030
long long elapsed_cyc
Definition: zero_fork.c:43
#define PAPI_DEFDOM
Definition: fpapi.h:49
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
char events[MAX_EVENTS][BUFSIZ]
#define PAPI_DEFGRN
Definition: fpapi.h:51
int EventSet2
Definition: rapl_overflow.c:12
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2795
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1399
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:920
int num_tests
Definition: zero_fork.c:46
void do_flops(int n)
Definition: multiplex.c:23
int PAPI_query_event(int EventCode)
Definition: papi.c:695
long long PAPI_get_real_usec(void)
Definition: papi.c:6125
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1937
long long PAPI_get_real_cyc(void)
Definition: papi.c:6078
int PAPI_start(int EventSet)
Definition: papi.c:2019
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
long long elapsed_us
Definition: zero_fork.c:43
void exit()
int EventSet1
Definition: zero_fork.c:40
int PAPI_list_events(int EventSet, int *Events, int *number)
Definition: papi.c:5863

Here is the call graph for this function:

Variable Documentation

int TESTS_QUIET

Definition at line 11 of file test_utils.c.