DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
DNDS::ArrayView< T, _row_size, _row_max, _align > Class Template Reference

Non-owning, device-callable view onto an Array. More...

#include <ArrayBasic.hpp>

Inheritance diagram for DNDS::ArrayView< T, _row_size, _row_max, _align >:
[legend]
Collaboration diagram for DNDS::ArrayView< T, _row_size, _row_max, _align >:
[legend]

Classes

class  RowView
 Non-owning view of a single row: {pointer, size}. More...
 

Public Member Functions

DNDS_DEVICE_CALLABLE ArrayView (index n_size, T *n_data, index n_data_size, const index *n_rowstart, index n_rowstart_size, const rowsize *n_rowsizes, index n_rowsizes_size, rowsize n_row_size_dynamic, bool n_isCompressed, t_dataUncompressed *n_p_dataUncompressed)
 Construct a view from raw pointers. Intended for internal use by Array::view().
 
DNDS_DEVICE_CALLABLE bool isCompressed () const
 Whether the underlying array is in the compressed (flat) form (always true for non-CSR).
 
DNDS_DEVICE_CALLABLE index Size () const
 Number of rows in the viewed array.
 
DNDS_DEVICE_CALLABLE rowsize RowSize () const
 Uniform row width for fixed layouts (asserts otherwise).
 
DNDS_DEVICE_CALLABLE rowsize RowSize (index iRow) const
 Per-row width. Handles CSR compressed and decompressed modes.
 
DNDS_DEVICE_CALLABLE rowsize RowSizeMax () const
 Maximum row width (TABLE_*Max only).
 
DNDS_DEVICE_CALLABLE rowsize RowSizeField () const
 "Logical" row-field width used by derived Eigen arrays; see Array::RowSizeField.
 
DNDS_DEVICE_CALLABLE rowsize RowSizeField (index iRow) const
 Per-row "field" size for CSR (= actual row width).
 
const T & at (index iRow, rowsize iCol) const
 Bounds-checked element read (not device-callable because CSR decompressed uses std::vector::at which throws on the host).
 
T & operator() (index iRow, rowsize iCol=0)
 2D indexed access (writable). See at.
 
const T & operator() (index iRow, rowsize iCol=0) const
 2D indexed access (read-only).
 
T * operator[] (index iRow)
 Raw row pointer. iRow == Size() is allowed for past-the-end queries (useful for computing buffer end in sweeps).
 
const T * operator[] (index iRow) const
 Const row pointer; see the non-const overload.
 
DNDS_DEVICE_CALLABLE T * data ()
 Raw pointer to the start of the flat data buffer.
 
DNDS_DEVICE_CALLABLE size_t DataSize () const
 Size of the flat data buffer in T elements.
 
DNDS_DEVICE_CALLABLE bool operator== (const self_type &R) const
 Pointer equality (two views referring to the same buffer).
 

Protected Types

using self_type = ArrayView< T, _row_size, _row_max, _align >
 
using t_Layout = ArrayLayout< T, _row_size, _row_max, _align >
 
using t_dataUncompressed = std::vector< std::vector< T > >
 

Protected Member Functions

DNDS_DEVICE_CALLABLE rowsize RowSize_Compressed (index iRow) const
 
DNDS_DEVICE_CALLABLE const T & at_compressed (index iRow, rowsize iCol) const
 
DNDS_DEVICE_CALLABLE T * get_rowstart_pointer_compressed (index iRow)
 

Protected Attributes

index _size
 
T * _data = nullptr
 
index _data_size = 0
 
std::conditional_t< _dataLayout==CSR, const index *, std::conditional_t< _dataLayout==TABLE_Max||_dataLayout==TABLE_StaticMax, const rowsize *, EmptyNoDefault > > _rowstart_or_rowsize = nullptr
 
bool _isCompressed = true
 
std::conditional_t< _dataLayout==TABLE_Max||_dataLayout==TABLE_Fixed, rowsize, EmptyNoDefault_row_size_dynamic = 0
 
std::conditional_t< _dataLayout==CSR, t_dataUncompressed *, EmptyNoDefault_p_dataUncompressed = nullptr
 

Additional Inherited Members

- Public Types inherited from DNDS::ArrayLayout< T, _row_size, _row_max, _align >
using value_type = T
 
- Static Public Member Functions inherited from DNDS::ArrayLayout< T, _row_size, _row_max, _align >
static constexpr DataLayout _GetDataLayout ()
 Deduce the DataLayout tag from the template parameters.
 
static std::string GetArrayName ()
 Human-readable type identifier including element typeid, sizes, and alignment.
 
static std::string GetArraySignature ()
 Compiler-independent identifier used by serializers to tag an array.
 
static std::string GetArraySignatureRelaxed ()
 Signature with _row_size / _row_max replaced by DynamicSize.
 
