cost_utils.c File Reference

Include dependency graph for cost_utils.c:

Go to the source code of this file.

Functions

double do_stats (long long *array, long long *min, long long *max, double *average)
void do_std_dev (long long *a, int *s, double std, double ave)
void do_dist (long long *a, long long min, long long max, int bins, int *d)

Variables

int num_iters = NUM_ITERS

Function Documentation

void do_dist ( long long *  a,
long long  min,
long long  max,
int  bins,
int *  d 
)

Definition at line 51 of file cost_utils.c.

00052 {
00053     int i, j;
00054     int dmax = 0;
00055     int range = ( int ) ( max - min + 1 );  /* avoid edge conditions */
00056 
00057     /* clear the distribution array */
00058     for ( i = 0; i < bins; i++ ) {
00059         d[i] = 0;
00060     }
00061 
00062     /* scan the array to distribute cost per bin */
00063     for ( i = 0; i < num_iters; i++ ) {
00064         j = ( ( int ) ( a[i] - min ) * bins ) / range;
00065         d[j]++;
00066         if ( j && ( dmax < d[j] ) )
00067             dmax = d[j];
00068     }
00069 
00070     /* scale each bin to a max of 100 */
00071     for ( i = 1; i < bins; i++ ) {
00072         d[i] = ( d[i] * 100 ) / dmax;
00073     }
00074 }

Here is the caller graph for this function:

double do_stats ( long long *  array,
long long *  min,
long long *  max,
double *  average 
)

Definition at line 7 of file cost_utils.c.

00008 {
00009     int i;
00010     double std, tmp;
00011 
00012     *min = *max = array[0];
00013     *average = 0;
00014     for ( i = 0; i < num_iters; i++ ) {
00015         *average += ( double ) array[i];
00016         if ( *min > array[i] )
00017             *min = array[i];
00018         if ( *max < array[i] )
00019             *max = array[i];
00020     }
00021     *average = *average / ( double ) num_iters;
00022     std = 0;
00023     for ( i = 0; i < num_iters; i++ ) {
00024         tmp = ( double ) array[i] - ( *average );
00025         std += tmp * tmp;
00026     }
00027     std = sqrt( std / ( num_iters - 1 ) );
00028     return ( std );
00029 }

Here is the caller graph for this function:

void do_std_dev ( long long *  a,
int *  s,
double  std,
double  ave 
)

Definition at line 32 of file cost_utils.c.

00033 {
00034     int i, j;
00035     double dev[10];
00036 
00037     for ( i = 0; i < 10; i++ ) {
00038         dev[i] = std * ( i + 1 );
00039         s[i] = 0;
00040     }
00041 
00042     for ( i = 0; i < num_iters; i++ ) {
00043         for ( j = 0; j < 10; j++ ) {
00044             if ( ( ( double ) a[i] - dev[j] ) > ave )
00045                 s[j]++;
00046         }
00047     }
00048 }

Here is the caller graph for this function:


Variable Documentation

int num_iters = NUM_ITERS

Definition at line 3 of file cost_utils.c.


Generated on 17 Nov 2016 for PAPI by  doxygen 1.6.1