Template Class IndexedIterator¶
Defined in File indexed_iterator.hpp
Inheritance Relationships¶
Base Type¶
public ripple::BlockIterator< T, Space >
(Template Class BlockIterator)
Class Documentation¶
-
template<typename
T
, typenameSpace
>
classripple
::
IndexedIterator
: public ripple::BlockIterator<T, Space>¶ The IndexedIterator class is an extended BlockIterator, with additional information which provides it with context for where the block is relative to the global space to which it belongs.
It also allows the thread indidces to be determined.
For this iterator, the global size and index data allow the iterator to be used to implement consistent interfaces for iteration across a global space which is split across multiple devices, which is the primary purpose of the class.
The type T for the iterator can be either a normal type, or a type which implements the StridableLayout interface, which allows the data to be stored and iterated as SoA instead of AoS. Regardless, the use is the same, and the iterator semantics are as if it was a poitner to T.
- Todo:
The storage of the additional index and size data for the iterator increases the register usage in device code, which needs to be improved.
It also allows the thread indidces to be determined.
- Template Parameters
T
: The data type which the iterator will access.Space
: The type which defines the iteration space.
For this iterator, the global size and index data allow the iterator to be used to implement consistent interfaces for iteration across a global space which is split across multiple devices, which is the primary purpose of the class.
The type T for the iterator can be either a normal type, or a type which implements the StridableLayout interface, which allows the data to be stored and iterated as SoA instead of AoS. Regardless, the use is the same, and the iterator semantics are as if it was a poitner to T.
- Template Parameters
T
: The data type which the iterator will access.Space
: The type which defines the iteration space.
Public Types
-
using
BlockIter
= BlockIterator<T, Space>¶ Defines the type of the base class.
-
using
Index
= int32_t¶ Defines the index type used for the iterator.
Public Functions
-
IndexedIterator
(BlockIter block_iter) noexcept¶ Constuctor to copy a BlockIterator
block_iter
into this iterator.- Parameters
block_iter
: The block iterator to use to set this iterator.
-
template<typename
Dim
>
constexpr autooffset
(Dim &&dim, int amount = 1) const noexcept -> IndexedIterator¶ Offsets the iterator by
amount
positions in the block in thedim
dimension.- Return
A new iterator to the offset location.
- Parameters
dim
: The dimension to offset inamount
: The amount to offset by.
- Template Parameters
Dim
: The type of the dimension specifier.
-
template<typename
Dim
>
autoblock_start_index
(Dim &&dim) const noexcept -> Index¶ Gets the thread index of the start of the block which this iterator can iterate over.
- Return
The first thread index in the dimension which this iterator can iterate from.
- Parameters
dim
: The dimension to get the block start index for.
- Template Parameters
Dim
: The type of the dimension specifier.
-
template<typename
Dim
>
autoset_block_start_index
(Dim &&dim, Index index) noexcept -> void¶ Sets the index of the first thread which this iterator can iterate from in the iteration space for the given dimension.
- Parameters
dim
: The dimension to set the block index for.index
: The index to set the start of the block to.
- Template Parameters
Dim
: The type of the dimension specifier.
-
template<typename
Dim
>
autoglobal_size
(Dim &&dim) const noexcept -> Index¶ Gets the size of the global space to which the block which can be iterated over can belongs for a given dimension (the total number of threads).
- Return
The number of elements in the dimension in the global space to which this iterator belongs.
- Parameters
dim
: The dimension to get the global size for.
- Template Parameters
Dim
: The type of the dimension specifier.
-
template<typename
Dim
>
autoset_global_size
(Dim &&dim, Index size) noexcept -> void¶ Sets the size of the global space to which the block belongs for dimension
dim
tosize
.- Parameters
dim
: The dimension to set the size for.size
: The size for the dimension.
- Template Parameters
Dim
: The type of the dimension specifier.
-
template<typename
Dim
>
autoglobal_idx
(Dim &&dim) const noexcept -> size_t¶ Gets the global index of the data to which this iterator points, in the global space for which this iterator can iterate a sub region.
- Return
The index of this iterator in the global space.
- Parameters
dim
: The dimension to get the global index for.
- Template Parameters
Dim
: The type of the dimension specifier.
-
template<typename
Dim
>
autonormalized_idx
(Dim &&dim) const noexcept -> double¶ Gets the global normalized index of the pointed to element for the iterator in the
dim
dimension.- Return
The global normalized index of the iterator in the global iteration space.
- Parameters
dim
: The dimension to get the global normalzies index for.
- Template Parameters
Dim
: The type of the dimension specifier.
-
template<typename
Dim
>
autois_valid
(Dim &&dim) const noexcept -> bool¶ Determines if the iterator is valid for the
dim
dimension.It is valid if its index is less than the number of elements in the dimension.
- Return
true if the iterator is valid for the dimension.
- Parameters
dim
: The dimension to check validity in.
- Template Parameters
Dim
: The type of the dimension specifier.
-
template<typename
Dim
>
autois_valid
(Dim &&dim, Index extra) const noexcept -> bool¶ Determines if the iterator is valid for the
dim
dimension.It is valid if its index is less than the number of elements in the dimension.
- Return
true if the iterator is valid for the dimension.
- Parameters
dim
: The dimension to check validity in.
- Template Parameters
Dim
: The type of the dimension specifier.
-
auto
coord
() noexcept -> Coordinate¶ Gets the co-ordinates of the iterator in the global space.
- Return
The co-ordinates of the iterator in the global space.
-
auto
norm_coord
() noexcept -> Coordinatef¶ Gets the co-ordinates of the iterator in the global space normalized to the 0 -> 1 range.
- Return
The co-ordinates of the iterator in the global space.
-
auto
scaled_norm_coord
(Coordinatef sizes) noexcept -> Coordinatef¶ Gets the scaled coordinated for a domain with absolute sizes specified by the
sizes
.- Parameters
sizes
: The sizes of the dimensions for the iteration space.
-
auto
first_in_global_space
() const noexcept -> bool¶ Determines if this is the first iterator in the global space, that is, it’s the first valid iterator in each dimensions of the space.
- Return
true if this is the first iterator in the global space.
-
auto
last_in_global_space
() const noexcept -> bool¶ Determines if this is the last iterator in the global space, that is, it’s the last valid iterator in each dimensions of the space.
- Return
true if this is the last iterator in the global space.