Skip to content

Commit b0e1748

Browse files
committed
Drop the solver-specific avg_iter column from the comparison benchmark
1 parent de6dedf commit b0e1748

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

source/source_hsolver/test/diago_compare_test.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ static void rr_subspace(const T* H, int n, T* psi_in, T* psi_out, int ld, int nb
210210
struct Result
211211
{
212212
double wall_s = 0.0;
213-
double avg_iter = -1.0; // -1 when the solver does not report it
214213
double max_err = 0.0; // max |eval_i - ref_i| over the requested bands
215214
long mem_bytes = 0; // peak heap memory allocated by the solver
216215
bool ok = false;
@@ -229,10 +228,9 @@ static Result run_ppcg(const std::vector<T>& H, int n, int nband, const std::vec
229228
hsolver::PpcgStrategy::BLOCK_SUBSPACE);
230229
auto h_op = [&H, n](T* in, T* out, int ld, int nc) { dense_h_multiply(H.data(), n, in, out, ld, nc); };
231230
auto t0 = std::chrono::high_resolution_clock::now();
232-
double avg = solver.diag(h_op, nullptr, n, nband, n, psi.data(), eval.data(), ethr, prec.data());
231+
solver.diag(h_op, nullptr, n, nband, n, psi.data(), eval.data(), ethr, prec.data());
233232
auto t1 = std::chrono::high_resolution_clock::now();
234233
r.wall_s = std::chrono::duration<double>(t1 - t0).count();
235-
r.avg_iter = avg;
236234
r.mem_bytes = heap_bytes() - mem0;
237235
for (int i = 0; i < nband; ++i)
238236
{
@@ -256,10 +254,9 @@ static Result run_cg(const std::vector<T>& H, int n, int nband, const std::vecto
256254
auto h_op = [&H, n](T* in, T* out, int ld, int nc) { dense_h_multiply(H.data(), n, in, out, ld, nc); };
257255
auto s_op = [](T* in, T* out, int ld, int nc) { identity_s(in, out, ld, nc); };
258256
auto t0 = std::chrono::high_resolution_clock::now();
259-
double avg = cg.diag(h_op, s_op, n, nband, n, psi.data(), eval.data(), ethr, prec.data());
257+
cg.diag(h_op, s_op, n, nband, n, psi.data(), eval.data(), ethr, prec.data());
260258
auto t1 = std::chrono::high_resolution_clock::now();
261259
r.wall_s = std::chrono::duration<double>(t1 - t0).count();
262-
r.avg_iter = avg;
263260
r.mem_bytes = heap_bytes() - mem0;
264261
for (int i = 0; i < nband; ++i)
265262
{
@@ -297,7 +294,6 @@ static Result run_bpcg(const std::vector<T>& H, int n, int nband, const std::vec
297294
}
298295
auto t1 = std::chrono::high_resolution_clock::now();
299296
r.wall_s = std::chrono::duration<double>(t1 - t0).count();
300-
r.avg_iter = it;
301297
r.mem_bytes = heap_bytes() - mem0;
302298
for (int i = 0; i < nband; ++i)
303299
{
@@ -319,10 +315,9 @@ static Result run_dav(const std::vector<T>& H, int n, int nband, const std::vect
319315
auto h_op = [&H, n](T* in, T* out, int ld, int nc) { dense_h_multiply(H.data(), n, in, out, ld, nc); };
320316
auto s_op = [](T* in, T* out, int ld, int nc) { identity_s(in, out, ld, nc); };
321317
auto t0 = std::chrono::high_resolution_clock::now();
322-
int it = dav.diag(h_op, s_op, n, psi.data(), eval.data(), ethr, 500);
318+
dav.diag(h_op, s_op, n, psi.data(), eval.data(), ethr, 500);
323319
auto t1 = std::chrono::high_resolution_clock::now();
324320
r.wall_s = std::chrono::duration<double>(t1 - t0).count();
325-
r.avg_iter = it;
326321
r.mem_bytes = heap_bytes() - mem0;
327322
for (int i = 0; i < nband; ++i)
328323
{
@@ -369,9 +364,9 @@ int main(int argc, char** argv)
369364
}
370365

371366
std::printf("\n=== Solver comparison (identical H, psi0, ethr) ===\n");
372-
std::printf("%-5s %-5s %-6s %-10s %-14s %-12s %-10s %-12s\n", "n", "nband", "spars", "solver", "wall_time(s)", "avg_iter",
367+
std::printf("%-5s %-5s %-6s %-10s %-14s %-10s %-12s\n", "n", "nband", "spars", "solver", "wall_time(s)",
373368
"max_err", "mem(MB)");
374-
std::printf("---------------------------------------------------------------------------\n");
369+
std::printf("-----------------------------------------------------------------\n");
375370

376371
for (const auto& c : cases)
377372
{
@@ -389,15 +384,15 @@ int main(int argc, char** argv)
389384
Result r_bpcg = run_bpcg(H, c.n, c.nband, prec, psi0, ethr, ref.data());
390385
Result r_dav = run_dav(H, c.n, c.nband, prec, psi0, ethr, ref.data());
391386

392-
std::printf("%-5d %-5d %-6d %-10s %-14.5f %-12.1f %-10.2e %-12.2f\n", c.n, c.nband, c.sparsity, "PPCG", r_ppcg.wall_s,
393-
r_ppcg.avg_iter, r_ppcg.max_err, r_ppcg.mem_bytes / 1048576.0);
394-
std::printf("%-5s %-5s %-6s %-10s %-14.5f %-12.1f %-10.2e %-12.2f\n", "", "", "", "CG", r_cg.wall_s, r_cg.avg_iter,
387+
std::printf("%-5d %-5d %-6d %-10s %-14.5f %-10.2e %-12.2f\n", c.n, c.nband, c.sparsity, "PPCG", r_ppcg.wall_s,
388+
r_ppcg.max_err, r_ppcg.mem_bytes / 1048576.0);
389+
std::printf("%-5s %-5s %-6s %-10s %-14.5f %-10.2e %-12.2f\n", "", "", "", "CG", r_cg.wall_s,
395390
r_cg.max_err, r_cg.mem_bytes / 1048576.0);
396-
std::printf("%-5s %-5s %-6s %-10s %-14.5f %-12.1f %-10.2e %-12.2f\n", "", "", "", "BPCG", r_bpcg.wall_s,
397-
r_bpcg.avg_iter, r_bpcg.max_err, r_bpcg.mem_bytes / 1048576.0);
398-
std::printf("%-5s %-5s %-6s %-10s %-14.5f %-12.1f %-10.2e %-12.2f\n", "", "", "", "Davidson", r_dav.wall_s,
399-
r_dav.avg_iter, r_dav.max_err, r_dav.mem_bytes / 1048576.0);
400-
std::printf("---------------------------------------------------------------------------\n");
391+
std::printf("%-5s %-5s %-6s %-10s %-14.5f %-10.2e %-12.2f\n", "", "", "", "BPCG", r_bpcg.wall_s,
392+
r_bpcg.max_err, r_bpcg.mem_bytes / 1048576.0);
393+
std::printf("%-5s %-5s %-6s %-10s %-14.5f %-10.2e %-12.2f\n", "", "", "", "Davidson", r_dav.wall_s,
394+
r_dav.max_err, r_dav.mem_bytes / 1048576.0);
395+
std::printf("-----------------------------------------------------------------\n");
401396
}
402397

403398
MPI_Finalize();

0 commit comments

Comments
 (0)