PAPI 7.1.0.0
Loading...
Searching...
No Matches
flops_testcode.c File Reference
Include dependency graph for flops_testcode.c:

Go to the source code of this file.

Macros

#define ROWS   1000
 
#define COLUMNS   1000
 

Functions

int flops_float_init_matrix (void)
 
float flops_float_matrix_matrix_multiply (void)
 
float flops_float_swapped_matrix_matrix_multiply (void)
 
int flops_double_init_matrix (void)
 
double flops_double_matrix_matrix_multiply (void)
 
double flops_double_swapped_matrix_matrix_multiply (void)
 
double do_flops3 (double x, int iters, int quiet)
 
double do_flops (int n, int quiet)
 

Variables

static float float_matrixa [ROWS][COLUMNS]
 
static float float_matrixb [ROWS][COLUMNS]
 
static float float_mresult [ROWS][COLUMNS]
 
static double double_matrixa [ROWS][COLUMNS]
 
static double double_matrixb [ROWS][COLUMNS]
 
static double double_mresult [ROWS][COLUMNS]
 
volatile double a = 0.5
 
volatile double b = 2.2
 

Macro Definition Documentation

◆ COLUMNS

#define COLUMNS   1000

Definition at line 12 of file flops_testcode.c.

◆ ROWS

#define ROWS   1000

Definition at line 11 of file flops_testcode.c.

Function Documentation

◆ do_flops()

double do_flops ( int  n,
int  quiet 
)

Definition at line 184 of file flops_testcode.c.

