9
9
#include < math.h>
10
10
11
11
// Number of runs to average
12
- #define N_RUNS 100
12
+ #define N_RUNS 1000
13
13
14
14
using floating_point_t = double ;
15
+ bool type_float;
15
16
16
17
floating_point_t benchmark (void );
17
18
floating_point_t cpu_time (void );
@@ -38,10 +39,14 @@ void setup()
38
39
39
40
if (sizeof (floating_point_t ) == sizeof (float )) {
40
41
data_type = " float" ;
42
+ type_float = true ;
41
43
} else if (sizeof (floating_point_t ) == sizeof (double )) {
42
44
data_type = " double" ;
45
+ type_float = false ;
43
46
} else {
44
47
data_type = " unknown" ;
48
+ log_e (" Unknown data type size. Aborting." );
49
+ while (1 );
45
50
}
46
51
47
52
log_d (" Starting Linpack %s test" , data_type.c_str ());
@@ -52,7 +57,7 @@ void setup()
52
57
floating_point_t minMflops = 1000000000.0 , maxMflops = 0.0 , avgMflops = 0.0 ;
53
58
for (int i = 0 ; i < N_RUNS; ++i)
54
59
{
55
- Serial.printf (" Run %d" , i);
60
+ Serial.printf (" Run %d\n " , i);
56
61
const auto mflops = benchmark ();
57
62
avgMflops += mflops;
58
63
minMflops = fmin (mflops, minMflops);
@@ -111,28 +116,26 @@ floating_point_t benchmark(void)
111
116
floating_point_t ops;
112
117
static floating_point_t resid[N];
113
118
floating_point_t resid_max;
114
- floating_point_t residn;
119
+ [[maybe_unused]] floating_point_t residn;
115
120
static floating_point_t rhs[N];
116
121
floating_point_t t1;
117
122
floating_point_t t2;
118
123
static floating_point_t time [6 ];
119
124
floating_point_t total;
120
125
floating_point_t x[N];
121
126
122
- Serial.print (" \n " );
123
- Serial.print (" LINPACK_BENCH\n " );
124
- Serial.print (" C version\n " );
125
- Serial.print (" \n " );
126
- Serial.print (" The LINPACK benchmark.\n " );
127
- Serial.print (" Language: C\n " );
128
- if (sizeof (floating_point_t ) == 8 )
129
- Serial.print (" Datatype: Double precision real\n " );
130
- else if (sizeof (floating_point_t ) == 4 )
131
- Serial.print (" Datatype: Single precision real\n " );
132
- else
133
- Serial.print (" Datatype: uknown\n " );
134
- Serial.println (String (" Matrix order N =" ) + N);
135
- Serial.println (" Leading matrix dimension LDA = " + LDA);
127
+ log_d (" LINPACK_BENCH" );
128
+ log_d (" C version" );
129
+ log_d (" The LINPACK benchmark." );
130
+ log_d (" Language: C" );
131
+ if (!type_float)
132
+ log_d (" Datatype: Double precision real" );
133
+ else if (type_float)
134
+ log_d (" Datatype: Single precision real" );
135
+ else
136
+ log_d (" Datatype: unknown" );
137
+ log_d (" Matrix order N = %d" , N);
138
+ log_d (" Leading matrix dimension LDA = %d" , LDA);
136
139
137
140
ops = (floating_point_t )(2L * N * N * N) / 3.0 + 2.0 * (floating_point_t )((long )N * N);
138
141
@@ -169,10 +172,9 @@ floating_point_t benchmark(void)
169
172
170
173
if (info != 0 )
171
174
{
172
- Serial.print (" \n " );
173
- Serial.print (" LINPACK_BENCH - Fatal error!\n " );
174
- Serial.print (" The matrix A is apparently singular.\n " );
175
- Serial.print (" Abnormal end of execution.\n " );
175
+ log_d (" LINPACK_BENCH - Fatal error!" );
176
+ log_d (" The matrix A is apparently singular." );
177
+ log_d (" Abnormal end of execution." );
176
178
return 1 ;
177
179
}
178
180
@@ -245,40 +247,20 @@ floating_point_t benchmark(void)
245
247
time [4 ] = 2.0 / time [3 ];
246
248
time [5 ] = total / cray;
247
249
248
- Serial.print (" \n " );
249
- Serial.print (" Norm. Resid Resid MACHEP X[1] X[N]\n " );
250
- Serial.print (" \n " );
251
- Serial.print (" " );
252
- Serial.print (residn, 14 );
253
- Serial.print (" " );
254
- Serial.print (resid_max, 14 );
255
- Serial.print (" " );
256
- Serial.print (eps, 14 );
257
- Serial.print (" " );
258
- Serial.print (b[0 ], 14 );
259
- Serial.print (" " );
260
- Serial.print (b[N - 1 ], 14 );
261
- Serial.print (" " );
262
- // printf ( " %14f %14f %14e %14f %14f\n", residn, resid_max, eps, b[0], b[N-1] );
263
- Serial.print (" \n " );
264
- Serial.print (" Factor Solve Total MFLOPS Unit Cray-Ratio\n " );
265
- Serial.print (" \n " );
266
- for (int i = 0 ; i < 6 ; i++)
267
- {
268
- Serial.print (" " );
269
- Serial.print (time [i], 9 );
270
- }
271
- // printf ( " %9f %9f %9f %9f %9f %9f\n",
272
- // time[0], time[1], time[2], time[3], time[4], time[5] );
250
+ log_d (" " );
251
+ log_d (" Norm. Resid Resid MACHEP X[1] X[N]" );
252
+ log_d (" %14f %14f %14e %14f %14f" , residn, resid_max, eps, b[0 ], b[N-1 ]);
253
+ log_d (" " );
254
+ log_d (" Factor Solve Total MFLOPS Unit Cray-Ratio" );
255
+ log_d (" %9f %9f %9f %9f %9f %9f" , time [0 ], time [1 ], time [2 ], time [3 ], time [4 ], time [5 ]);
273
256
274
257
/*
275
258
Terminate.
276
259
*/
277
- Serial.print (" \n " );
278
- Serial.print (" LINPACK_BENCH\n " );
279
- Serial.print (" Normal end of execution.\n " );
280
-
281
- Serial.print (" \n " );
260
+ log_d (" " );
261
+ log_d (" LINPACK_BENCH" );
262
+ log_d (" Normal end of execution." );
263
+ log_d (" " );
282
264
283
265
return time [3 ];
284
266
#undef LDA
0 commit comments