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

Go to the source code of this file.

Macros

#define REPEATS   5
 
#define MAXEVENTS   14
 
#define SLEEPTIME   100
 
#define MINCOUNTS   100000
 

Functions

static double dummy3 (double x, int iters)
 
void check_values (int eventset, int *events, int nevents, long long *values, long long *refvalues)
 
void ref_measurements (int iters, int *eventset, int *events, int nevents, long long *refvalues)
 
void decide_which_events (int *events, int *nevents)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

#define MAXEVENTS   14

Definition at line 16 of file sdsc.c.

#define MINCOUNTS   100000

Definition at line 18 of file sdsc.c.

#define REPEATS   5

Definition at line 15 of file sdsc.c.

#define SLEEPTIME   100

Definition at line 17 of file sdsc.c.

Function Documentation

void check_values ( int  eventset,
int events,
int  nevents,
long long values,
long long refvalues 
)

Definition at line 23 of file sdsc.c.

25 {
26  double spread[MAXEVENTS];
27  int i = nevents, j = 0;
28 
29  if ( !TESTS_QUIET ) {
30  printf( "\nRelative accuracy:\n" );
31  for ( j = 0; j < nevents; j++ )
32  printf( " Event %.2d", j + 1 );
33  printf( "\n" );
34  }
35 
36  for ( j = 0; j < nevents; j++ ) {
37  spread[j] = abs( (int) ( refvalues[j] - values[j] ) );
38  if ( values[j] )
39  spread[j] /= ( double ) values[j];
40  if ( !TESTS_QUIET )
41  printf( "%10.3g ", spread[j] );
42  /* Make sure that NaN get counted as errors */
43  if ( spread[j] < MPX_TOLERANCE ) {
44  i--;
45  }
46  else if ( refvalues[j] < MINCOUNTS ) { /* Neglect inprecise results with low counts */
47  i--;
48  }
49  else {
50  char buff[BUFSIZ];
51 
52  printf("reference = %lld, value = %lld, diff = %lld\n",
53  refvalues[j],values[j],refvalues[j] - values[j] );
54  sprintf(buff,"Error on %d, spread %lf > threshold %lf AND count %lld > minimum size threshold %d\n",j,spread[j],MPX_TOLERANCE,
55  refvalues[j],MINCOUNTS);
56 
57  test_fail( __FILE__, __LINE__, buff, 1 );
58  }
59  }
60  printf( "\n\n" );
61 #if 0
62  if ( !TESTS_QUIET ) {
63  for ( j = 0; j < nevents; j++ ) {
64  PAPI_get_event_info( events[j], &info );
65  printf( "Event %.2d: ref=", j );
66  printf( LLDFMT10, refvalues[j] );
67  printf( ", diff/ref=%7.2g -- %s\n", spread[j], info.short_descr );
68  printf( "\n" );
69  }
70  printf( "\n" );
71  }
72 #else
73  ( void ) eventset;
74  ( void ) events;
75 #endif
76 
77 
78 }
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
void
Definition: iozone.c:18627
#define printf
Definition: papi_test.h:125
static double
Definition: fileop.c:1281
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:844
#define LLDFMT10
Definition: papi_test.h:119
int TESTS_QUIET
Definition: test_utils.c:11
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int i
Definition: fileop.c:140
#define MINCOUNTS
Definition: sdsc.c:18
#define MAXEVENTS
Definition: sdsc.c:16
char events[MAX_EVENTS][BUFSIZ]
#define MPX_TOLERANCE
Definition: test_utils.h:15
long j
Definition: iozone.c:19135
static long long values[NUM_EVENTS]
Definition: init_fini.c:10

Here is the call graph for this function:

Here is the caller graph for this function:

void decide_which_events ( int events,
int nevents 
)

Definition at line 127 of file sdsc.c.

