Shortcuts

Template Class IndexedIterator

Inheritance Relationships

Base Type

Class Documentation

template<typename T, typename Space>
class ripple::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.

using Indices = Vec<Index, BlockIter::dims>

Defines the type of the contianer used to store the indices.

using Coordinate = Coord<dims>

Defines the type for the coordinates of the iterator.

using Coordinatef = Vec<Value, dims>

Defines the type for the normalized coordinates of 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 auto offset(Dim &&dim, int amount = 1) const noexcept -> IndexedIterator

Offsets the iterator by amount positions in the block in the dim dimension.

Return

A new iterator to the offset location.

Parameters
  • dim: The dimension to offset in

  • amount: The amount to offset by.

Template Parameters
  • Dim: The type of the dimension specifier.

template<typename Dim>
auto block_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>
auto set_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>
auto global_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>
auto set_global_size(Dim &&dim, Index size) noexcept -> void

Sets the size of the global space to which the block belongs for dimension dim to size.

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>
auto global_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>
auto normalized_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>
auto is_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>
auto is_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.

Public Static Attributes

constexpr size_t dims = BlockIter::dims

The number of dimensions for the iterator.

Docs

Access comprehensive developer documentation for Ripple

View Docs

Tutorials

Get tutorials to help with understand all features

View Tutorials

Examples

Find examples to help get started

View Examples