Add unified RS-coarsening kernels - #2034
Open
gojakuch wants to merge 5 commits into
Open
Conversation
yhmtsai
reviewed
Jun 16, 2026
| exec, [] GKO_KERNEL(auto i, auto cf) { cf[i] = 0; }, | ||
| cf_marker.get_size(), cf); | ||
|
|
||
| /// 4. RS-COARSENING (inherently sequential algorithm?) |
Member
There was a problem hiding this comment.
Is lambda_vals and cf shared with all runner?
The unified kernel won't be able to control the visibility of memory, so the other threads may not see the updated value at all.
If it is the sequential part, you can still use the host to solve it
gojakuch
force-pushed
the
feat/rs-coarsening-kernels
branch
from
June 17, 2026 08:48
f568022 to
cc9e07b
Compare
gojakuch
marked this pull request as ready for review
June 23, 2026 08:08
pratikvn
requested changes
Jul 7, 2026
pratikvn
left a comment
Member
There was a problem hiding this comment.
Nice work! Mostly minor comments
| } | ||
|
|
||
| // Copy results back to device | ||
| lambda = array<IndexType>(exec, h_lambda); |
Comment on lines
+134
to
+135
| array<IndexType> h_row_ptrs(host_exec, a_row_ptrs, a_row_ptrs + n + 1); | ||
| array<IndexType> h_col_idxs(host_exec, a_col_idxs, a_col_idxs + nnz); |
Member
There was a problem hiding this comment.
Maybe check if host_exec == exec ? For OMP this is the case, and there is an unnecessary copy
Comment on lines
+36
to
66
| run_kernel_reduction( | ||
| exec, | ||
| [] GKO_KERNEL(auto row, auto row_ptrs, auto col_idxs, auto values) { | ||
| bool has_diag = false; | ||
| bool valid = true; | ||
| for (auto nz = row_ptrs[row]; nz < row_ptrs[row + 1]; ++nz) { | ||
| const auto col = col_idxs[nz]; | ||
| const auto val = real(values[nz]); | ||
| using real_t = decltype(val); | ||
|
|
||
| if (row == col) { | ||
| has_diag = true; | ||
| if (val <= zero<real_t>()) valid = false; | ||
| } else { | ||
| if (val > zero<real_t>()) valid = false; | ||
| } | ||
| } | ||
| return (valid && has_diag) ? IndexType{1} : IndexType{0}; | ||
| }, | ||
| GKO_KERNEL_REDUCE_SUM(IndexType), d_result.get_data(), num_rows, | ||
| row_ptrs, col_idxs, values); | ||
|
|
||
| const IndexType count = get_element(d_result, 0); | ||
|
|
||
| run_kernel( | ||
| exec, | ||
| [count, num_rows] GKO_KERNEL(auto tidx, auto is_m_matrix) { | ||
| is_m_matrix[0] = (count == static_cast<IndexType>(num_rows)); | ||
| }, | ||
| 1, is_m_matrix_array.get_data()); | ||
| } |
Member
There was a problem hiding this comment.
Can be simplified ?
run_kernel_reduction(
exec,
[] GKO_KERNEL(auto row, auto row_ptrs, auto col_idxs, auto values) {
bool has_diag = false, valid = true;
for (auto nz = row_ptrs[row]; nz < row_ptrs[row + 1]; ++nz) { // same }
return valid && has_diag; // bool per row
},
[] GKO_KERNEL(auto a, auto b) { return a && b; }, // AND
[] GKO_KERNEL(auto a) { return a; },
true, is_m_matrix_array.get_data(), num_rows,
row_ptrs, col_idxs, values);
Comment on lines
+14
to
+16
| #include <ginkgo/core/matrix/diagonal.hpp> | ||
| #include <ginkgo/core/matrix/row_gatherer.hpp> | ||
| #include <ginkgo/core/matrix/sparsity_csr.hpp> |
Member
There was a problem hiding this comment.
unnecessary includes. Also check for others
gojakuch
force-pushed
the
feat/rs-coarsening-kernels
branch
2 times, most recently
from
July 10, 2026 20:25
eda193f to
997ed1b
Compare
gojakuch
force-pushed
the
feat/rs-coarsening-kernels
branch
from
August 3, 2026 14:21
997ed1b to
9e2e4e2
Compare
Collaborator
Author
|
rebased |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.