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

Adding Functionality needed by openCARP #555

Closed
fritzgoebel opened this issue Jun 5, 2020 · 8 comments
Closed

Adding Functionality needed by openCARP #555

fritzgoebel opened this issue Jun 5, 2020 · 8 comments
Labels
is:help-wanted Need ideas on how to solve this. is:new-feature A request or implementation of a feature that does not exist yet. type:matrix-format This is related to the Matrix formats

Comments

@fritzgoebel
Copy link
Collaborator

So far, I think we are missing the following functionalities:

  • diagonal scaling: openCARP needs to compute LMR where L and R are diagonal matrices. This could potentially be done with a new diagonal matrix format

  • matrix axpy: openCARP needs to compute a * A + b * B. This is not trivial as it potentially changes the sparsity pattern, if new zero entries occur even to something else that the union of the sparsity patterns of A and B

  • extract the diagonal from a matrix

  • initialize a matrix with all zeros

Any ideas / comments on how to handle a diagonal matrix format?

@fritzgoebel fritzgoebel added is:help-wanted Need ideas on how to solve this. is:new-feature A request or implementation of a feature that does not exist yet. type:matrix-format This is related to the Matrix formats labels Jun 5, 2020
@upsj
Copy link
Member

upsj commented Jun 5, 2020

Matrix axpy: For sparse matrices that's called spgeam and we already have an implementation hidden inside the HIP advanced spgemm and I could easily add it for the other executors as well. We only need to figure out how to represent/call it. If you call advanced Csr->apply(alpha, Identity, beta, Csr) maybe?

@fritzgoebel
Copy link
Collaborator Author

Matrix axpy: For sparse matrices that's called spgeam and we already have an implementation hidden inside the HIP advanced spgemm and I could easily add it for the other executors as well. We only need to figure out how to represent/call it. If you call advanced Csr->apply(alpha, Identity, beta, Csr) maybe?

Your representation makes sense, it would be awesome if you could add this :)

@pratikvn
Copy link
Member

pratikvn commented Jun 5, 2020

For diagonal scaling: I see two approaches:

  1. Add a new diagonal matrix format as you suggest.
  2. Add a diagonal scaling operation to all the matrix formats.

I personally think the second approach might be better because it would be easier to implement and I dont see any particular reason to add a new format for representing a diagonal matrix format. Additionally, you would also need to implement conversions from one diagonal to all other formats and vice versa which I am not sure is such a good idea. The diagonal scaling operation could look like :

auto mat = gko::matrix::Csr<>::create(...);
auto scaled_matmat = gko::matrix::Csr<>::create(...);
auto diag = gko::Array<>{exec, {values}};
mat->scale_diagonal(lend(diag), lend(scaled_mat));

You could similarly have a extract diagonal operation. I think we already have some similar kernels for the CSR format within the ParIX classes .

@upsj
Copy link
Member

upsj commented Jun 5, 2020

The reason I would prefer a diagonal matrix type is that it better matches with Ginkgo's position as a linear operator library. When we add special functions for these kinds of features, we can't use them within solvers, compositions, combinations etc.

@tcojean
Copy link
Member

tcojean commented Jun 5, 2020

I agree with Tobias here, it's always nice to be able to combine things in a transparent fashion, whereas adding new interfaces somewhat destroy that workflow.

@upsj upsj mentioned this issue Jun 5, 2020
@pratikvn
Copy link
Member

pratikvn commented Jun 5, 2020

Okay, then I guess it might be better to add a diagonal matrix format. But in any case the extracting of the diagonal would need to be specific to the different matrix formats.

@fritzgoebel
Copy link
Collaborator Author

Okay, then I guess it might be better to add a diagonal matrix format. But in any case the extracting of the diagonal would need to be specific to the different matrix formats.

Yes, I started implementing the extraction of the diagonal.

@upsj
Copy link
Member

upsj commented May 5, 2021

This was all implemented with #563 and #580 and #702 (fill)

@upsj upsj closed this as completed May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:help-wanted Need ideas on how to solve this. is:new-feature A request or implementation of a feature that does not exist yet. type:matrix-format This is related to the Matrix formats
Projects
None yet
Development

No branches or pull requests

7 participants