Skip to content

Commit

Permalink
Merge fix for GCR initialization
Browse files Browse the repository at this point in the history
This fixes a stride-related bug in GCR kernels.

Related PR: ginkgo-project#1656
  • Loading branch information
upsj authored and MarcelKoch committed Dec 2, 2024
2 parents 2b3a4f7 + 35d821c commit 2c614d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions common/unified/solver/gcr_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void initialize(std::shared_ptr<const DefaultExecutor> exec,
stopping_status* stop_status)
{
if (b->get_size()) {
run_kernel_solver(
run_kernel(
exec,
[] GKO_KERNEL(auto row, auto col, auto b, auto residual,
auto stop) {
Expand All @@ -36,8 +36,7 @@ void initialize(std::shared_ptr<const DefaultExecutor> exec,
}
residual(row, col) = b(row, col);
},
b->get_size(), b->get_stride(), default_stride(b),
default_stride(residual), stop_status);
b->get_size(), b, residual, stop_status);
} else {
run_kernel(
exec, [] GKO_KERNEL(auto col, auto stop) { stop[col].reset(); },
Expand Down
16 changes: 16 additions & 0 deletions test/solver/gcr_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ TEST_F(Gcr, GcrKernelInitializeIsEquivalentToRef)
}


TEST_F(Gcr, GcrKernelInitializeWithStrideIsEquivalentToRef)
{
initialize_data();
auto d_b_strided = Mtx::create(exec, b->get_size(), b->get_stride() + 2);
d_b_strided->copy_from(d_b);

gko::kernels::reference::gcr::initialize(ref, b.get(), residual.get(),
stop_status.get_data());
gko::kernels::GKO_DEVICE_NAMESPACE::gcr::initialize(
exec, d_b_strided.get(), d_residual.get(), d_stop_status.get_data());

GKO_ASSERT_MTX_NEAR(d_residual, residual, r<value_type>::value);
GKO_ASSERT_ARRAY_EQ(d_stop_status, stop_status);
}


TEST_F(Gcr, GcrKernelRestartIsEquivalentToRef)
{
initialize_data();
Expand Down

0 comments on commit 2c614d1

Please sign in to comment.