Skip to content

Commit e284cbe

Browse files
committed
fix(linpack): Change prints to log_d
1 parent bca566b commit e284cbe

File tree

2 files changed

+66
-102
lines changed

2 files changed

+66
-102
lines changed

tests/performance/linpack_double/linpack_double.ino

+33-51
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
#include <math.h>
1010

1111
// Number of runs to average
12-
#define N_RUNS 100
12+
#define N_RUNS 1000
1313

1414
using floating_point_t = double;
15+
bool type_float;
1516

1617
floating_point_t benchmark(void);
1718
floating_point_t cpu_time(void);
@@ -38,10 +39,14 @@ void setup()
3839

3940
if (sizeof(floating_point_t) == sizeof(float)) {
4041
data_type = "float";
42+
type_float = true;
4143
} else if (sizeof(floating_point_t) == sizeof(double)) {
4244
data_type = "double";
45+
type_float = false;
4346
} else {
4447
data_type = "unknown";
48+
log_e("Unknown data type size. Aborting.");
49+
while (1);
4550
}
4651

4752
log_d("Starting Linpack %s test", data_type.c_str());
@@ -52,7 +57,7 @@ void setup()
5257
floating_point_t minMflops = 1000000000.0, maxMflops = 0.0, avgMflops = 0.0;
5358
for (int i = 0; i < N_RUNS; ++i)
5459
{
55-
Serial.printf("Run %d", i);
60+
Serial.printf("Run %d\n", i);
5661
const auto mflops = benchmark();
5762
avgMflops += mflops;
5863
minMflops = fmin(mflops, minMflops);
@@ -111,28 +116,26 @@ floating_point_t benchmark(void)
111116
floating_point_t ops;
112117
static floating_point_t resid[N];
113118
floating_point_t resid_max;
114-
floating_point_t residn;
119+
[[maybe_unused]] floating_point_t residn;
115120
static floating_point_t rhs[N];
116121
floating_point_t t1;
117122
floating_point_t t2;
118123
static floating_point_t time[6];
119124
floating_point_t total;
120125
floating_point_t x[N];
121126

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);
136139

137140
ops = (floating_point_t)(2L * N * N * N) / 3.0 + 2.0 * (floating_point_t)((long)N * N);
138141

@@ -169,10 +172,9 @@ floating_point_t benchmark(void)
169172

170173
if (info != 0)
171174
{
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.");
176178
return 1;
177179
}
178180

@@ -245,40 +247,20 @@ floating_point_t benchmark(void)
245247
time[4] = 2.0 / time[3];
246248
time[5] = total / cray;
247249

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]);
273256

274257
/*
275258
Terminate.
276259
*/
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("");
282264

283265
return time[3];
284266
#undef LDA

tests/performance/linpack_float/linpack_float.ino

+33-51
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
#include <math.h>
1010

1111
// Number of runs to average
12-
#define N_RUNS 100
12+
#define N_RUNS 1000
1313

1414
using floating_point_t = float;
15+
bool type_float;
1516

1617
floating_point_t benchmark(void);
1718
floating_point_t cpu_time(void);
@@ -38,10 +39,14 @@ void setup()
3839

3940
if (sizeof(floating_point_t) == sizeof(float)) {
4041
data_type = "float";
42+
type_float = true;
4143
} else if (sizeof(floating_point_t) == sizeof(double)) {
4244
data_type = "double";
45+
type_float = false;
4346
} else {
4447
data_type = "unknown";
48+
log_e("Unknown data type size. Aborting.");
49+
while (1);
4550
}
4651

4752
log_d("Starting Linpack %s test", data_type.c_str());
@@ -52,7 +57,7 @@ void setup()
5257
floating_point_t minMflops = 1000000000.0, maxMflops = 0.0, avgMflops = 0.0;
5358
for (int i = 0; i < N_RUNS; ++i)
5459
{
55-
Serial.printf("Run %d", i);
60+
Serial.printf("Run %d\n", i);
5661
const auto mflops = benchmark();
5762
avgMflops += mflops;
5863
minMflops = fmin(mflops, minMflops);
@@ -111,28 +116,26 @@ floating_point_t benchmark(void)
111116
floating_point_t ops;
112117
static floating_point_t resid[N];
113118
floating_point_t resid_max;
114-
floating_point_t residn;
119+
[[maybe_unused]] floating_point_t residn;
115120
static floating_point_t rhs[N];
116121
floating_point_t t1;
117122
floating_point_t t2;
118123
static floating_point_t time[6];
119124
floating_point_t total;
120125
floating_point_t x[N];
121126

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);
136139

137140
ops = (floating_point_t)(2L * N * N * N) / 3.0 + 2.0 * (floating_point_t)((long)N * N);
138141

@@ -169,10 +172,9 @@ floating_point_t benchmark(void)
169172

170173
if (info != 0)
171174
{
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.");
176178
return 1;
177179
}
178180

@@ -245,40 +247,20 @@ floating_point_t benchmark(void)
245247
time[4] = 2.0 / time[3];
246248
time[5] = total / cray;
247249

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]);
273256

274257
/*
275258
Terminate.
276259
*/
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("");
282264

283265
return time[3];
284266
#undef LDA

0 commit comments

Comments
 (0)