Skip to content

Commit

Permalink
fix solver_test?
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Hahn <hahnse@ornl.gov>
  • Loading branch information
quantumsteve committed Feb 6, 2024
1 parent 0ab6d72 commit 40ce264
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,10 @@ simple_gmres(adapt::distributed_grid<P> const &adaptive_grid, int const elem_siz

int const n = b.size();
expect(n == x.size());

{
auto const &grid = adaptive_grid.get_subgrid(get_rank());
expect(n == elem_size*(grid.col_stop - grid.col_start + 1));
}
if (restart == parser::NO_USER_VALUE)
restart = default_gmres_restarts<P>(num_rows);
expect(restart > 0); // checked in program_options
Expand Down
17 changes: 10 additions & 7 deletions src/solver_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ void test_kronmult(parser const &parse, P const tol_factor)
asgard::matrix_list<P> operator_matrices;
asgard::adapt::distributed_grid adaptive_grid(*pde, opts);
operator_matrices.make(matrix_entry::regular, *pde, adaptive_grid, opts);
P const dt = pde->get_dt();

P const dt = pde->get_dt();
auto const &grid = adaptive_grid.get_subgrid(get_rank());
// perform matrix-free gmres
fk::vector<P> const matrix_free_gmres = [&adaptive_grid, elem_size, &operator_matrices, &gold, &b,
fk::vector<P> const matrix_free_gmres = [&adaptive_grid, elem_size, &grid, &operator_matrices, &gold, &b,
dt]() {
fk::vector<P> x(gold);
int len = elem_size * (grid.col_stop - grid.col_start + 1);
fk::vector<P> x(len), b_dist(len);
std::copy_n(gold.data(grid.col_start * elem_size), len, x.data());
std::copy_n(b.data(grid.col_start * elem_size), len, b_dist.data());
int const restart = parser::DEFAULT_GMRES_INNER_ITERATIONS;
int const max_iter = parser::DEFAULT_GMRES_OUTER_ITERATIONS;
P const tolerance = std::is_same_v<float, P> ? 1e-6 : 1e-12;
Expand All @@ -110,12 +113,12 @@ void test_kronmult(parser const &parse, P const tol_factor)
b, restart, max_iter, tolerance);
#else
solver::simple_gmres_euler(adaptive_grid, elem_size, dt, operator_matrices[matrix_entry::regular], x,
b, restart, max_iter, tolerance);
b_dist, restart, max_iter, tolerance);
#endif
return x;
}();

rmse_comparison(gold, matrix_free_gmres, tol_factor);
fk::vector<P, mem_type::const_view> gold_dist(gold, grid.col_start * elem_size, (grid.col_stop + 1) * elem_size - 1);
rmse_comparison(gold_dist, matrix_free_gmres, tol_factor);
#ifdef ASGARD_USE_CUDA
// perform matrix-free gmres
fk::vector<P> const mf_gpu_gmres = [&adaptive_grid, elem_size, &operator_matrices, &gold, &b, dt]() {
Expand Down

0 comments on commit 40ce264

Please sign in to comment.