Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a batched block Jacobi preconditioner #1542

Merged
merged 23 commits into from
May 9, 2024
Merged

Conversation

pratikvn
Copy link
Member

@pratikvn pratikvn commented Feb 14, 2024

This PR adds a batched block Jacobi preconditioner. This PR only adds reference and omp kernels to reduce the amount of code that needs to be reviewed. Again, as usual, a lot of it is harness code,

TODO

  • Update docs
  • Format tests

@pratikvn pratikvn added 1:ST:WIP This PR is a work in progress. Not ready for review. type:batched-functionality This is related to the batched functionality in Ginkgo labels Feb 14, 2024
@pratikvn pratikvn self-assigned this Feb 14, 2024
@ginkgo-bot ginkgo-bot added reg:build This is related to the build system. reg:testing This is related to testing. type:preconditioner This is related to the preconditioners mod:all This touches all Ginkgo modules. labels Feb 14, 2024
@pratikvn pratikvn force-pushed the batch-prec-jacobi branch 2 times, most recently from 7de7adf to 6d06c91 Compare February 14, 2024 11:37
@pratikvn pratikvn changed the title WIP: Add a batched block Jacobi preconditioner Add a batched block Jacobi preconditioner Feb 14, 2024
@pratikvn pratikvn requested review from a team February 14, 2024 18:30
@pratikvn pratikvn added 1:ST:ready-for-review This PR is ready for review and removed 1:ST:WIP This PR is a work in progress. Not ready for review. labels Feb 14, 2024
Copy link
Member

@yhmtsai yhmtsai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first part of my reviews

include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
* where the first value is 0, and the last value is the number of
* rows / columns of the matrix.
*
* @note Even if not set explicitly, this parameter will be set to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we make the parameters in non-batch method non-mutable usage although it is still marked as mutable variable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think it should be marked mutable ?

include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
reference/test/preconditioner/batch_jacobi_kernels.cpp Outdated Show resolved Hide resolved
reference/preconditioner/batch_jacobi_kernels.hpp.inc Outdated Show resolved Hide resolved
Copy link
Member

@MarcelKoch MarcelKoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first comments just on the interface.

include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
Copy link
Member

@MarcelKoch MarcelKoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second part. Mostly minor stuff.

The largest issue for me is still the storage_scheme type. I would like a better solution to it, either storing the data it needs in the class, or freestanding functions.

@@ -119,6 +130,11 @@ struct batch_item {
index_type num_rows;
index_type num_cols;
index_type num_stored_elems_per_row;

inline size_type get_single_item_num_nnz() const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it a bit odd, that both uniform_batch and batch_item have both the function get_single_item_num_nnz, but TBH I'm not sure what to do about that. Maybe only keep the batch_item one and use extract_batch_item?

core/test/preconditioner/batch_jacobi.cpp Outdated Show resolved Hide resolved
reference/preconditioner/batch_block_jacobi.hpp Outdated Show resolved Hide resolved
reference/preconditioner/batch_scalar_jacobi.hpp Outdated Show resolved Hide resolved
reference/preconditioner/batch_scalar_jacobi.hpp Outdated Show resolved Hide resolved
test/preconditioner/batch_jacobi_kernels.cpp Outdated Show resolved Hide resolved
test/preconditioner/batch_jacobi_kernels.cpp Outdated Show resolved Hide resolved
test/preconditioner/batch_jacobi_kernels.cpp Outdated Show resolved Hide resolved
omp/preconditioner/batch_jacobi_kernels.cpp Show resolved Hide resolved
reference/preconditioner/batch_jacobi_kernels.hpp.inc Outdated Show resolved Hide resolved
omp/preconditioner/batch_jacobi_kernels.cpp Outdated Show resolved Hide resolved
reference/preconditioner/batch_scalar_jacobi.hpp Outdated Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved
core/preconditioner/batch_jacobi.cpp Outdated Show resolved Hide resolved
@pratikvn pratikvn force-pushed the batch-prec-jacobi branch 2 times, most recently from 233c13c to fe0507d Compare April 2, 2024 14:40
@MarcelKoch MarcelKoch added this to the Ginkgo 1.8.0 milestone Apr 5, 2024
@pratikvn pratikvn force-pushed the batch-prec-jacobi branch 2 times, most recently from d8b398d to 43c4797 Compare April 17, 2024 07:17
Copy link
Member

@MarcelKoch MarcelKoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly smaller nits left. One larger thing is where should the block pointers should be stored. I would suggest the Jacobi class directly, instead of the parameters.

include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
include/ginkgo/core/preconditioner/batch_jacobi.hpp Outdated Show resolved Hide resolved
reference/preconditioner/batch_jacobi_kernels.hpp.inc Outdated Show resolved Hide resolved
core/preconditioner/batch_jacobi_kernels.hpp Show resolved Hide resolved
test/preconditioner/batch_jacobi_kernels.cpp Outdated Show resolved Hide resolved

for (int k = 0; k < num_blocks; k++) {
const auto bsize = block_ptrs[k + 1] - block_ptrs[k];
for (int r = 0; r < bsize; r++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here, maybe use dense matrix views.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason it's not possible to use the views here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We compare the unbatched version with the batched one, the storage of the blocks is different. Additionally, for debugging purposes, it is easier if there is a element based comparison in case there are issues.

test/solver/batch_bicgstab_kernels.cpp Outdated Show resolved Hide resolved
core/preconditioner/batch_jacobi_helpers.hpp Outdated Show resolved Hide resolved
core/preconditioner/batch_jacobi_helpers.hpp Outdated Show resolved Hide resolved
@pratikvn pratikvn added 1:ST:ready-to-merge This PR is ready to merge. and removed 1:ST:ready-for-review This PR is ready for review labels May 8, 2024
pratikvn and others added 23 commits May 9, 2024 15:26
Co-authored-by: Isha Aggarwal<[email protected]>
Co-authored-by: Aditya Kashi<[email protected]>
Co-authored-by: Isha Aggarwal<[email protected]>
Co-authored-by: Aditya Kashi<[email protected]>
Co-authored-by: Isha Aggarwal<[email protected]>
Co-authored-by: Aditya Kashi<[email protected]>
Co-authored-by: Isha Aggarwal<[email protected]>
Co-authored-by: Aditya Kashi<[email protected]>
Co-authored-by: Isha Aggarwal<[email protected]>
Co-authored-by: Aditya Kashi<[email protected]>
Co-authored-by: Isha Aggarwal<[email protected]>
Co-authored-by: Aditya Kashi<[email protected]>
Co-authored-by: Marcel Koch <[email protected]>
Co-authored-by: Yu-Hsiang Tsai <[email protected]>
Co-authored-by: Marcel Koch <[email protected]>
Co-authored-by: Yu-Hsiang Tsai <[email protected]>
due to circ dep issues, libginkgo -> libginkgo_kernels
Co-authored-by: Yu-Hsiang Tsai <[email protected]>
@pratikvn pratikvn merged commit 1dfa912 into develop May 9, 2024
12 of 15 checks passed
@pratikvn pratikvn deleted the batch-prec-jacobi branch May 9, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1:ST:ready-to-merge This PR is ready to merge. mod:all This touches all Ginkgo modules. reg:build This is related to the build system. reg:testing This is related to testing. type:batched-functionality This is related to the batched functionality in Ginkgo type:preconditioner This is related to the preconditioners
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants