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.

00013 {
00014     if ( CLOCK_ERROR )
00015         return;
00016 
00017     long long *elapsed_cyc, total_cyc = 0, uniq_cyc = 0, diff_cyc = 0;
00018     int i;
00019     double min, max, average, std, tmp;
00020 
00021     elapsed_cyc = ( long long * ) calloc( NUM_ITERS, sizeof ( long long ) );
00022 
00023     /* Real */
00024     switch ( flag ) {
00025     case 0:
00026         for ( i = 0; i < NUM_ITERS; i++ )
00027             elapsed_cyc[i] = ( long long ) PAPI_get_real_cyc(  );
00028         break;
00029     case 1:
00030         for ( i = 0; i < NUM_ITERS; i++ )
00031             elapsed_cyc[i] = ( long long ) PAPI_get_real_usec(  );
00032         break;
00033     case 2:
00034         for ( i = 0; i < NUM_ITERS; i++ )
00035             elapsed_cyc[i] = ( long long ) PAPI_get_virt_cyc(  );
00036         break;
00037     case 3:
00038         for ( i = 0; i < NUM_ITERS; i++ )
00039             elapsed_cyc[i] = ( long long ) PAPI_get_virt_usec(  );
00040         break;
00041     default:
00042         test_fail( __FILE__, __LINE__, "clock_res_check", -1 );
00043 
00044     }
00045 
00046     min = max = ( double ) ( elapsed_cyc[1] - elapsed_cyc[0] );
00047 
00048     for ( i = 1; i < NUM_ITERS; i++ ) {
00049         if ( elapsed_cyc[i] - elapsed_cyc[i - 1] < 0 ) {
00050             CLOCK_ERROR = 1;
00051             test_fail( __FILE__, __LINE__, "Negative elapsed time", -1 );
00052             free( elapsed_cyc );
00053             return;
00054         }
00055 
00056         diff_cyc = elapsed_cyc[i] - elapsed_cyc[i - 1];
00057         if ( min > diff_cyc )
00058             min = ( double ) diff_cyc;
00059         if ( max < diff_cyc )
00060             max = ( double ) diff_cyc;
00061         if ( diff_cyc != 0 )
00062             uniq_cyc++;
00063         total_cyc += diff_cyc;
00064     }
00065 
00066     average = ( double ) total_cyc / ( NUM_ITERS - 1 );
00067     std = 0;
00068 
00069     for ( i = 1; i < NUM_ITERS; i++ ) {
00070         tmp = ( double ) ( elapsed_cyc[i] - elapsed_cyc[i - 1] );
00071         tmp = tmp - average;
00072         std += tmp * tmp;
00073     }
00074 
00075     std = sqrt( std / ( NUM_ITERS - 2 ) );
00076     printf( "%s: min %.3lf  max %.3lf \n", func_name[flag], min, max );
00077     printf( "                   average %.3lf std %.3lf\n", average, std );
00078 
00079     if ( !TESTS_QUIET ) {
00080         if ( uniq_cyc == NUM_ITERS - 1 ) {
00081             printf( "%s : %7.3f   <%7.3f\n", func_name[flag],
00082                     ( double ) total_cyc / ( double ) ( NUM_ITERS ),
00083                     ( double ) total_cyc / ( double ) uniq_cyc );
00084         } else if ( uniq_cyc ) {
00085             printf( "%s : %7.3f    %7.3f\n", func_name[flag],
00086                     ( double ) total_cyc / ( double ) ( NUM_ITERS ),
00087                     ( double ) total_cyc / ( double ) uniq_cyc );
00088         } else {
00089             printf( "%s : %7.3f   >%7.3f\n", func_name[flag],
00090                     ( double ) total_cyc / ( double ) ( NUM_ITERS ),
00091                     ( double ) total_cyc );
00092         }
00093     }
00094 
00095     free( elapsed_cyc );
00096 }

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.

00100 {
00101     /* check PAPI_get_real_cyc */
00102     clock_res_check( 0 );
00103     /* check PAPI_get_real_usec */
00104     clock_res_check( 1 );
00105 
00106     /* check PAPI_get_virt_cyc */
00107     /* Virtual */
00108     if ( PAPI_get_virt_cyc(  ) != -1 ) {
00109         clock_res_check( 2 );
00110     } else
00111         test_fail( __FILE__, __LINE__, "PAPI_get_virt_cyc", -1 );
00112 
00113     /* check PAPI_get_virt_usec */
00114     if ( PAPI_get_virt_usec(  ) != -1 ) {
00115         clock_res_check( 3 );
00116     } else
00117         test_fail( __FILE__, __LINE__, "PAPI_get_virt_usec", -1 );
00118 }

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.


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1