Skip to content

Commit

Permalink
review updates
Browse files Browse the repository at this point in the history
- remove unnecessary stdin in tests
- simplify validate_config
- consistently use pointer members instead of reference members

Co-authored-by: Marcel Koch <marcel.koch@kit.edu>
  • Loading branch information
upsj and MarcelKoch committed Aug 28, 2023
1 parent 49ffd96 commit a725d3c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 26 deletions.
6 changes: 1 addition & 5 deletions benchmark/solver/solver_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,7 @@ struct SolverBenchmark : Benchmark<solver_benchmark_state<Generator>> {

bool validate_config(const json& value) const override
{
return ((value.contains("size") && value.contains("stencil") &&
value["size"].is_number_integer() &&
value["stencil"].is_string()) ||
(value.contains("filename") &&
value["filename"].is_string())) &&
return generator.validate_config(value) &&
(value.contains("optimal") &&
value["optimal"].contains("spmv") &&
value["optimal"]["spmv"].is_string());
Expand Down
2 changes: 0 additions & 2 deletions benchmark/test/blas.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
["-input", str(test_framework.sourcepath / "input.blas.json")],
expected_stdout="blas.simple.stdout",
expected_stderr="blas.simple.stderr",
stdin='[{"n": 100}]',
)

# profiler annotations
test_framework.compare_output(
["-input", '[{"n": 100}]', "-profile", "-profiler_hook", "debug"],
expected_stdout="blas.profile.stdout",
expected_stderr="blas.profile.stderr",
stdin='[{"n": 100}]',
)
2 changes: 0 additions & 2 deletions benchmark/test/multi_vector_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
["-input", str(test_framework.sourcepath / "input.blas.json")],
expected_stdout="multi_vector_distributed.simple.stdout",
expected_stderr="multi_vector_distributed.simple.stderr",
stdin='[{"n": 100}]',
num_procs=3,
)

Expand All @@ -33,6 +32,5 @@
["-input", '[{"n": 100}]', "-profile", "-profiler_hook", "debug"],
expected_stdout="multi_vector_distributed.profile.stdout",
expected_stderr="multi_vector_distributed.profile.stderr",
stdin='[{"n": 100}]',
num_procs=3,
)
34 changes: 17 additions & 17 deletions benchmark/utils/loggers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,35 +179,35 @@ struct ResidualLogger : gko::log::Logger {
const gko::array<gko::stopping_status>* status,
bool all_stopped) const override
{
timestamps.push_back(std::chrono::duration<double>(
std::chrono::steady_clock::now() - start)
.count());
timestamps->push_back(std::chrono::duration<double>(
std::chrono::steady_clock::now() - start)
.count());
if (residual_norm) {
rec_res_norms.push_back(
rec_res_norms->push_back(
get_norm(gko::as<vec<rc_vtype>>(residual_norm)));
} else {
gko::detail::vector_dispatch<rc_vtype>(
residual, [&](const auto v_residual) {
rec_res_norms.push_back(compute_norm2(v_residual));
rec_res_norms->push_back(compute_norm2(v_residual));
});
}
if (solution) {
gko::detail::vector_dispatch<
rc_vtype>(solution, [&](auto v_solution) {
using concrete_type =
std::remove_pointer_t<std::decay_t<decltype(v_solution)>>;
true_res_norms.push_back(compute_residual_norm(
true_res_norms->push_back(compute_residual_norm(
matrix, gko::as<concrete_type>(b), v_solution));
});
} else {
true_res_norms.push_back(-1.0);
true_res_norms->push_back(-1.0);
}
if (implicit_sq_residual_norm) {
implicit_res_norms.push_back(std::sqrt(
implicit_res_norms->push_back(std::sqrt(
get_norm(gko::as<vec<rc_vtype>>(implicit_sq_residual_norm))));
has_implicit_res_norm = true;
} else {
implicit_res_norms.push_back(-1.0);
implicit_res_norms->push_back(-1.0);
}
}

Expand All @@ -219,11 +219,11 @@ struct ResidualLogger : gko::log::Logger {
matrix{matrix.get()},
b{b.get()},
start{std::chrono::steady_clock::now()},
rec_res_norms{rec_res_norms},
true_res_norms{true_res_norms},
rec_res_norms{&rec_res_norms},
true_res_norms{&true_res_norms},
has_implicit_res_norm{},
implicit_res_norms{implicit_res_norms},
timestamps{timestamps}
implicit_res_norms{&implicit_res_norms},
timestamps{&timestamps}
{}

bool has_implicit_res_norms() const { return has_implicit_res_norm; }
Expand All @@ -232,11 +232,11 @@ struct ResidualLogger : gko::log::Logger {
const gko::LinOp* matrix;
const gko::LinOp* b;
std::chrono::steady_clock::time_point start;
json& rec_res_norms;
json& true_res_norms;
json* rec_res_norms;
json* true_res_norms;
mutable bool has_implicit_res_norm;
json& implicit_res_norms;
json& timestamps;
json* implicit_res_norms;
json* timestamps;
};


Expand Down

0 comments on commit a725d3c

Please sign in to comment.