gko::matrix::view#
Each of Dense, Coo, Csr, Ell, Sellp and Hybrid exposes device_view and const_device_view types, together with the member functions get_device_view() and get_const_device_view(). A view is a small, trivially copyable struct of sizes and raw pointers, meant to be passed by value into kernel code or across library boundaries. The pointers refer to memory on the matrix’s executor and stay valid as long as the matrix is alive and not resized.
// A read-only view of A's arrays, e.g. to pass into a kernel.
auto view = A->get_const_device_view();
auto num_rows = view.size[0];
auto num_entries = view.num_stored_elements;
const int* row_ptrs = view.row_ptrs; // col_idxs and values likewise
The view types live in <ginkgo/core/matrix/device_views.hpp>. get_device_view() returns a view with mutable pointers; as_const() converts it to its const counterpart.
Views#
-
template<typename ValueType>
struct dense# Non-owning view of a matrix::Dense to be used inside device kernels. This type is used to provide a simple and stable ABI for passing data between libraries. The data is stored in row-major order.
- Template Parameters:
ValueType – the value type used to store matrix entries.
-
template<typename ValueType, typename IndexType>
struct coo# Non-owning view of a matrix::Coo to be used inside device kernels. This type is used to provide a simple and stable ABI for passing data between libraries.
- Template Parameters:
ValueType – the value type used to store matrix entries.
IndexType – the index type used to store row and column indices.
-
template<typename ValueType, typename IndexType>
struct csr# Non-owning view of a matrix::Csr to be used inside device kernels. This type is used to provide a simple and stable ABI for passing data between libraries.
- Template Parameters:
ValueType – the value type used to store matrix entries.
IndexType – the index type used to store row and column indices.
-
template<typename ValueType, typename IndexType>
struct ell# Non-owning view of a matrix::Ell to be used inside device kernels. This type is used to provide a simple and stable ABI for passing data between libraries.
- Template Parameters:
ValueType – the value type used to store matrix values.
IndexType – the index type used to store matrix columns.
Public Functions
- inline constexpr ell(
- dim<2> size,
- size_type num_stored_elements_per_row,
- size_type stride,
- ValueType *values,
- IndexType *col_idxs,
Constructs a ell view
- inline constexpr ell<const ValueType, const IndexType> as_const(
Returns a const view of the same values
-
template<typename ValueType, typename IndexType>
struct sellp# Non-owning view of a matrix::Sellp to be used inside device kernels. This type is used to provide a simple and stable ABI for passing data between libraries.
- Template Parameters:
ValueType – the value type used to store matrix values.
IndexType – the index type used to store matrix columns.
Public Functions
- inline constexpr sellp(
- dim<2> size,
- size_type slice_size,
- size_type stride_factor,
- size_type total_cols,
- ValueType *values,
- IndexType *col_idxs,
- adapt_size_type *slice_lengths,
- adapt_size_type *slice_sets,
Constructs a sellp view
- inline constexpr sellp<const ValueType, const IndexType> as_const(
Returns a const view of the same values
-
template<typename ValueType, typename IndexType>
struct hybrid# Non-owning view of a matrix::Hybrid to be used inside device kernels. This type is used to provide a simple and stable ABI for passing data between libraries.
- Template Parameters:
ValueType – the value type used to store matrix values.
IndexType – the index type used to store matrix columns.
See also
Matrix formats: the storage each view describes.
gko::matrix: the matrix classes that hand out views.