128 {
129  int i, j = 0;
130  PAPI_event_info_t info;
131  int newevents[MAXEVENTS];
132 
133  for ( i = 0; i < MAXEVENTS; i++ ) {
134  if ( PAPI_get_event_info( events[i], &info ) == PAPI_OK ) {
135  if ( info.count && ( strcmp( info.derived, "NOT_DERIVED" ) == 0 ) ) {
136  printf( "Added %s\n", info.symbol );
137  newevents[j++] = events[i];
138  }
139  }
140  }
141 
142  if ( j < 2 )
143  test_skip( __FILE__, __LINE__, "Not enough events to multiplex...", 0 );
144  *nevents = j;
145  memcpy( events, newevents, sizeof ( newevents ) );
146 
147  printf( "Using %d events\n\n", *nevents );
148 }
unsigned int count
Definition: papi.h:982
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:961
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:844
int i
Definition: fileop.c:140
#define MAXEVENTS
Definition: sdsc.c:16
char events[MAX_EVENTS][BUFSIZ]
long j
Definition: iozone.c:19135
char derived[PAPI_MIN_STR_LEN]
Definition: papi.h:990

Here is the call graph for this function:

Here is the caller graph for this function:

static double dummy3 ( double  x,
int  iters 
)
static

Definition at line 298 of file sdsc.c.

299 {
300  int i;
301  double w, y, z, a, b, c, d, e, f, g, h;
302  double one;
303  one = 1.0;
304  w = x;
305  y = x;
306  z = x;
307  a = x;
308  b = x;
309  c = x;
310  d = x;
311  e = x;
312  f = x;
313  g = x;
314  h = x;
315  for ( i = 1; i <= iters; i++ ) {
316  w = w * 1.000000000001 + one;
317  y = y * 1.000000000002 + one;
318  z = z * 1.000000000003 + one;
319  a = a * 1.000000000004 + one;
320  b = b * 1.000000000005 + one;
321  c = c * 0.999999999999 + one;
322  d = d * 0.999999999998 + one;
323  e = e * 0.999999999997 + one;
324  f = f * 0.999999999996 + one;
325  g = h * 0.999999999995 + one;
326  h = h * 1.000000000006 + one;
327  }
328  return 2.0 * ( a + b + c + d + e + f + w + x + y + z + g + h );
329 }
double f(double a)
Definition: cpi.c:23
double c
Definition: multiplex.c:22
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:37
long long y
Definition: iozone.c:1335
int i
Definition: fileop.c:140
int one
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:38
int x
Definition: fileop.c:78

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 151 of file sdsc.c.

