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

Go to the source code of this file.

Functions

void clock_res_check (int flag)
 
void clockcore (void)
 

Variables

static char * func_name []
 
static int CLOCK_ERROR = 0
 

Function Documentation

void clock_res_check ( int  flag)

Definition at line 12 of file clockcore.c.

13 {
14  if ( CLOCK_ERROR )
15  return;
16 
17  long long *elapsed_cyc, total_cyc = 0, uniq_cyc = 0, diff_cyc = 0;
18  int i;
19  double min, max, average, std, tmp;
20 
21  elapsed_cyc = ( long long * ) calloc( NUM_ITERS, sizeof ( long long ) );
22 
23  /* Real */
24  switch ( flag ) {
25  case 0:
26  for ( i = 0; i < NUM_ITERS; i++ )
27  elapsed_cyc[i] = ( long long ) PAPI_get_real_cyc( );
28  break;
29  case 1:
30  for ( i = 0; i < NUM_ITERS; i++ )
31  elapsed_cyc[i] = ( long long ) PAPI_get_real_usec( );
32  break;
33  case 2:
34  for ( i = 0; i < NUM_ITERS; i++ )
35  elapsed_cyc[i] = ( long long ) PAPI_get_virt_cyc( );
36  break;
37  case 3:
38  for ( i = 0; i < NUM_ITERS; i++ )
39  elapsed_cyc[i] = ( long long ) PAPI_get_virt_usec( );
40  break;
41  default:
42  test_fail( __FILE__, __LINE__, "clock_res_check", -1 );
43 
44  }
45 
46  min = max = ( double ) ( elapsed_cyc[1] - elapsed_cyc[0] );
47 
48  for ( i = 1; i < NUM_ITERS; i++ ) {
49  if ( elapsed_cyc[i] - elapsed_cyc[i - 1] < 0 ) {
50  CLOCK_ERROR = 1;
51  test_fail( __FILE__, __LINE__, "Negative elapsed time", -1 );
52  free( elapsed_cyc );
53  return;
54  }
55 
56  diff_cyc = elapsed_cyc[i] - elapsed_cyc[i - 1];
57  if ( min > diff_cyc )
58  min = ( double ) diff_cyc;
59  if ( max < diff_cyc )
60  max = ( double ) diff_cyc;
61  if ( diff_cyc != 0 )
62  uniq_cyc++;
63  total_cyc += diff_cyc;
64  }
65 
66  average = ( double ) total_cyc / ( NUM_ITERS - 1 );
67  std = 0;
68 
69  for ( i = 1; i < NUM_ITERS; i++ ) {
70  tmp = ( double ) ( elapsed_cyc[i] - elapsed_cyc[i - 1] );
71  tmp = tmp - average;
72  std += tmp * tmp;
73  }
74 
75  std = sqrt( std / ( NUM_ITERS - 2 ) );
76  printf( "%s: min %.3lf max %.3lf \n", func_name[flag], min, max );
77  printf( " average %.3lf std %.3lf\n", average, std );
78 
79  if ( !TESTS_QUIET ) {
80  if ( uniq_cyc == NUM_ITERS - 1 ) {
81  printf( "%s : %7.3f <%7.3f\n", func_name[flag],
82  ( double ) total_cyc / ( double ) ( NUM_ITERS ),
83  ( double ) total_cyc / ( double ) uniq_cyc );
84  } else if ( uniq_cyc ) {
85  printf( "%s : %7.3f %7.3f\n", func_name[flag],
86  ( double ) total_cyc / ( double ) ( NUM_ITERS ),
87  ( double ) total_cyc / ( double ) uniq_cyc );
88  } else {
89  printf( "%s : %7.3f >%7.3f\n", func_name[flag],
90  ( double ) total_cyc / ( double ) ( NUM_ITERS ),
91  ( double ) total_cyc );
92  }
93  }
94 
95  free( elapsed_cyc );
96 }
off64_t max
Definition: libasync.c:331
static int CLOCK_ERROR
Definition: clockcore.c:9
long long PAPI_get_virt_usec(void)
Definition: papi.c:6233
#define NUM_ITERS
Definition: multiplex.c:19
long long PAPI_get_virt_cyc(void)
Definition: papi.c:6161
static char * func_name[]
Definition: clockcore.c:3
#define printf
Definition: papi_test.h:125
static double
Definition: fileop.c:1281
int TESTS_QUIET
Definition: test_utils.c:11
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int i
Definition: fileop.c:140
long long elapsed_cyc
Definition: zero_fork.c:43
free(dummyfile[xx])
child_stat flag
Definition: iozone.c:12951
#define min(x, y)
Definition: darwin-common.h:4
long long PAPI_get_real_usec(void)
Definition: papi.c:6125
long long PAPI_get_real_cyc(void)
Definition: papi.c:6078
long long tmp
Definition: iozone.c:12031

Here is the call graph for this function:

Here is the caller graph for this function:

void clockcore ( void  )

Definition at line 99 of file clockcore.c.

100 {
101  /* check PAPI_get_real_cyc */
102  clock_res_check( 0 );
103  /* check PAPI_get_real_usec */
104  clock_res_check( 1 );
105 
106  /* check PAPI_get_virt_cyc */
107  /* Virtual */
108  if ( PAPI_get_virt_cyc( ) != -1 ) {
109  clock_res_check( 2 );
110  } else
111  test_fail( __FILE__, __LINE__, "PAPI_get_virt_cyc", -1 );
112 
113  /* check PAPI_get_virt_usec */
114  if ( PAPI_get_virt_usec( ) != -1 ) {
115  clock_res_check( 3 );
116  } else
117  test_fail( __FILE__, __LINE__, "PAPI_get_virt_usec", -1 );
118 }
long long PAPI_get_virt_usec(void)
Definition: papi.c:6233
long long PAPI_get_virt_cyc(void)
Definition: papi.c:6161
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
void clock_res_check(int flag)
Definition: clockcore.c:12

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int CLOCK_ERROR = 0
static

Definition at line 9 of file clockcore.c.

char* func_name[]
static
Initial value:
= {
"PAPI_get_real_cyc",
"PAPI_get_real_usec",
"PAPI_get_virt_cyc",
"PAPI_get_virt_usec"
}

Definition at line 3 of file clockcore.c.