static std::tuple< int, int, int, int > ParseArraySignatureTuple (const std::string &v)
 Parse a signature string into (sizeof_T, row_size, row_max, align).
 
static bool ArraySignatureIsCompatible (const std::string &v)
 Whether a stored signature can be read into this array type.
 
- Static Public Attributes inherited from DNDS::ArrayLayout< T, _row_size, _row_max, _align >
static const rowsize al = _align
 
static const rowsize rs = _row_size
 
static const rowsize rm = _row_max
 
static const size_t sizeof_T = sizeof(value_type)
 
static const rowsize s_T = al == NoAlign ? sizeof_T : (sizeof_T / al + 1) * al
 
static const DataLayout _dataLayout = _GetDataLayout()
 
static const bool isCSR = _dataLayout == CSR
 

Detailed Description

template<class T, rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
class DNDS::ArrayView< T, _row_size, _row_max, _align >

Non-owning, device-callable view onto an Array.

Captures pointers to the flat data buffer and the structural arrays (_rowstart_or_rowsize) plus the nested-vector pointer for CSR decompressed. It is the type responsible for actually implementing operator[] / operator() indexing across every layout, and is marked __host__ __device__ to work inside CUDA kernels.

Instances are typically produced by Array::view() and must not outlive the owning Array.

Definition at line 237 of file ArrayBasic.hpp.

Member Typedef Documentation

◆ self_type

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
using DNDS::ArrayView< T, _row_size, _row_max, _align >::self_type = ArrayView<T, _row_size, _row_max, _align>
protected

Definition at line 242 of file ArrayBasic.hpp.

◆ t_dataUncompressed

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
using DNDS::ArrayView< T, _row_size, _row_max, _align >::t_dataUncompressed = std::vector<std::vector<T> >
protected

Definition at line 275 of file ArrayBasic.hpp.

◆ t_Layout

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
using DNDS::ArrayView< T, _row_size, _row_max, _align >::t_Layout = ArrayLayout<T, _row_size, _row_max, _align>
protected

Definition at line 245 of file ArrayBasic.hpp.

Constructor & Destructor Documentation

◆ ArrayView()

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE DNDS::ArrayView< T, _row_size, _row_max, _align >::ArrayView ( index  n_size,
T *  n_data,
index  n_data_size,
const index n_rowstart,
index  n_rowstart_size,
const rowsize n_rowsizes,
index  n_rowsizes_size,
rowsize  n_row_size_dynamic,
bool  n_isCompressed,
t_dataUncompressed n_p_dataUncompressed 
)
inline

Construct a view from raw pointers. Intended for internal use by Array::view().

Definition at line 282 of file ArrayBasic.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ at()

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
const T & DNDS::ArrayView< T, _row_size, _row_max, _align >::at ( index  iRow,
rowsize  iCol 
) const
inline

Bounds-checked element read (not device-callable because CSR decompressed uses std::vector::at which throws on the host).

unsafe

Definition at line 461 of file ArrayBasic.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ at_compressed()

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE const T & DNDS::ArrayView< T, _row_size, _row_max, _align >::at_compressed ( index  iRow,
rowsize  iCol 
) const
inlineprotected

unsafe

unsafe

Definition at line 426 of file ArrayBasic.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ data()

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE T * DNDS::ArrayView< T, _row_size, _row_max, _align >::data ( )
inline

Raw pointer to the start of the flat data buffer.

For CSR, requires compressed form. Device-callable.

Definition at line 549 of file ArrayBasic.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DataSize()

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE size_t DNDS::ArrayView< T, _row_size, _row_max, _align >::DataSize ( ) const
inline

Size of the flat data buffer in T elements.

Definition at line 557 of file ArrayBasic.hpp.

Here is the call graph for this function:

◆ get_rowstart_pointer_compressed()

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE T * DNDS::ArrayView< T, _row_size, _row_max, _align >::get_rowstart_pointer_compressed ( index  iRow)
inlineprotected

unsafe

Definition at line 487 of file ArrayBasic.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCompressed()

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE bool DNDS::ArrayView< T, _row_size, _row_max, _align >::isCompressed ( ) const
inline

Whether the underlying array is in the compressed (flat) form (always true for non-CSR).

Definition at line 315 of file ArrayBasic.hpp.

Here is the caller graph for this function:

◆ operator()() [1/2]

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
T & DNDS::ArrayView< T, _row_size, _row_max, _align >::operator() ( index  iRow,
rowsize  iCol = 0 
)
inline

2D indexed access (writable). See at.

Definition at line 475 of file ArrayBasic.hpp.

Here is the call graph for this function:

◆ operator()() [2/2]

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
const T & DNDS::ArrayView< T, _row_size, _row_max, _align >::operator() ( index  iRow,
rowsize  iCol = 0 
) const
inline

2D indexed access (read-only).

Definition at line 481 of file ArrayBasic.hpp.

Here is the call graph for this function:

◆ operator==()

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE bool DNDS::ArrayView< T, _row_size, _row_max, _align >::operator== ( const self_type R) const
inline

Pointer equality (two views referring to the same buffer).

Definition at line 567 of file ArrayBasic.hpp.

◆ operator[]() [1/2]

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
T * DNDS::ArrayView< T, _row_size, _row_max, _align >::operator[] ( index  iRow)
inline

Raw row pointer. iRow == Size() is allowed for past-the-end queries (useful for computing buffer end in sweeps).

Parameters
iRowRow index.
Returns
T*

unsafe

Definition at line 520 of file ArrayBasic.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator[]() [2/2]

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
const T * DNDS::ArrayView< T, _row_size, _row_max, _align >::operator[] ( index  iRow) const
inline

Const row pointer; see the non-const overload.

Definition at line 542 of file ArrayBasic.hpp.

◆ RowSize() [1/2]

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE rowsize DNDS::ArrayView< T, _row_size, _row_max, _align >::RowSize ( ) const
inline

Uniform row width for fixed layouts (asserts otherwise).

Definition at line 328 of file ArrayBasic.hpp.

Here is the caller graph for this function:

◆ RowSize() [2/2]

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE rowsize DNDS::ArrayView< T, _row_size, _row_max, _align >::RowSize ( index  iRow) const
inline

Per-row width. Handles CSR compressed and decompressed modes.

unsafe

Definition at line 373 of file ArrayBasic.hpp.

Here is the call graph for this function:

◆ RowSize_Compressed()

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE rowsize DNDS::ArrayView< T, _row_size, _row_max, _align >::RowSize_Compressed ( index  iRow) const
inlineprotected

unsafe

unsafe

Definition at line 343 of file ArrayBasic.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RowSizeField() [1/2]

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE rowsize DNDS::ArrayView< T, _row_size, _row_max, _align >::RowSizeField ( ) const
inline

"Logical" row-field width used by derived Eigen arrays; see Array::RowSizeField.

Definition at line 403 of file ArrayBasic.hpp.

Here is the call graph for this function:

◆ RowSizeField() [2/2]

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE rowsize DNDS::ArrayView< T, _row_size, _row_max, _align >::RowSizeField ( index  iRow) const
inline

Per-row "field" size for CSR (= actual row width).

Definition at line 416 of file ArrayBasic.hpp.

Here is the call graph for this function:

◆ RowSizeMax()

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE rowsize DNDS::ArrayView< T, _row_size, _row_max, _align >::RowSizeMax ( ) const
inline

Maximum row width (TABLE_*Max only).

Definition at line 392 of file ArrayBasic.hpp.

Here is the caller graph for this function:

◆ Size()

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
DNDS_DEVICE_CALLABLE index DNDS::ArrayView< T, _row_size, _row_max, _align >::Size ( ) const
inline

Number of rows in the viewed array.

Definition at line 324 of file ArrayBasic.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ _data

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
T* DNDS::ArrayView< T, _row_size, _row_max, _align >::_data = nullptr
protected

Definition at line 264 of file ArrayBasic.hpp.

◆ _data_size

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
index DNDS::ArrayView< T, _row_size, _row_max, _align >::_data_size = 0
protected

Definition at line 265 of file ArrayBasic.hpp.

◆ _isCompressed

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
bool DNDS::ArrayView< T, _row_size, _row_max, _align >::_isCompressed = true
protected

Definition at line 271 of file ArrayBasic.hpp.

◆ _p_dataUncompressed

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
std::conditional_t<_dataLayout == CSR, t_dataUncompressed *, EmptyNoDefault> DNDS::ArrayView< T, _row_size, _row_max, _align >::_p_dataUncompressed = nullptr
protected

Definition at line 276 of file ArrayBasic.hpp.

◆ _row_size_dynamic

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
std::conditional_t<_dataLayout == TABLE_Max || _dataLayout == TABLE_Fixed, rowsize, EmptyNoDefault> DNDS::ArrayView< T, _row_size, _row_max, _align >::_row_size_dynamic = 0
protected

Definition at line 273 of file ArrayBasic.hpp.

◆ _rowstart_or_rowsize

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
std::conditional_t<_dataLayout == CSR, const index *, std::conditional_t<_dataLayout == TABLE_Max || _dataLayout == TABLE_StaticMax, const rowsize *, EmptyNoDefault> > DNDS::ArrayView< T, _row_size, _row_max, _align >::_rowstart_or_rowsize = nullptr
protected

Definition at line 269 of file ArrayBasic.hpp.

◆ _size

template<class T , rowsize _row_size = 1, rowsize _row_max = _row_size, rowsize _align = NoAlign>
index DNDS::ArrayView< T, _row_size, _row_max, _align >::_size
protected

Definition at line 263 of file ArrayBasic.hpp.


The documentation for this class was generated from the following file: