Added methods to diagonally scale csr matrices on the left and right.#283
Merged
shakedregev merged 14 commits intodevelopfrom May 27, 2025
Merged
Added methods to diagonally scale csr matrices on the left and right.#283shakedregev merged 14 commits intodevelopfrom
shakedregev merged 14 commits intodevelopfrom
Conversation
9 tasks
pelesh
approved these changes
May 25, 2025
Collaborator
pelesh
left a comment
There was a problem hiding this comment.
All tests pass on CUDA and HIP backends, code is reasonably well documented and unit tests are implemented.
One thing to take care of before merging is to put the code in line with style guidelines (or alternatively to wait until #261 is merged). In particular, note that:
- Long function names are not correctly aligned.
- There are no empty lines between different functions.
- There are redundant empty lines i. the code.
I flagged a couple of examples, please check style in all new code.
Comment on lines
+190
to
+196
| */ | ||
| __global__ void leftDiagScale(index_type n, | ||
| const index_type* a_row_ptr, | ||
| real_type* a_val, | ||
| const real_type* d_val) | ||
| { | ||
| // Get row index from thread and block indices |
Collaborator
There was a problem hiding this comment.
Either fix these or wait for #261 to be merged.
Comment on lines
+213
to
+215
| } | ||
| /** | ||
| * @brief Scales a csr matrix on the right by a diagonal matrix |
Collaborator
There was a problem hiding this comment.
An empty line is needed between functions per Re::Solve guidelines.
Comment on lines
+542
to
+543
|
|
||
| // Define block size and number of blocks |
Collaborator
There was a problem hiding this comment.
Te empty line is redundant here.
This reverts commit d707b66.
Co-authored-by: pelesh <peless@ornl.gov>
c18775b to
9682336
Compare
I fixed the whitespace and rebased according to your comments. Please re-review.
pelesh
approved these changes
May 27, 2025
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.
Description
This is necessary to solve the issue of L and U being in the right format. See details here. Additionally, diagonal scaling is needed for SUNDIALS and HyKKT integration.
1 of the 2 steps necessary to close issue 251
Proposed changes
I added methods to diagonally scale CSR matrices on the left and right. This will allow the use of external codes and moving the unit diagonal when we transpose and switch L and U by interpreting their CSC representation as CSR. New unit tests pass.
Checklist
Put an
xin the boxes that apply. You can also fill these out after creatingthe PR. If you're unsure about any of them, don't hesitate to ask. We're here
to help! This is simply a reminder of what we are going to look for before
merging your code.
-Wall -Wpedantic -Wconversion -Wextra.Further comments
This replaces #281 which was somehow hopelessly broken. A clarification: The different order of arguments for
leftDiagonalScale(vector_type diag, matrix::Csr A)andrightDiagonalScale(matrix::Csr A, vector_type diag)is intentional to reflect the mathematics. There is no danger of the code compiling if the order of the arguments is switched. The functions have a different stamp so that the user is intentional about which one to call.