batchlas::KernelMatrixView< T, MType > Struct Template Reference

Overview

template<typename T, MatrixFormat MType>
struct batchlas::KernelMatrixView< T, MType >

Trivially copyable view of a MatrixView for use inside a SYCL kernel.

Obtained from Matrix::kernel_view() or MatrixView::kernel_view() on the host and captured by value. It holds raw pointers and extents only: no ownership, no backend handle, no bounds checks beyond debug-build asserts. Specialised on the format so format-specific paths resolve at compile time; slicing is dense-only. The fields are public so kernels can read them without a call.

Template Parameters
Tscalar type
MTypeMatrixFormat::Dense or MatrixFormat::CSR
See also
Matrix model: KernelMatrixView, the device-side view

Definition at line 145 of file matrix.hh.

#include <batchlas/blas/matrix.hh>

Constructors

◆ KernelMatrixView() [1/4]

template<typename T, MatrixFormat MType>
batchlas::KernelMatrixView< T, MType >::KernelMatrixView ( )
default

A null 0 x 0 view with batch size 1.

◆ KernelMatrixView() [2/4]

template<typename T, MatrixFormat MType>
batchlas::KernelMatrixView< T, MType >::KernelMatrixView ( const KernelMatrixView< T, MType > & )
default

◆ KernelMatrixView() [3/4]

template<typename T, MatrixFormat MType>
batchlas::KernelMatrixView< T, MType >::KernelMatrixView ( KernelMatrixView< T, MType > && )
default

◆ KernelMatrixView() [4/4]

template<typename T, MatrixFormat MType>
template<MatrixFormat MF = MType>
requires DenseMatrixFormat<MF>
batchlas::KernelMatrixView< T, MType >::KernelMatrixView ( T * data,
int rows,
int cols,
int ld = 0,
int stride = 0,
int batch_size = 1 )
inline

Dense view over raw device-accessible memory.

Parameters
database of batch item 0
rowsrows per item
colscolumns per item
ldleading dimension; 0 means rows
stridebatch stride; 0 means (resolved ld) * cols
batch_sizenumber of items

Definition at line 280 of file matrix.hh.

Functions

◆ operator()() [1/5]

template<typename T, MatrixFormat MType>
template<MatrixFormat MF = MType>
requires DenseMatrixFormat<MF>
T & batchlas::KernelMatrixView< T, MType >::operator() ( int i,
int j,
int b = 0 ) const
inlineconstexpr

Dense element (i, j) of batch item b: data_[b * stride_ + j * ld_ + i].

Precondition
0 <= i < rows_, 0 <= j < cols_, 0 <= b < batch_size_ (asserted in debug builds)

Definition at line 166 of file matrix.hh.

◆ get()

template<typename T, MatrixFormat MType>
template<MatrixFormat MF = MType>
requires CsrMatrixFormat<MF>
T batchlas::KernelMatrixView< T, MType >::get ( int i,
int j,
int b = 0 ) const
inlineconstexpr

CSR coefficient (i, j) of batch item b, or zero if not stored.

A linear search over row i's entries: O(nnz in row i).

Definition at line 183 of file matrix.hh.

◆ batch_item()

template<typename T, MatrixFormat MType>
KernelMatrixView batchlas::KernelMatrixView< T, MType >::batch_item ( int b) const
inlineconstexpr

A single-item view (batch_size_ = 1) of batch item b.

Dense: rows and columns are the item's active extents, and the result is homogeneous. An out-of-range b yields a 0 x 0 view rather than a fault.

Definition at line 198 of file matrix.hh.

◆ data()

template<typename T, MatrixFormat MType>
auto batchlas::KernelMatrixView< T, MType >::data ( ) const
inline

Base pointer of item 0.

Definition at line 217 of file matrix.hh.

◆ rows() [1/2]

template<typename T, MatrixFormat MType>
auto batchlas::KernelMatrixView< T, MType >::rows ( ) const
inline

Row count (the capacity on a heterogeneous batch).

Definition at line 219 of file matrix.hh.

◆ rows() [2/2]

template<typename T, MatrixFormat MType>
auto batchlas::KernelMatrixView< T, MType >::rows ( int batch_index) const
inline

Active row count of batch item batch_index.

Definition at line 221 of file matrix.hh.

◆ cols() [1/2]

template<typename T, MatrixFormat MType>
auto batchlas::KernelMatrixView< T, MType >::cols ( ) const
inline

Column count (the capacity on a heterogeneous batch).

Definition at line 223 of file matrix.hh.

◆ cols() [2/2]

template<typename T, MatrixFormat MType>
auto batchlas::KernelMatrixView< T, MType >::cols ( int batch_index) const
inline

Active column count of batch item batch_index.

Definition at line 225 of file matrix.hh.

◆ batch_size()

template<typename T, MatrixFormat MType>
auto batchlas::KernelMatrixView< T, MType >::batch_size ( ) const
inline

Number of batch items.

Definition at line 226 of file matrix.hh.

◆ ld()

template<typename T, MatrixFormat MType>
auto batchlas::KernelMatrixView< T, MType >::ld ( ) const
inline

Dense leading dimension, in elements.

Definition at line 227 of file matrix.hh.

◆ stride()

template<typename T, MatrixFormat MType>
auto batchlas::KernelMatrixView< T, MType >::stride ( ) const
inline

Dense batch stride, in elements.

Definition at line 228 of file matrix.hh.

◆ nnz() [1/2]

template<typename T, MatrixFormat MType>
auto batchlas::KernelMatrixView< T, MType >::nnz ( ) const
inline