152 {
153  PAPI_event_info_t info;
154  int i, j, retval;
155  int iters = NUM_FLOPS;
156  double x = 1.1, y;
157  long long t1, t2;
158  long long values[MAXEVENTS], refvalues[MAXEVENTS];
159  int sleep_time = SLEEPTIME;
160  int nevents = MAXEVENTS;
161  int eventset = PAPI_NULL;
162  int events[MAXEVENTS];
163 
164  events[0] = PAPI_FP_INS;
165  events[1] = PAPI_TOT_INS;
166  events[2] = PAPI_INT_INS;
167  events[3] = PAPI_TOT_CYC;
168  events[4] = PAPI_STL_CCY;
169  events[5] = PAPI_BR_INS;
170  events[6] = PAPI_SR_INS;
171  events[7] = PAPI_LD_INS;
172  events[8] = PAPI_TOT_IIS;
173  events[9] = PAPI_FAD_INS;
174  events[10] = PAPI_BR_TKN;
175  events[11] = PAPI_BR_MSP;
176  events[12] = PAPI_L1_ICA;
177  events[13] = PAPI_L1_DCA;
178 
179  for ( i = 0; i < MAXEVENTS; i++ ) {
180  values[i] = 0;
181  }
182 
183  if ( argc > 1 ) {
184  if ( !strcmp( argv[1], "TESTS_QUIET" ) )
185  tests_quiet( argc, argv );
186  else {
187  sleep_time = atoi( argv[1] );
188  if ( sleep_time <= 0 )
189  sleep_time = SLEEPTIME;
190  }
191  }
192 
193  if ( !TESTS_QUIET ) {
194  printf( "\nAccuracy check of multiplexing routines.\n" );
195  printf
196  ( "Comparing a multiplex measurement with separate measurements.\n\n" );
197  }
198 
199  if ( ( retval =
201  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
202 
203  decide_which_events( events, &nevents );
204 
205  init_multiplex( );
206 
207  /* Find a reasonable number of iterations (each
208  * event active 20 times) during the measurement
209  */
210  t2 = 10000 * 20 * nevents; /* Target: 10000 usec/multiplex, 20 repeats */
211  if ( t2 > 30e6 )
212  test_skip( __FILE__, __LINE__, "This test takes too much time",
213  retval );
214 
215  y = dummy3( x, iters );
216  /* Measure one run */
217  t1 = PAPI_get_real_usec( );
218  y = dummy3( x, iters );
219  t1 = PAPI_get_real_usec( ) - t1;
220 
221  if ( t1 < 1000000 ) { /* Scale up execution time to match t2 */
222  iters = iters * ( int ) ( 1000000 / t1 );
223  printf( "Modified iteration count to %d\n\n", iters );
224  }
225 
226  if (!TESTS_QUIET) fprintf(stdout,"y=%lf\n",y);
227 
228  /* Now loop through the items one at a time */
229 
230  ref_measurements( iters, &eventset, events, nevents, refvalues );
231 
232  /* Now check multiplexed */
233 
234  if ( ( retval = PAPI_create_eventset( &eventset ) ) )
235  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
236 
237 
238  /* In Component PAPI, EventSets must be assigned a component index
239  before you can fiddle with their internals.
240  0 is always the cpu component */
241  retval = PAPI_assign_eventset_component( eventset, 0 );
242  if ( retval != PAPI_OK )
243  test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component",
244  retval );
245 
246  if ( ( retval = PAPI_set_multiplex( eventset ) ) ) {
247  if ( retval == PAPI_ENOSUPP) {
248  test_skip(__FILE__, __LINE__, "Multiplex not supported", 1);
249  }
250 
251  test_fail( __FILE__, __LINE__, "PAPI_set_multiplex", retval );
252  }
253 
254  if ( ( retval = PAPI_add_events( eventset, events, nevents ) ) )
255  test_fail( __FILE__, __LINE__, "PAPI_add_events", retval );
256 
257  printf( "\nPAPI multiplexed measurements:\n" );
258  x = 1.0;
259  t1 = PAPI_get_real_usec( );
260  if ( ( retval = PAPI_start( eventset ) ) )
261  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
262  y = dummy3( x, iters );
263  if ( ( retval = PAPI_stop( eventset, values ) ) )
264  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
265  t2 = PAPI_get_real_usec( );
266 
267  for ( j = 0; j < nevents; j++ ) {
268  PAPI_get_event_info( events[j], &info );
269  if ( !TESTS_QUIET ) {
270  printf( "%20s = ", info.short_descr );
271  printf( LLDFMT, values[j] );
272  printf( "\n" );
273  }
274  }
275 
276  check_values( eventset, events, nevents, values, refvalues );
277 
278  if ( ( retval = PAPI_remove_events( eventset, events, nevents ) ) )
279  test_fail( __FILE__, __LINE__, "PAPI_remove_events", retval );
280  if ( ( retval = PAPI_cleanup_eventset( eventset ) ) )
281  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
282  if ( ( retval = PAPI_destroy_eventset( &eventset ) ) )
283  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
284  eventset = PAPI_NULL;
285 
286  /* Now loop through the items one at a time */
287 
288  ref_measurements( iters, &eventset, events, nevents, refvalues );
289 
290  check_values( eventset, events, nevents, values, refvalues );
291 
292  test_pass( __FILE__, NULL, 0 );
293 
294  return 0;
295 }
#define PAPI_INT_INS
Definition: fpapi.h:186
int atoi()
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
#define NUM_FLOPS
#define PAPI_LD_INS
Definition: fpapi.h:188
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_L1_ICA
Definition: fpapi.h:211
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
#define PAPI_TOT_INS
Definition: fpapi.h:185
return PAPI_OK
Definition: linux-nvml.c:458
volatile double t2
tests_quiet(argc, argv)
int PAPI_remove_events(int EventSet, int *Events, int number)
Definition: papi.c:5807
#define printf
Definition: papi_test.h:125
volatile double t1
void init_multiplex(void)
Definition: test_utils.c:888
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int PAPI_add_events(int EventSet, int *Events, int number)
Definition: papi.c:5720
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:844
#define PAPI_BR_INS
Definition: fpapi.h:190
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
long long y
Definition: iozone.c:1335
int i
Definition: fileop.c:140
#define PAPI_ENOSUPP
Definition: fpapi.h:123
#define PAPI_TOT_CYC
Definition: fpapi.h:194
#define PAPI_SR_INS
Definition: fpapi.h:189
#define MAXEVENTS
Definition: sdsc.c:16
char short_descr[PAPI_MIN_STR_LEN]
Definition: papi.h:962
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
static double dummy3(double x, int iters)
Definition: sdsc.c:298
char events[MAX_EVENTS][BUFSIZ]
#define PAPI_BR_MSP
Definition: fpapi.h:181
#define PAPI_FP_INS
Definition: fpapi.h:187
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_assign_eventset_component(int EventSet, int cidx)
Definition: papi.c:1467
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
#define PAPI_BR_TKN
Definition: fpapi.h:179
#define PAPI_FAD_INS
Definition: fpapi.h:233
#define LLDFMT
Definition: papi_test.h:118
#define PAPI_TOT_IIS
Definition: fpapi.h:184
long long PAPI_get_real_usec(void)
Definition: papi.c:6138
int
Definition: iozone.c:18528
int x
Definition: fileop.c:78
#define PAPI_STL_CCY
Definition: fpapi.h:174
#define SLEEPTIME
Definition: sdsc.c:17
int PAPI_set_multiplex(int EventSet)
Definition: papi.c:3241
void check_values(int eventset, int *events, int nevents, long long *values, long long *refvalues)
Definition: sdsc.c:23
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
int PAPI_start(int EventSet)
Definition: papi.c:2026
long j
Definition: iozone.c:19135
void decide_which_events(int *events, int *nevents)
Definition: sdsc.c:127
void ref_measurements(int iters, int *eventset, int *events, int nevents, long long *refvalues)
Definition: sdsc.c:81
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
#define PAPI_L1_DCA
Definition: fpapi.h:199

Here is the call graph for this function:

void ref_measurements ( int  iters,
int eventset,
int events,
int  nevents,
long long refvalues 
)

Definition at line 81 of file sdsc.c.

83 {
84  PAPI_event_info_t info;
85  int i, retval;
86  double x = 1.1, y;
87  long long t1, t2;
88 
89  printf( "PAPI reference measurements:\n" );
90 
91  if ( ( retval = PAPI_create_eventset( eventset ) ) )
92  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
93 
94  for ( i = 0; i < nevents; i++ ) {
95  if ( ( retval = PAPI_add_event( *eventset, events[i] ) ) )
96  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
97 
98  x = 1.0;
99 
100  t1 = PAPI_get_real_usec( );
101  if ( ( retval = PAPI_start( *eventset ) ) )
102  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
103  y = dummy3( x, iters );
104  if ( ( retval = PAPI_stop( *eventset, &refvalues[i] ) ) )
105  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
106  t2 = PAPI_get_real_usec( );
107 
108  if (!TESTS_QUIET) {
109  printf( "\tOperations= %.1f Mflop", y * 1e-6 );
110  printf( "\t(%g Mflop/s)\n\n", ( ( float ) y / ( t2 - t1 ) ) );
111  }
112 
113  PAPI_get_event_info( events[i], &info );
114  printf( "%20s = ", info.short_descr );
115  printf( LLDFMT, refvalues[i] );
116  printf( "\n" );
117 
118  if ( ( retval = PAPI_cleanup_eventset( *eventset ) ) )
119  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
120  }
121  if ( ( retval = PAPI_destroy_eventset( eventset ) ) )
122  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
123  *eventset = PAPI_NULL;
124 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
#define PAPI_NULL
Definition: fpapi.h:13
volatile double t2
#define printf
Definition: papi_test.h:125
volatile double t1
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:844
int TESTS_QUIET
Definition: test_utils.c:11
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
long long y
Definition: iozone.c:1335
int i
Definition: fileop.c:140
char short_descr[PAPI_MIN_STR_LEN]
Definition: papi.h:962
static double dummy3(double x, int iters)
Definition: sdsc.c:298
char events[MAX_EVENTS][BUFSIZ]
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
#define LLDFMT
Definition: papi_test.h:118
long long PAPI_get_real_usec(void)
Definition: papi.c:6138
int x
Definition: fileop.c:78
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
int PAPI_start(int EventSet)
Definition: papi.c:2026
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function: