PAPI 7.1.0.0
Loading...
Searching...
No Matches
cost_utils.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

double do_stats (long long *, long long *, long long *, double *)
 
void do_std_dev (long long *, int *, double, double)
 
void do_dist (long long *, long long, long long, int, int *)
 
int do_percentile (long long *a, long long *percent25, long long *percent50, long long *percent75, long long *percent99)
 

Variables

int num_iters
 

Function Documentation

◆ do_dist()

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

Definition at line 56 of file cost_utils.c.

57{
58 int i, j;
59 int dmax = 0;
60 int range = ( int ) ( max - min + 1 ); /* avoid edge conditions */
61
62 /* clear the distribution array */
63 for ( i = 0; i < bins; i++ ) {
64 d[i] = 0;
65 }
66
67 /* scan the array to distribute cost per bin */
68 for ( i = 0; i < num_iters; i++ ) {
69 j = ( ( int ) ( a[i] - min ) * bins ) / range;
70 d[j]++;
71 if ( j && ( dmax < d[j] ) )
72 dmax = d[j];
73 }
74
75 /* scale each bin to a max of 100 */
76 for ( i = 1; i < bins; i++ ) {
77 d[i] = ( d[i] * 100 ) / dmax;
78 }
79}
int i
int num_iters
Definition: cost_utils.c:8
#define min(x, y)
Definition: darwin-common.h:4
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:38
int
Definition: sde_internal.h:89
Here is the caller graph for this function:

◆ do_percentile()

int do_percentile ( long long a,
long long percent25,
long long percent50,
long long percent75,
long long percent99 
)

Definition at line 96 of file cost_utils.c.

100 {
101
102 long long *a_sort;
103 int i_25,i_50,i_75,i_99;
104
105 /* Allocate room for a copy of the results */
106 a_sort = calloc(num_iters,sizeof(long long));
107 if (a_sort==NULL) {
108 fprintf(stderr,"Memory allocation error!\n");
109 return -1;
110 }
111
112 /* Make a copy of the results */
113 memcpy(a_sort,a,num_iters*sizeof(long long));
114
115 /* Calculate indices */
116 i_25=(int)num_iters/4;
117 i_50=(int)num_iters/2;
118 // index for 75%, not quite accurate because it doesn't
119 // take even or odd into consideration
120 i_75=((int)num_iters*3)/4;
121 i_99=((int)num_iters*99)/100;
122
123 qsort(a_sort,num_iters-1,sizeof(long long),cmpfunc);
124
125 *percent25=a_sort[i_25];
126 *percent50=a_sort[i_50];
127 *percent75=a_sort[i_75];
128 *percent99=a_sort[i_99];
129
130 free(a_sort);
131
132 return 0;
133}
static int cmpfunc(const void *a, const void *b)
Definition: cost_utils.c:82
FILE * stderr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_stats()

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

Definition at line 12 of file cost_utils.c.

13{
14 int i;
15 double std, tmp;
16
17 *min = *max = array[0];
18 *average = 0;
19 for ( i = 0; i < num_iters; i++ ) {
20 *average += ( double ) array[i];
21 if ( *min > array[i] )
22 *min = array[i];
23 if ( *max < array[i] )
24 *max = array[i];
25 }
26 *average = *average / ( double ) num_iters;
27 std = 0;
28 for ( i = 0; i < num_iters; i++ ) {
29 tmp = ( double ) array[i] - ( *average );
30 std += tmp * tmp;
31 }
32 std = sqrt( std / ( num_iters - 1 ) );
33 return ( std );
34}
double tmp
static double array[ARRAYSIZE]
Definition: papi_l1_dca.c:23
Here is the caller graph for this function:

◆ do_std_dev()

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

Definition at line 37 of file cost_utils.c.

38{
39 int i, j;
40 double dev[10];
41
42 for ( i = 0; i < 10; i++ ) {
43 dev[i] = std * ( i + 1 );
44 s[i] = 0;
45 }
46
47 for ( i = 0; i < num_iters; i++ ) {
48 for ( j = 0; j < 10; j++ ) {
49 if ( ( ( double ) a[i] - dev[j] ) > ave )
50 s[j]++;
51 }
52 }
53}
double s
Definition: byte_profile.c:36
Here is the caller graph for this function:

Variable Documentation

◆ num_iters

int num_iters
extern

Definition at line 8 of file cost_utils.c.