CSR per-item non-zero capacity; over-counts every item smaller than the largest.

Definition at line 230 of file matrix.hh.

◆ nnz() [2/2]

template<typename T, MatrixFormat MType>
auto batchlas::KernelMatrixView< T, MType >::nnz ( int b) const
inline

CSR non-zeros actually stored by batch item b, read from its row offsets.

Definition at line 232 of file matrix.hh.

◆ is_heterogeneous()

template<typename T, MatrixFormat MType>
bool batchlas::KernelMatrixView< T, MType >::is_heterogeneous ( ) const
inline

True when per-item active extents are attached.

Definition at line 237 of file matrix.hh.

◆ operator()() [2/5]

template<typename T, MatrixFormat MType>
template<MatrixFormat MF = MType>
requires DenseMatrixFormat<MF>
KernelMatrixView batchlas::KernelMatrixView< T, MType >::operator() ( Slice rows_slice,
Slice cols_slice = {} ) const

Dense sub-block view; same pointer arithmetic as MatrixView::operator()(Slice, Slice).

Note
Empty or inverted slices are not diagnosed here (the check is a no-op assert).

◆ operator()() [3/5]

template<typename T, MatrixFormat MType>
template<MatrixFormat MF = MType>
requires DenseMatrixFormat<MF>
KernelMatrixView batchlas::KernelMatrixView< T, MType >::operator() ( Slice rows_slice) const
inline

Dense row-range view over all columns.

Definition at line 247 of file matrix.hh.

◆ operator()() [4/5]

template<typename T, MatrixFormat MType>
template<MatrixFormat MF = MType>
requires DenseMatrixFormat<MF>
VectorView< T > batchlas::KernelMatrixView< T, MType >::operator() ( int32_t row,
Slice cols_slice ) const

Part of row row as a batched VectorView (inc = ld_, stride = stride_).

◆ operator()() [5/5]

template<typename T, MatrixFormat MType>
template<MatrixFormat MF = MType>
requires DenseMatrixFormat<MF>
VectorView< T > batchlas::KernelMatrixView< T, MType >::operator() ( Slice rows_slice,
int32_t col ) const

Part of column col as a batched VectorView (inc = 1, stride = stride_).

◆ operator=() [1/2]

template<typename T, MatrixFormat MType>
KernelMatrixView & batchlas::KernelMatrixView< T, MType >::operator= ( const KernelMatrixView< T, MType > & )
default

◆ operator=() [2/2]

template<typename T, MatrixFormat MType>
KernelMatrixView & batchlas::KernelMatrixView< T, MType >::operator= ( KernelMatrixView< T, MType > && )
default

Variables

◆ data_

template<typename T, MatrixFormat MType>
T* batchlas::KernelMatrixView< T, MType >::data_ = nullptr

Values of batch item 0.

Definition at line 146 of file matrix.hh.

◆ rows_

template<typename T, MatrixFormat MType>
int batchlas::KernelMatrixView< T, MType >::rows_ = 0

Rows (the capacity when heterogeneous).

Definition at line 147 of file matrix.hh.

◆ cols_

template<typename T, MatrixFormat MType>
int batchlas::KernelMatrixView< T, MType >::cols_ = 0

Columns (the capacity when heterogeneous).

Definition at line 148 of file matrix.hh.

◆ batch_size_

template<typename T, MatrixFormat MType>
int batchlas::KernelMatrixView< T, MType >::batch_size_ = 1

Number of batch items.

Definition at line 149 of file matrix.hh.

◆ ld_

template<typename T, MatrixFormat MType>
int batchlas::KernelMatrixView< T, MType >::ld_ = 0

Dense: leading dimension, in elements.

Definition at line 151 of file matrix.hh.

◆ stride_

template<typename T, MatrixFormat MType>
int batchlas::KernelMatrixView< T, MType >::stride_ = 0

Dense: batch stride, in elements.

Definition at line 152 of file matrix.hh.

◆ active_rows_

template<typename T, MatrixFormat MType>
int* batchlas::KernelMatrixView< T, MType >::active_rows_ = nullptr

Dense: per-item row counts, or null when homogeneous.

Definition at line 153 of file matrix.hh.

◆ active_cols_

template<typename T, MatrixFormat MType>
int* batchlas::KernelMatrixView< T, MType >::active_cols_ = nullptr

Dense: per-item column counts, or null when homogeneous.

Definition at line 154 of file matrix.hh.

◆ row_offsets_

template<typename T, MatrixFormat MType>
int* batchlas::KernelMatrixView< T, MType >::row_offsets_ = nullptr

CSR: rows + 1 offsets per item, items offset_stride_ apart.

Definition at line 156 of file matrix.hh.

◆ col_indices_

template<typename T, MatrixFormat MType>
int* batchlas::KernelMatrixView< T, MType >::col_indices_ = nullptr

CSR: column indices, items matrix_stride_ apart.

Definition at line 157 of file matrix.hh.

◆ nnz_

template<typename T, MatrixFormat MType>
int batchlas::KernelMatrixView< T, MType >::nnz_ = 0

CSR: per-item non-zero capacity.

Definition at line 158 of file matrix.hh.

◆ matrix_stride_

template<typename T, MatrixFormat MType>
int batchlas::KernelMatrixView< T, MType >::matrix_stride_ = 0

CSR: element distance between items' value (and index) arrays.

Definition at line 159 of file matrix.hh.

◆ offset_stride_

template<typename T, MatrixFormat MType>
int batchlas::KernelMatrixView< T, MType >::offset_stride_ = 0

CSR: element distance between items' offset arrays.

Definition at line 160 of file matrix.hh.