20 #ifndef RAJA_RangeSegment_HPP
21 #define RAJA_RangeSegment_HPP
23 #include "RAJA/config.hpp"
97 template<
typename StorageT,
98 typename DiffT = make_signed_t<strip_index_type_t<StorageT>>>
106 static_assert(std::is_signed<DiffT>::value,
107 "TypedRangeSegment DiffT requires signed type.");
108 static_assert(!std::is_floating_point<StorageT>::value,
109 "TypedRangeSegment Type must be non floating point.");
190 return m_begin == o.m_begin && m_end == o.m_end;
230 StorageT start = m_begin[0] +
begin;
231 StorageT
end = start + length > m_end[0] ? m_end[0] : start + length;
241 camp::safe_swap(m_begin, other.m_begin);
242 camp::safe_swap(m_end, other.m_end);
330 template<
typename StorageT,
331 typename DiffT = make_signed_t<strip_index_type_t<StorageT>>>
339 static_assert(std::is_signed<DiffT>::value,
340 "TypedRangeStrideSegment DiffT requires signed type.");
341 static_assert(!std::is_floating_point<StorageT>::value,
342 "TypedRangeStrideSegment Type must be non floating point.");
378 m_size((
end -
begin + stride - (stride > 0 ? 1 : -1)) / stride)
381 if (stride < 0 && end >
begin)
390 m_size = m_size < DiffT {0} ? DiffT {0} : m_size;
444 return m_begin == o.m_begin && m_end == o.m_end && m_size == o.m_size;
490 StorageT start = m_begin[0] +
begin * stride;
491 StorageT
end = start + stride * length;
511 camp::safe_swap(m_begin, other.m_begin);
512 camp::safe_swap(m_end, other.m_end);
513 camp::safe_swap(m_size, other.m_size);
536 template<
typename T,
typename... Rest>
538 : std::common_type<T, typename std::common_type<Rest...>::type>
547 template<
typename... Ts>
560 template<
typename BeginT,
578 template<
typename BeginT,
581 typename Common = detail::common_type_t<BeginT, EndT>>
587 static_assert(std::is_signed<StrideT>::value,
588 "make_strided_segment : stride must be signed.");
591 "make_stride_segment : stride and end must be of similar types.");
592 return {begin, end, stride};
598 template<
typename T,
typename U>
600 : DefineConcept(camp::val<RAJA::detail::common_type_t<T, U>>()) {};
602 template<
typename T,
typename U,
typename V>
604 : DefineConcept(camp::val<RAJA::detail::common_type_t<T, U, V>>()) {};
608 namespace type_traits
RAJA header file for strongly-typed integer class.
Header file for RAJA iterator constructs.
Definition: Iterators.hpp:114
Definition: Iterators.hpp:304
RAJA_HOST_DEVICE DifferenceType get_stride() const
Definition: Iterators.hpp:330
Header file for RAJA concept definitions.
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
typename common_type< Ts... >::type common_type_t
Definition: RangeSegment.hpp:548
DefineTypeTraitFromConcept(is_range_constructible, RAJA::concepts::RangeConstructible)
Definition: AlignedRangeIndexSetBuilders.cpp:35
typename internal::StripIndexTypeT< FROM >::type strip_index_type_t
Strips a strongly typed index to its underlying type In the case of a non-strongly typed index,...
Definition: IndexValue.hpp:364
RAJA_HOST_DEVICE TypedRangeStrideSegment< Common > make_strided_range(BeginT &&begin, EndT &&end, StrideT &&stride)
Function to make a TypedRangeStride Segment for the interval [begin, end) with given stride.
Definition: RangeSegment.hpp:582
constexpr RAJA_HOST_DEVICE RAJA_INLINE std::enable_if< std::is_base_of< IndexValueBase, FROM >::value, typename FROM::value_type >::type stripIndexType(FROM const val)
Function that strips the strongly typed Index<> and returns its underlying value_type value.
Definition: IndexValue.hpp:323
RAJA_HOST_DEVICE TypedRangeSegment< Common > make_range(BeginT &&begin, EndT &&end)
Function to make a TypedRangeSegment for the interval [begin, end)
Definition: RangeSegment.hpp:563
typename std::conditional< std::is_floating_point< FROM >::value, std::common_type< FROM >, std::make_signed< FROM > >::type::type make_signed_t
Converts a type into a signed type. Also handles floating point types as std::make_signed only suppor...
Definition: IndexValue.hpp:376
Definition: ListSegment.hpp:416
RAJA_INLINE void swap(RAJA::TypedListSegment< StorageT > &a, RAJA::TypedListSegment< StorageT > &b)
Specialization of std::swap for TypedListSegment.
Definition: ListSegment.hpp:420
Segment class representing a contiguous range of typed indices.
Definition: RangeSegment.hpp:100
DiffT IndexType
The underlying type for a difference in index values.
Definition: RangeSegment.hpp:121
RAJA_HOST_DEVICE RAJA_INLINE bool operator!=(TypedRangeSegment const &o) const
Compare this segment to another for inequality.
Definition: RangeSegment.hpp:198
RAJA_INLINE TypedRangeSegment & operator=(TypedRangeSegment const &)=default
Defaulted copy assignment operator.
strip_index_type_t< StorageT > StripStorageT
Construct a range segment repreenting the interval [begin, end)
Definition: RangeSegment.hpp:134
Iterators::numeric_iterator< StorageT, DiffT > iterator
The underlying iterator type.
Definition: RangeSegment.hpp:115
RAJA_HOST_DEVICE RAJA_INLINE DiffT size() const
Get size of this segment (end - begin)
Definition: RangeSegment.hpp:175
RAJA_HOST_DEVICE RAJA_INLINE iterator end() const
Get iterator to the end of this segment.
Definition: RangeSegment.hpp:170
RAJA_HOST_DEVICE RAJA_INLINE iterator begin() const
Get iterator to the beginning of this segment.
Definition: RangeSegment.hpp:165
RAJA_HOST_DEVICE RAJA_INLINE TypedRangeSegment slice(StorageT begin, DiffT length) const
Get a new TypedRangeSegment instance representing a slice of existing segment.
Definition: RangeSegment.hpp:227
constexpr RAJA_HOST_DEVICE TypedRangeSegment(StripStorageT begin, StripStorageT end)
Definition: RangeSegment.hpp:136
RAJA_HOST_DEVICE RAJA_INLINE bool operator==(TypedRangeSegment const &o) const
Compare this segment to another for equality.
Definition: RangeSegment.hpp:187
constexpr TypedRangeSegment(TypedRangeSegment &&)=default
Defaulted move constructor.
RAJA_HOST_DEVICE RAJA_INLINE void swap(TypedRangeSegment &other)
Swap this segment with another.
Definition: RangeSegment.hpp:239
RAJA_HOST_DEVICE TypedRangeSegment()=delete
Disable compiler generated constructor.
constexpr TypedRangeSegment(TypedRangeSegment const &)=default
Defaulted copy constructor.
RAJA_INLINE ~TypedRangeSegment()=default
Defaulted destructor.
StorageT value_type
The underlying value type.
Definition: RangeSegment.hpp:118
Segment class representing a strided range of typed indices.
Definition: RangeSegment.hpp:333
strip_index_type_t< StorageT > StripStorageT
Construct a range segment for the interval [begin, end) with given stride.
Definition: RangeSegment.hpp:369
RAJA_HOST_DEVICE iterator begin() const
Get iterator to the beginning of this segment.
Definition: RangeSegment.hpp:416
TypedRangeStrideSegment(TypedRangeStrideSegment &&)=default
Defaulted move constructor.
StorageT value_type
The underlying value type.
Definition: RangeSegment.hpp:351
Iterators::strided_numeric_iterator< StorageT, DiffT > iterator
The underlying iterator type.
Definition: RangeSegment.hpp:348
RAJA_HOST_DEVICE TypedRangeStrideSegment slice(StorageT begin, DiffT length) const
Get a new TypedRangeStrideSegment instance representing a slice of existing segment.
Definition: RangeSegment.hpp:486
RAJA_HOST_DEVICE RAJA_INLINE bool operator!=(TypedRangeStrideSegment const &o) const
Compare this segment to another for inequality.
Definition: RangeSegment.hpp:452
~TypedRangeStrideSegment()=default
Defaulted destructore.
RAJA_HOST_DEVICE bool operator==(TypedRangeStrideSegment const &o) const
Compare this segment to another for equality.
Definition: RangeSegment.hpp:441
RAJA_HOST_DEVICE void swap(TypedRangeStrideSegment &other)
Swap this segment with another.
Definition: RangeSegment.hpp:509
TypedRangeStrideSegment()=delete
Disable compiler generated constructor.
TypedRangeStrideSegment(TypedRangeStrideSegment const &)=default
Defaulted copy constructor.
RAJA_HOST_DEVICE iterator end() const
Get iterator to the end of this segment.
Definition: RangeSegment.hpp:421
DiffT IndexType
The underlying type for a difference in index values.
Definition: RangeSegment.hpp:354
RAJA_HOST_DEVICE DiffT size() const
Get size of this segment.
Definition: RangeSegment.hpp:429
TypedRangeStrideSegment & operator=(TypedRangeStrideSegment const &)=default
Defaulted copy assignment operator.
RAJA_HOST_DEVICE TypedRangeStrideSegment(StripStorageT begin, StripStorageT end, DiffT stride)
Definition: RangeSegment.hpp:371
Definition: RangeSegment.hpp:600
Definition: RangeSegment.hpp:604
T type
Definition: RangeSegment.hpp:544
Definition: RangeSegment.hpp:539