Provides joint access semantics for multiple operands.
More...
#include <rexlib/core/layout/joint_layout.hpp>
Provides joint access semantics for multiple operands.
This class enables jointly iterating over multiple operands. It stores extents of the iteration space, strides for each of the operands, and offset for each of the operands.
Instances of this object must be obtained through joint_layout_builder. Once built, it is inmutable.
- See also
- joint_layout_builder
◆ compute_element_count()
| std::size_t rexlib::joint_layout::compute_element_count |
( |
| ) |
const |
|
noexcept |
Computes the number of positions the iteration space holds.
The product of the extents, which is how many times a traversal of the whole layout visits its operands, and so the range seek() indexes into. A layout of no axes holds a single position, the identity of the product.
- Returns
- std::size_t Number of positions. 0 if the layout can not be iterated, as
iter() and seek() report it.
◆ get_extents()
| span< const std::size_t > rexlib::joint_layout::get_extents |
( |
| ) |
const |
Get the extents of the iteration space.
- Returns
- span<const std::size_t> The extents of the iteration space.
◆ get_implementation()
Get a pointer to the implementation.
- Returns
- const joint_layout_implementation* Pointer to the implementation.
- Note
- This method is meant to be used for testing purposes, as the joint_layout_implementation is not publicly available.
◆ get_number_of_operands()
| std::size_t rexlib::joint_layout::get_number_of_operands |
( |
| ) |
const |
|
noexcept |
Get the number of operands.
- Returns
- std::size_t The number of operands.
◆ get_offset()
| std::ptrdiff_t rexlib::joint_layout::get_offset |
( |
std::size_t |
operand | ) |
const |
Get the offset parameter of an operand.
- Parameters
-
| operand | The index of the operand. Must be in [0, number_of_operands()) |
- Returns
- std::ptrdiff_t The offset parameter of the requested operand.
- Exceptions
-
| std::out_of_range | if operand index is out of range. |
◆ get_rank()
| std::size_t rexlib::joint_layout::get_rank |
( |
| ) |
const |
|
noexcept |
Get the number of dimensions.
- Returns
- std::size_t Number of dimensions.
◆ get_strides()
| span< const std::ptrdiff_t > rexlib::joint_layout::get_strides |
( |
std::size_t |
operand | ) |
const |
Get the strides for an operand.
- Parameters
-
| operand | The index of the operand. Must be in [0, number_of_operands()) |
- Returns
- span<const std::ptrdiff_t> The strides of the requested operand. Always has the same size as extents.
- Exceptions
-
| std::out_of_range | if operand index is out of range. |
◆ iter()
| std::size_t rexlib::joint_layout::iter |
( |
joint_cursor & |
ite, |
|
|
std::size_t |
first_dim = 0, |
|
|
std::size_t |
last_dim = end_dim |
|
) |
| const |
Populate a cursor for traversing this layout.
- Parameters
-
| ite | The iterator to be populated. |
| first_dim | Index of the inner-most dimension to be iterated. Must be less or equal to get_rank(). Defaults to zero. |
| last_dim | Index of the outer-most dimension to be iterated. Must be less or equal to get_rank() or equal to end_dim. Defaults to end_dim. |
- Returns
- std::size_t Number of elements in the dimension. 0 if the layout can not be iterated.
◆ next()
| std::size_t rexlib::joint_layout::next |
( |
joint_cursor & |
ite, |
|
|
std::size_t |
n, |
|
|
std::size_t |
first_dim = 0, |
|
|
std::size_t |
last_dim = end_dim |
|
) |
| const |
|
noexcept |
Advance a cursor.
- Parameters
-
| ite | The iterator to be advanced. Must have been populated by iter(). The previous call to iter() or next() must have returned a non-zero value. |
| n | Number of elements to be advanced. Must be less or equal to the number returned by the previous call to iter() or next(). Otherwise behavior is undefined. |
| first_dim | Index of the inner-most dimension to be iterated. Must be less or equal to get_rank(). Defaults to zero. |
| last_dim | Index of the outer-most dimension to be iterated. Must be less or equal to get_rank() or equal to end_dim. Defaults to end_dim. |
- Returns
- std::size_t Number of remaining elements in
dim. 0 if iteration has finished.
- Warning
- If
first_dim or last_dim is modified during iteration, the value provided to n needs special attention as the limit may be smaller than the last value returned by iter() or last next(). If unsure, the new limit may be computed using next(ite, 0, first_dim, last_dim).
◆ seek()
| std::size_t rexlib::joint_layout::seek |
( |
joint_cursor & |
ite, |
|
|
std::size_t |
position, |
|
|
std::size_t |
first_dim = 0, |
|
|
std::size_t |
last_dim = end_dim |
|
) |
| const |
Populate a cursor for traversing this layout, positioned at a given point of the traversal.
The position counts the way the traversal does, first_dim varying fastest, so that a range of it names a contiguous stretch of the very iteration next() performs: two cursors splitting that range visit between them exactly what one cursor visits alone. This is what lets an iteration be shared out, whether over threads or over anything else.
seek(ite, 0, ...) is iter(ite, ...).
- Parameters
-
| ite | The iterator to be populated. |
| position | Index into the iterated range, counting first_dim fastest. Must be less than the number of positions that range holds. Otherwise behavior is undefined. |
| first_dim | Index of the inner-most dimension to be iterated. Must be less or equal to get_rank(). Defaults to zero. |
| last_dim | Index of the outer-most dimension to be iterated. Must be less or equal to get_rank() or equal to end_dim. Defaults to end_dim. |
- Returns
- std::size_t Number of remaining elements in the inner-most iterated dimension, as
iter() reports it. 0 if the layout can not be iterated.
◆ end_dim
| REXLIB_CONST_CONSTEXPR std::size_t rexlib::joint_layout::end_dim |
|
static |
Initial value:=
std::numeric_limits<std::size_t>::max()
Constant value to be passed to the last_dim parameter of iter() and next() to signal the past-the-end axis of the layout.
The documentation for this class was generated from the following file: