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 GPU offloadable SparseMatrixStorage and read-only SparseMatrixView. #247

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

wdeconinck
Copy link
Member

This is an alternative proposal to #241 , keeping its idea of using atlas::array::Array, but aiming to be more generic.
It decouples three things: 1) construction of a sparse matrix, 2) storage, 3) read-only access.

Instead of recreating a different atlas::linalg::SparseMatrix class, we have a SparseMatrixStorage class that can be constructed using various means of host-data.

  • copy or move from eckit::linalg::SparseMatrix
  • copy or move from Eigen::SparseMatrix
  • copy from SparseMatrixView (see further).

The SparseMatrixStorage class holds three GPU-offloadable atlas::array::Array types to hold the sparse matrix data.
Since the atlas::array::Array types can hold any data type we can represent any precision SparseMatrix now, both for indices and values. Note that in order to support complex data type we need to extend atlas::array::Array to handle complex types (nudge @odlomax ).
When the SparseMatrixStorage is move-constructed from e.g. eckit::linalg::SparseMatrix or Eigen::SparseMatrix,
the Arrays will wrap these matrices in its host_data, and the GPU data will be owned.

The sparse_matrix_multiply API is refactored to take a templated SparseMatrixView<Value,Index> which provides a read-only access to either the host_data or device_data of the SparseMatrixStorage or other Sparse matrix formats.
It basically holds pointers. When these are device pointers, it is a device-view, and when they are host pointers it is a host-view.

The Interpolation classes and Caches have been adapted to hold the SparseMatrixStorage. @pmaciel , this may need an update on how you extract the eckit::linalg::SparseMatrix.
See here: https://github.com/ecmwf/atlas/compare/feature/sparse_storage_with_view?expand=1#diff-c5fa3d45217f3c703440ca5f193220d4b31fca9014d718a5f3a34971c1e2883fR109-R111

@l90lpa
Copy link
Contributor

l90lpa commented Dec 4, 2024

Hi @wdeconinck, your alternative looks great. Can I assume that the code isn't going to change much from this and thus start rebasing my other work on this?

@wdeconinck wdeconinck force-pushed the feature/sparse_storage_with_view branch from 4c38db8 to 7c1f738 Compare December 5, 2024 16:09
@wdeconinck
Copy link
Member Author

Hi @wdeconinck, your alternative looks great. Can I assume that the code isn't going to change much from this and thus start rebasing my other work on this?

I think that is safe to assume.

@l90lpa
Copy link
Contributor

l90lpa commented Dec 6, 2024

I think that is safe to assume.

Great, I've rebased #246 onto this branch.

wdeconinck and others added 2 commits December 9, 2024 08:50
…lation to hold SparseMatrixStorage and create views

Co-authored-by: Liam Adams <[email protected]>
@wdeconinck wdeconinck force-pushed the feature/sparse_storage_with_view branch from 88badf1 to bd9ab9a Compare December 9, 2024 08:53
@wdeconinck wdeconinck merged commit a3947dd into develop Dec 9, 2024
174 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants