Add GPU offloadable SparseMatrixStorage and read-only SparseMatrixView. #247
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.
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.
The
SparseMatrixStorage
class holds three GPU-offloadableatlas::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
orEigen::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 theSparseMatrixStorage
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 theeckit::linalg::SparseMatrix
.See here: https://github.com/ecmwf/atlas/compare/feature/sparse_storage_with_view?expand=1#diff-c5fa3d45217f3c703440ca5f193220d4b31fca9014d718a5f3a34971c1e2883fR109-R111