PAPI  5.6.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.

Macros

#define NUM_ITERS   1000000
 

Functions

static int clock_res_check (int flag, int quiet)
 
int clockcore (int quiet)
 

Variables

static char * func_name []
 
static int CLOCK_ERROR = 0
 

Macro Definition Documentation

#define NUM_ITERS   1000000

Definition at line 9 of file clockcore.c.

Function Documentation

static int clock_res_check ( int  flag,
int  quiet 
)
static

Definition at line 20 of file clockcore.c.

21 {
22  if ( CLOCK_ERROR ) {
23  return -1;
24  }
25 
26  long long *elapsed_cyc, total_cyc = 0, uniq_cyc = 0, diff_cyc = 0;
27  int i;
28  double min, max, average, std, tmp;
29 
30  elapsed_cyc = ( long long * ) calloc( NUM_ITERS, sizeof ( long long ) );
31 
32  /* Real */
33  switch ( flag ) {
34  case 0:
35  for ( i = 0; i < NUM_ITERS; i++ )
36  elapsed_cyc[i] = ( long long ) PAPI_get_real_cyc( );
37  break;
38  case 1:
39  for ( i = 0; i < NUM_ITERS; i++ )
40  elapsed_cyc[i] = ( long long ) PAPI_get_real_usec( );
41  break;
42  case 2:
43  for ( i = 0; i < NUM_ITERS; i++ )
44  elapsed_cyc[i] = ( long long ) PAPI_get_virt_cyc( );
45  break;
46  case 3:
47  for ( i = 0; i < NUM_ITERS; i++ )
48  elapsed_cyc[i] = ( long long ) PAPI_get_virt_usec( );
49  break;
50  default:
51  return -1;
52 
53  }
54 
55  min = max = ( double ) ( elapsed_cyc[1] - elapsed_cyc[0] );
56 
57  for ( i = 1; i < NUM_ITERS; i++ ) {
58  if ( elapsed_cyc[i] - elapsed_cyc[i - 1] < 0 ) {
59  CLOCK_ERROR = 1;
60  fprintf(stderr,"Error! Negative elapsed time\n");
61  free( elapsed_cyc );
62  return -1;
63  }
64 
65  diff_cyc = elapsed_cyc[i] - elapsed_cyc[i - 1];
66  if ( min > diff_cyc )
67  min = ( double ) diff_cyc;
68  if ( max < diff_cyc )
69  max = ( double ) diff_cyc;
70  if ( diff_cyc != 0 )
71  uniq_cyc++;
72  total_cyc += diff_cyc;
73  }
74 
75  average = ( double ) total_cyc / ( NUM_ITERS - 1 );
76  std = 0;
77 
78  for ( i = 1; i < NUM_ITERS; i++ ) {
79  tmp = ( double ) ( elapsed_cyc[i] - elapsed_cyc[i - 1] );
80  tmp = tmp - average;
81  std += tmp * tmp;
82  }
83 
84  if ( !quiet ) {
85  std = sqrt( std / ( NUM_ITERS - 2 ) );
86  printf( "%s: min %.3lf max %.3lf \n", func_name[flag], min, max );
87  printf( " average %.3lf std %.3lf\n", average, std );
88 
89  if ( uniq_cyc == NUM_ITERS - 1 ) {
90  printf( "%s : %7.3f <%7.3f\n", func_name[flag],
91  ( double ) total_cyc / ( double ) ( NUM_ITERS ),
92  ( double ) total_cyc / ( double ) uniq_cyc );
93  } else if ( uniq_cyc ) {
94  printf( "%s : %7.3f %7.3f\n", func_name[flag],
95  ( double ) total_cyc / ( double ) ( NUM_ITERS ),
96  ( double ) total_cyc / ( double ) uniq_cyc );
97  } else {
98  printf( "%s : %7.3f >%7.3f\n", func_name[flag],
99  ( double ) total_cyc / ( double ) ( NUM_ITERS ),
100  ( double ) total_cyc );
101  }
102  }
103 
104  free( elapsed_cyc );
105 
106  return PAPI_OK;
107 }
off64_t max
Definition: libasync.c:331
static int CLOCK_ERROR
Definition: clockcore.c:17
long long PAPI_get_virt_usec(void)
Definition: papi.c:6372
#define NUM_ITERS
Definition: clockcore.c:9
long long PAPI_get_virt_cyc(void)
Definition: papi.c:6300
static char * func_name[]
Definition: clockcore.c:11
return PAPI_OK
Definition: linux-nvml.c:497
static double
Definition: fileop.c:1281
int i
Definition: fileop.c:140
int quiet
Definition: rapl_overflow.c:18
long long elapsed_cyc
Definition: zero_fork.c:50
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:6264
printf("\tTry: -i 0 -i 1 \n\n")
long long PAPI_get_real_cyc(void)
Definition: papi.c:6217
long long tmp
Definition: iozone.c:12031

Here is the call graph for this function:

Here is the caller graph for this function:

int clockcore ( int  quiet)

Definition at line 110 of file clockcore.c.

111 {
112  /* check PAPI_get_real_cyc */
113  clock_res_check( 0, quiet );
114  /* check PAPI_get_real_usec */
115  clock_res_check( 1, quiet );
116 
117  /* check PAPI_get_virt_cyc */
118  /* Virtual */
119  if ( PAPI_get_virt_cyc( ) != -1 ) {
120  clock_res_check( 2, quiet );
121  } else {
123  }
124 
125  /* check PAPI_get_virt_usec */
126  if ( PAPI_get_virt_usec( ) != -1 ) {
127  clock_res_check( 3, quiet );
128  } else {
130  }
131 
132  return PAPI_OK;
133 }
long long PAPI_get_virt_usec(void)
Definition: papi.c:6372
long long PAPI_get_virt_cyc(void)
Definition: papi.c:6300
#define CLOCKCORE_VIRT_USEC_FAIL
Definition: clockcore.h:2
static int clock_res_check(int flag, int quiet)
Definition: clockcore.c:20
return PAPI_OK
Definition: linux-nvml.c:497
#define CLOCKCORE_VIRT_CYC_FAIL
Definition: clockcore.h:1
int quiet
Definition: rapl_overflow.c:18

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 17 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 11 of file clockcore.c.