185{
186 int i;
187 double c = 0.11;
188
189 for ( i = 0; i < n; i++ ) {
190 c += a * b;
191 }
192
193 if (!quiet) printf("%lf\n",c);
194
195 return c;
196}
int i
volatile double b
volatile double a
static double c[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:40
int quiet
Definition: rapl_overflow.c:19

◆ do_flops3()

double do_flops3 ( double  x,
int  iters,
int  quiet 
)

Definition at line 142 of file flops_testcode.c.

143{
144 int i;
145 double w, y, z, a, b, c, d, e, f, g, h;
146 double result;
147 double one;
148 one = 1.0;
149 w = x;
150 y = x;
151 z = x;
152 a = x;
153 b = x;
154 c = x;
155 d = x;
156 e = x;
157 f = x;
158 g = x;
159 h = x;
160 for ( i = 1; i <= iters; i++ ) {
161 w = w * 1.000000000001 + one;
162 y = y * 1.000000000002 + one;
163 z = z * 1.000000000003 + one;
164 a = a * 1.000000000004 + one;
165 b = b * 1.000000000005 + one;
166 c = c * 0.999999999999 + one;
167 d = d * 0.999999999998 + one;
168 e = e * 0.999999999997 + one;
169 f = f * 0.999999999996 + one;
170 g = h * 0.999999999995 + one;
171 h = h * 1.000000000006 + one;
172 }
173 result = 2.0 * ( a + b + c + d + e + f + w + x + y + z + g + h );
174
175 if (!quiet) printf("Result = %lf\n", result);
176
177 return result;
178}
volatile int result
double f(double a)
Definition: cpi.c:23
volatile double y
volatile double x
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flops_double_init_matrix()

int flops_double_init_matrix ( void  )

Definition at line 81 of file flops_testcode.c.

81 {
82
83 int i,j;
84
85 /* Initialize the Matrix arrays */
86 /* Non-optimail row major. Intentional? */
87 for ( i = 0; i < ROWS; i++ ) {
88 for ( j = 0; j < COLUMNS; j++) {
89 double_mresult[j][i] = 0.0;
90 double_matrixa[j][i] = ( double ) rand() * ( double ) 1.1;
91 double_matrixb[j][i] = ( double ) rand() * ( double ) 1.1;
92 }
93 }
94
95#if defined(__powerpc__)
96 /* has fused multiply-add */
97 return ROWS*ROWS*ROWS;
98#else
99 return ROWS*ROWS*ROWS*2;
100#endif
101
102}
#define COLUMNS
#define ROWS
static double double_mresult[ROWS][COLUMNS]
static double double_matrixb[ROWS][COLUMNS]
static double double_matrixa[ROWS][COLUMNS]
Here is the caller graph for this function:

◆ flops_double_matrix_matrix_multiply()

double flops_double_matrix_matrix_multiply ( void  )

Definition at line 104 of file flops_testcode.c.

104 {
105
106 int i,j,k;
107
108 /* Matrix-Matrix multiply */
109 for ( i = 0; i < ROWS; i++ ) {
110 for ( j = 0; j < COLUMNS; j++ ) {
111 for ( k = 0; k < COLUMNS; k++ ) {
113 }
114 }
115 }
116
117 return double_mresult[10][10];
118}
Here is the caller graph for this function:

◆ flops_double_swapped_matrix_matrix_multiply()

double flops_double_swapped_matrix_matrix_multiply ( void  )

Definition at line 120 of file flops_testcode.c.

120 {
121
122 int i, j, k;
123
124 /* Matrix-Matrix multiply */
125 /* With inner loops swapped */
126
127 for (i = 0; i < ROWS; i++) {
128 for (k = 0; k < COLUMNS; k++) {
129 for (j = 0; j < COLUMNS; j++) {
131 }
132 }
133 }
134 return double_mresult[10][10];
135}

◆ flops_float_init_matrix()

int flops_float_init_matrix ( void  )

Definition at line 23 of file flops_testcode.c.

23 {
24
25 int i,j;
26
27 /* Initialize the Matrix arrays */
28 /* Non-optimail row major. Intentional? */
29 for ( i = 0; i < ROWS; i++ ) {
30 for ( j = 0; j < COLUMNS; j++) {
31 float_mresult[j][i] = 0.0;
32 float_matrixa[j][i] = ( float ) rand() * ( float ) 1.1;
33 float_matrixb[j][i] = ( float ) rand() * ( float ) 1.1;
34 }
35 }
36
37#if defined(__powerpc__)
38 /* Has fused multiply-add */
39 return ROWS*ROWS*ROWS;
40#else
41 return ROWS*ROWS*ROWS*2;
42#endif
43
44}
static float float_matrixa[ROWS][COLUMNS]
static float float_matrixb[ROWS][COLUMNS]
static float float_mresult[ROWS][COLUMNS]
Here is the caller graph for this function:

◆ flops_float_matrix_matrix_multiply()

float flops_float_matrix_matrix_multiply ( void  )

Definition at line 46 of file flops_testcode.c.

46 {
47
48 int i,j,k;
49
50 /* Matrix-Matrix multiply */
51 for ( i = 0; i < ROWS; i++ ) {
52 for ( j = 0; j < COLUMNS; j++ ) {
53 for ( k = 0; k < COLUMNS; k++ ) {
54 float_mresult[i][j] += float_matrixa[i][k] * float_matrixb[k][j];
55 }
56 }
57 }
58
59 return float_mresult[10][10];
60}
Here is the caller graph for this function:

◆ flops_float_swapped_matrix_matrix_multiply()

float flops_float_swapped_matrix_matrix_multiply ( void  )

Definition at line 62 of file flops_testcode.c.

62 {
63
64 int i, j, k;
65
66 /* Matrix-Matrix multiply */
67 /* With inner loops swapped */
68
69 for (i = 0; i < ROWS; i++) {
70 for (k = 0; k < COLUMNS; k++) {
71 for (j = 0; j < COLUMNS; j++) {
72 float_mresult[i][j] += float_matrixa[i][k] * float_matrixb[k][j];
73 }
74 }
75 }
76 return float_mresult[10][10];
77}
Here is the caller graph for this function:

Variable Documentation

◆ a

volatile double a = 0.5

Definition at line 181 of file flops_testcode.c.

◆ b

volatile double b = 2.2

Definition at line 181 of file flops_testcode.c.

◆ double_matrixa

double double_matrixa[ROWS][COLUMNS]
static

Definition at line 18 of file flops_testcode.c.

◆ double_matrixb

double double_matrixb[ROWS][COLUMNS]
static

Definition at line 19 of file flops_testcode.c.

◆ double_mresult

double double_mresult[ROWS][COLUMNS]
static

Definition at line 20 of file flops_testcode.c.

◆ float_matrixa

float float_matrixa[ROWS][COLUMNS]
static

Definition at line 14 of file flops_testcode.c.

◆ float_matrixb

float float_matrixb[ROWS][COLUMNS]
static

Definition at line 15 of file flops_testcode.c.

◆ float_mresult

float float_mresult[ROWS][COLUMNS]
static

Definition at line 16 of file flops_testcode.c.