StencilStream v3.0.0
SYCL-based Stencil Simulation Framework Targeting FPGAs
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
stencil::AccessorSubscript< Cell, Accessor, access_mode, current_subdim > Class Template Reference

A helper class to support the double-subscript idiom for GridAccessors. More...

#include <AccessorSubscript.hpp>

Public Member Functions

 AccessorSubscript (Accessor &ac, uindex_t i)
 Instantiate a new accessor subscript object with the given index as the prefix.
 
 AccessorSubscript (Accessor &ac, sycl::id< dimensions > id_prefix, uindex_t i)
 Instantiate a new subscript object with the given prefix and subscript index.
 
AccessorSubscript< Cell, Accessor, access_mode, current_subdim+1 > operator[] (uindex_t i)
 Access the next dimension's accessor subscript.
 
Cell const & operator[] (uindex_t i)
 Access the cell.
 
Cell & operator[] (uindex_t i)
 Access the cell.
 

Static Public Attributes

static constexpr uindex_t dimensions = Accessor::dimensions
 The number of dimensions in the accessed grid.
 

Detailed Description

template<typename Cell, typename Accessor, sycl::access::mode access_mode, uindex_t current_subdim = 0>
class stencil::AccessorSubscript< Cell, Accessor, access_mode, current_subdim >

A helper class to support the double-subscript idiom for GridAccessors.

This class is used to support expressions like accessor[i_column][i_row]. Each subscript except the last one creates an object of this class, which stores the index of the subscript as well as all previous indices to form a so-called "prefix." When the last subscript is called, the index is added to the prefix to yield the complete, multi-dimensional index. Then, the last subscript object returns a reference to the requested cell.

Template Parameters
CellThe cell type to support
Accessoraccessor to direct to. It must fulfill stencil::concepts::GridAccessor, but since this class is also part of the concept's definition, we can't check it here.
access_modeThe access mode of the accessor. Used to enable and disable different operator[] implementations
current_subdimThe current subdim. Decides whether the next call to operator[] returns another AccessorSubscript or the final cell reference.

Constructor & Destructor Documentation

◆ AccessorSubscript() [1/2]

template<typename Cell , typename Accessor , sycl::access::mode access_mode, uindex_t current_subdim = 0>
stencil::AccessorSubscript< Cell, Accessor, access_mode, current_subdim >::AccessorSubscript ( Accessor &  ac,
uindex_t  i 
)
inline

Instantiate a new accessor subscript object with the given index as the prefix.

This accessor is meant to be used by the operator[] implementation of the accessor to construct the first subscript object. It is therefore only available iff the current subdimention is zero.

Parameters
acThe accessor to redirect to.
iThe index of the previous subscript. It will be used as a prefix.

◆ AccessorSubscript() [2/2]

template<typename Cell , typename Accessor , sycl::access::mode access_mode, uindex_t current_subdim = 0>
stencil::AccessorSubscript< Cell, Accessor, access_mode, current_subdim >::AccessorSubscript ( Accessor &  ac,
sycl::id< dimensions id_prefix,
uindex_t  i 
)
inline

Instantiate a new subscript object with the given prefix and subscript index.

This constructor will take the given prefix, add the new index to it at the current position, and use the resulting prefix.

Parameters
acThe accessor to redirect to.
id_prefixThe previous prefix
iThe new index to add to the prefix.

Member Function Documentation

◆ operator[]() [1/3]

template<typename Cell , typename Accessor , sycl::access::mode access_mode, uindex_t current_subdim = 0>
AccessorSubscript< Cell, Accessor, access_mode, current_subdim+1 > stencil::AccessorSubscript< Cell, Accessor, access_mode, current_subdim >::operator[] ( uindex_t  i)
inline

Access the next dimension's accessor subscript.

The resulting subscript object will contain the current prefix together with the given index. This implementation is only available to intermediate dimensions. For the last dimension, the resulting ID will be evaluated and returned.

Parameters
iThe next dimension's index.
Returns
A subscript object for the following dimensions.

◆ operator[]() [2/3]

template<typename Cell , typename Accessor , sycl::access::mode access_mode, uindex_t current_subdim = 0>
Cell const & stencil::AccessorSubscript< Cell, Accessor, access_mode, current_subdim >::operator[] ( uindex_t  i)
inline

Access the cell.

This will add the given index to the prefix and use the underlying accessor to provide a reference to the cell. This is the implementation for read-only accessors as it returns a constant reference.

Parameters
iThe final dimension's index.
Returns
A constant reference to the indexed cell.

◆ operator[]() [3/3]

template<typename Cell , typename Accessor , sycl::access::mode access_mode, uindex_t current_subdim = 0>
Cell & stencil::AccessorSubscript< Cell, Accessor, access_mode, current_subdim >::operator[] ( uindex_t  i)
inline

Access the cell.

This will add the given index to the prefix and use the underlying accessor to provide a reference to the cell. This is the implementation for accessors that may alter the grid.

Parameters
iThe final dimension's index.
Returns
A reference to the indexed cell.

Member Data Documentation

◆ dimensions

template<typename Cell , typename Accessor , sycl::access::mode access_mode, uindex_t current_subdim = 0>
constexpr uindex_t stencil::AccessorSubscript< Cell, Accessor, access_mode, current_subdim >::dimensions = Accessor::dimensions
staticconstexpr

The number of dimensions in the accessed grid.


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