PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tenth.c File Reference
Include dependency graph for tenth.c:

Go to the source code of this file.

Macros

#define ITERS   100
 
#define CACHE_LEVEL   "PAPI_L1_TCM"
 
#define EVT1   PAPI_L1_TCM
 
#define EVT2   PAPI_L1_ICM
 
#define EVT3   PAPI_L1_DCM
 
#define EVT1_STR   "PAPI_L1_TCM: "
 
#define EVT2_STR   "PAPI_L1_ICM: "
 
#define EVT3_STR   "PAPI_L1_DCM: "
 
#define MASK1   MASK_L1_TCM
 
#define MASK2   MASK_L1_ICM
 
#define MASK3   MASK_L1_DCM
 

Functions

int main (int argc, char **argv)
 

Variables

int TESTS_QUIET
 

Macro Definition Documentation

#define CACHE_LEVEL   "PAPI_L1_TCM"

Definition at line 46 of file tenth.c.

#define EVT1   PAPI_L1_TCM

Definition at line 47 of file tenth.c.

#define EVT1_STR   "PAPI_L1_TCM: "

Definition at line 50 of file tenth.c.

#define EVT2   PAPI_L1_ICM

Definition at line 48 of file tenth.c.

#define EVT2_STR   "PAPI_L1_ICM: "

Definition at line 51 of file tenth.c.

#define EVT3   PAPI_L1_DCM

Definition at line 49 of file tenth.c.

#define EVT3_STR   "PAPI_L1_DCM: "

Definition at line 52 of file tenth.c.

#define ITERS   100

Definition at line 6 of file tenth.c.

#define MASK1   MASK_L1_TCM

Definition at line 53 of file tenth.c.

#define MASK2   MASK_L1_ICM

Definition at line 54 of file tenth.c.

#define MASK3   MASK_L1_DCM

Definition at line 55 of file tenth.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 64 of file tenth.c.

