Skip to content

Commit

Permalink
add constant rhs to solver benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj committed Nov 3, 2020
1 parent de18d71 commit ccca1ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion benchmark/solver/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ DEFINE_uint32(
DEFINE_uint32(gmres_restart, 100,
"What maximum dimension of the Krylov space to use in GMRES");

DEFINE_bool(random_rhs, false,
"Use a random vector for the rhs (otherwise use all ones)");

DEFINE_bool(random_initial_guess, false,
"Use a random vector for the initial guess (otherwise use rhs)");

Expand Down Expand Up @@ -692,7 +695,8 @@ int main(int argc, char *argv[])
} else {
b = create_matrix<etype>(
exec,
gko::dim<2>{system_matrix->get_size()[0], FLAGS_nrhs});
gko::dim<2>{system_matrix->get_size()[0], FLAGS_nrhs},
engine, FLAGS_random_rhs);
}
if (FLAGS_random_initial_guess) {
x = create_matrix<etype>(
Expand Down
10 changes: 7 additions & 3 deletions benchmark/utils/general.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,15 @@ std::unique_ptr<vec<ValueType>> create_matrix(
template <typename ValueType, typename RandomEngine>
std::unique_ptr<vec<ValueType>> create_matrix(
std::shared_ptr<const gko::Executor> exec, gko::dim<2> size,
RandomEngine &engine)
RandomEngine &engine, bool random = true)
{
auto res = vec<ValueType>::create(exec);
res->read(gko::matrix_data<ValueType>(
size, std::uniform_real_distribution<>(-1.0, 1.0), engine));
if (random) {
res->read(gko::matrix_data<ValueType>(
size, std::uniform_real_distribution<>(-1.0, 1.0), engine));
} else {
res->read(gko::matrix_data<ValueType>(size, gko::one<ValueType>()));
}
return res;
}

Expand Down

0 comments on commit ccca1ef

Please sign in to comment.