|
RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
|
Segment class representing a contiguous range of typed indices. More...
#include <RangeSegment.hpp>
Public Types | |
Types used in implementation based on template parameters. | |
| using | iterator = Iterators::numeric_iterator< StorageT, DiffT > |
| The underlying iterator type. More... | |
| using | value_type = StorageT |
| The underlying value type. More... | |
| using | IndexType = DiffT |
| The underlying type for a difference in index values. More... | |
Public Member Functions | |
Accessor methods | |
| RAJA_HOST_DEVICE RAJA_INLINE iterator | begin () const |
| Get iterator to the beginning of this segment. More... | |
| RAJA_HOST_DEVICE RAJA_INLINE iterator | end () const |
| Get iterator to the end of this segment. More... | |
| RAJA_HOST_DEVICE RAJA_INLINE DiffT | size () const |
| Get size of this segment (end - begin) More... | |
Constructors, destructor, and copy assignment. | |
| using | StripStorageT = strip_index_type_t< StorageT > |
| Construct a range segment repreenting the interval [begin, end) More... | |
| constexpr RAJA_HOST_DEVICE | TypedRangeSegment (StripStorageT begin, StripStorageT end) |
| RAJA_HOST_DEVICE | TypedRangeSegment ()=delete |
| Disable compiler generated constructor. More... | |
| constexpr | TypedRangeSegment (TypedRangeSegment &&)=default |
| Defaulted move constructor. More... | |
| constexpr | TypedRangeSegment (TypedRangeSegment const &)=default |
| Defaulted copy constructor. More... | |
| RAJA_INLINE TypedRangeSegment & | operator= (TypedRangeSegment const &)=default |
| Defaulted copy assignment operator. More... | |
| RAJA_INLINE | ~TypedRangeSegment ()=default |
| Defaulted destructor. More... | |
Segment comparison methods | |
| RAJA_HOST_DEVICE RAJA_INLINE bool | operator== (TypedRangeSegment const &o) const |
| Compare this segment to another for equality. More... | |
| RAJA_HOST_DEVICE RAJA_INLINE bool | operator!= (TypedRangeSegment const &o) const |
| Compare this segment to another for inequality. More... | |
| RAJA_HOST_DEVICE RAJA_INLINE TypedRangeSegment | slice (StorageT begin, DiffT length) const |
| Get a new TypedRangeSegment instance representing a slice of existing segment. More... | |
| RAJA_HOST_DEVICE RAJA_INLINE void | swap (TypedRangeSegment &other) |
| Swap this segment with another. More... | |
Segment class representing a contiguous range of typed indices.
| StorageT | underlying data type for the segment indices (required) |
| DiffT | underlying data type for the difference between two segment indices (optional) |
A TypedRangeSegment models an Iterable interface:
begin() – returns an iterator (TypedRangeSegment::iterator) end() – returns an iterator (TypedRangeSegment::iterator) size() – returns the total size of the Segment iteration space (DiffT)
NOTE: TypedRangeSegment::iterator is a RandomAccessIterator
NOTE: TypedRangeSegment supports negative indices; e.g., an interval of indices [-5, 3).
NOTE: Proper handling of indices strides requires that StorageT is a signed type.
Usage:
A common C-style loop traversal pattern would be:
* for (T i = begin; i < end; ++i) {
* // loop body -- use i as index value
* }
* Using a TypedRangeSegment, this becomes:
* TypedRangeSegment<T> seg (begin, end);
* for (auto i = seg.begin(); i != seg.end(); ++i) {
* // loop body -- use (*i) as index value
* }
* This can also be used in a C++11 style range-based for:
* for (auto i : TypedRangeSegment<T>(begin, end)) {
* // loop body -- use i as index value
* }
* Or, as it would be commonly used with a RAJA forall execution template:
* forall<exec_pol>(TypedRangeSegment<T>(beg, end), [=] (T i) {
* // loop body -- use i as index value
* });
* | using RAJA::TypedRangeSegment< StorageT, DiffT >::iterator = Iterators::numeric_iterator<StorageT, DiffT> |
The underlying iterator type.
| using RAJA::TypedRangeSegment< StorageT, DiffT >::value_type = StorageT |
The underlying value type.
| using RAJA::TypedRangeSegment< StorageT, DiffT >::IndexType = DiffT |
The underlying type for a difference in index values.
| using RAJA::TypedRangeSegment< StorageT, DiffT >::StripStorageT = strip_index_type_t<StorageT> |
Construct a range segment repreenting the interval [begin, end)
| begin | start value (inclusive) for the range |
| end | end value (exclusive) for the range |
|
inlineconstexpr |
|
delete |
Disable compiler generated constructor.
|
constexprdefault |
Defaulted move constructor.
|
constexprdefault |
Defaulted copy constructor.
|
default |
Defaulted destructor.
|
default |
Defaulted copy assignment operator.
|
inline |
Get iterator to the beginning of this segment.
|
inline |
Get iterator to the end of this segment.
|
inline |
Get size of this segment (end - begin)
|
inline |
Compare this segment to another for equality.
|
inline |
Compare this segment to another for inequality.
|
inline |
Get a new TypedRangeSegment instance representing a slice of existing segment.
| begin | start iterate of new range |
| length | maximum length of new range |
Here's an example of a slice operation on a range segment with negative indices:
* * // r represents the index interval [-4, 4) * auto r = RAJA::TypedRangeSegment<int>(-4, 4); * * // s repreents the subinterval [-3, 2) * auto s = r.slice(1, 5); * *
|
inline |
Swap this segment with another.