65 {
66  int retval, num_tests = 30, tmp;
67  int EventSet1 = PAPI_NULL;
68  int EventSet2 = PAPI_NULL;
69  int EventSet3 = PAPI_NULL;
70  int mask1 = MASK1;
71  int mask2 = MASK2;
72  int mask3 = MASK3;
73  int num_events1;
74  int num_events2;
75  int num_events3;
76  long long **values;
77  int i, j;
78  long long min[3];
79  long long max[3];
80  long long sum[3];
81 
82  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
83 
85  if ( retval != PAPI_VER_CURRENT )
86  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
87 
88  /* Make sure that required resources are available */
89  /* Skip (don't fail!) if they are not */
90  retval = PAPI_query_event( EVT1 );
91  if ( retval != PAPI_OK )
92  test_skip( __FILE__, __LINE__, EVT1_STR, retval );
93 
94  retval = PAPI_query_event( EVT2 );
95  if ( retval != PAPI_OK )
96  test_skip( __FILE__, __LINE__, EVT2_STR, retval );
97 
98  retval = PAPI_query_event( EVT3 );
99  if ( retval != PAPI_OK )
100  test_skip( __FILE__, __LINE__, EVT3_STR, retval );
101 
102 
103  EventSet1 = add_test_events( &num_events1, &mask1, 1 );
104  EventSet2 = add_test_events( &num_events2, &mask2, 1 );
105  EventSet3 = add_test_events( &num_events3, &mask3, 1 );
106 
107  values = allocate_test_space( num_tests, 1 );
108 
109  /* Warm me up */
110  do_l1misses( ITERS );
111  do_misses( 1, 1024 * 1024 * 4 );
112 
113  for ( i = 0; i < 10; i++ ) {
114  retval = PAPI_start( EventSet1 );
115  if ( retval != PAPI_OK )
116  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
117 
118  do_l1misses( ITERS );
119  do_misses( 1, 1024 * 1024 * 4 );
120 
121  retval = PAPI_stop( EventSet1, values[( i * 3 ) + 0] );
122  if ( retval != PAPI_OK )
123  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
124 
125  retval = PAPI_start( EventSet2 );
126  if ( retval != PAPI_OK )
127  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
128 
129  do_l1misses( ITERS );
130  do_misses( 1, 1024 * 1024 * 4 );
131 
132  retval = PAPI_stop( EventSet2, values[( i * 3 ) + 1] );
133  if ( retval != PAPI_OK )
134  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
135 
136  retval = PAPI_start( EventSet3 );
137  if ( retval != PAPI_OK )
138  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
139 
140  do_l1misses( ITERS );
141  do_misses( 1, 1024 * 1024 * 4 );
142 
143  retval = PAPI_stop( EventSet3, values[( i * 3 ) + 2] );
144  if ( retval != PAPI_OK )
145  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
146  }
147 
148  remove_test_events( &EventSet1, mask1 );
149  remove_test_events( &EventSet2, mask2 );
150  remove_test_events( &EventSet3, mask3 );
151 
152  for ( j = 0; j < 3; j++ ) {
153  min[j] = 65535;
154  max[j] = sum[j] = 0;
155  }
156  for ( i = 0; i < 10; i++ ) {
157  for ( j = 0; j < 3; j++ ) {
158  if ( min[j] > values[( i * 3 ) + j][0] )
159  min[j] = values[( i * 3 ) + j][0];
160  if ( max[j] < values[( i * 3 ) + j][0] )
161  max[j] = values[( i * 3 ) + j][0];
162  sum[j] += values[( i * 3 ) + j][0];
163  }
164  }
165 
166  if ( !TESTS_QUIET ) {
167  printf( "Test case 10: start, stop for derived event %s.\n",
168  CACHE_LEVEL );
169  printf( "--------------------------------------------------------\n" );
170  tmp = PAPI_get_opt( PAPI_DEFDOM, NULL );
171  printf( "Default domain is: %d (%s)\n", tmp,
173  tmp = PAPI_get_opt( PAPI_DEFGRN, NULL );
174  printf( "Default granularity is: %d (%s)\n", tmp,
176  printf( "Using %d iterations of c += a*b\n", ITERS );
177  printf( "Repeated 10 times\n" );
178  printf
179  ( "-------------------------------------------------------------------------\n" );
180 /*
181  for (i=0;i<10;i++) {
182  printf("Test type : %12s%13s%13s\n", "1", "2", "3");
183  printf(TAB3, EVT1_STR, values[(i*3)+0][0], (long long)0, (long long)0);
184  printf(TAB3, EVT2_STR, (long long)0, values[(i*3)+1][0], (long long)0);
185  printf(TAB3, EVT3_STR, (long long)0, (long long)0, values[(i*3)+2][0]);
186  printf
187  ("-------------------------------------------------------------------------\n");
188  }
189 */
190  printf( "Test type : %12s%13s%13s\n", "min", "max", "sum" );
191  printf( TAB3, EVT1_STR, min[0], max[0], sum[0] );
192  printf( TAB3, EVT2_STR, min[1], max[1], sum[1] );
193  printf( TAB3, EVT3_STR, min[2], max[2], sum[2] );
194  printf
195  ( "-------------------------------------------------------------------------\n" );
196  printf( "Verification:\n" );
197 #if defined(sun) && defined(sparc)
198  printf( TAB1, "Sum 1 approximately equals sum 2 - sum 3 or",
199  ( sum[1] - sum[2] ) );
200 #else
201  printf( TAB1, "Sum 1 approximately equals sum 2 + sum 3 or",
202  ( sum[1] + sum[2] ) );
203 #endif
204  }
205 
206  {
207  long long tmin, tmax;
208 
209 #if defined(sun) && defined(sparc)
210  tmax = ( long long ) ( sum[1] - sum[2] );
211 #else
212  tmax = ( long long ) ( sum[1] + sum[2] );
213 #endif
214 
215  printf( "percent error: %f\n",
216  ( float ) ( abs( ( int ) ( tmax - sum[0] ) ) * 100 / sum[0] ) );
217  tmin = ( long long ) ( ( double ) tmax * 0.8 );
218  tmax = ( long long ) ( ( double ) tmax * 1.2 );
219  if ( sum[0] > tmax || sum[0] < tmin )
220  test_fail( __FILE__, __LINE__, CACHE_LEVEL, 1 );
221  }
222  test_pass( __FILE__, values, num_tests );
223  exit( 1 );
224 }
#define EVT3_STR
Definition: tenth.c:52
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2225
int mask1
Definition: zero_fork.c:41
#define EVT2_STR
Definition: tenth.c:51
off64_t max
Definition: libasync.c:331
#define EVT2
Definition: tenth.c:48
#define MASK2
Definition: tenth.c:54
#define EVT1_STR
Definition: tenth.c:50
#define MASK1
Definition: tenth.c:53
#define PAPI_NULL
Definition: fpapi.h:13
#define EVT3
Definition: tenth.c:49
char * stringify_granularity(int granularity)
Definition: test_utils.c:429
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
#define TAB3
Definition: papi_test.h:114
int num_events1
Definition: zero_fork.c:42
#define TAB1
Definition: papi_test.h:112
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
void do_l1misses(int n)
Definition: do_loops.c:213
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
char * stringify_all_domains(int domains)
Definition: test_utils.c:369
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4030
void do_misses(int n, int bytes)
Definition: do_loops.c:113
#define PAPI_DEFDOM
Definition: fpapi.h:49
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
long long
Definition: iozone.c:19827
#define min(x, y)
Definition: darwin-common.h:4
#define PAPI_DEFGRN
Definition: fpapi.h:51
int EventSet2
Definition: rapl_overflow.c:12
#define EVT1
Definition: tenth.c:47
int num_tests
Definition: zero_fork.c:46
#define ITERS
Definition: tenth.c:6
int PAPI_query_event(int EventCode)
Definition: papi.c:695
#define MASK3
Definition: tenth.c:55
int PAPI_start(int EventSet)
Definition: papi.c:2019
long j
Definition: iozone.c:19135
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:107
void exit()
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:277
#define CACHE_LEVEL
Definition: tenth.c:46
int add_test_events(int *number, int *mask, int allow_derived)
Definition: test_utils.c:213
int EventSet1
Definition: zero_fork.c:40

Here is the call graph for this function:

Variable Documentation

int TESTS_QUIET

Definition at line 11 of file test_utils.c.