20 #ifndef RAJA_CombingAdapter_HPP
21 #define RAJA_CombingAdapter_HPP
23 #include <type_traits>
82 template<
typename Lambda,
typename Layout_>
91 using DimArr =
typename Layout::DimArr;
100 template<camp::idx_t... RangeInts>
102 camp::idx_seq<RangeInts...>)
103 -> decltype(m_lambda(
104 camp::val<camp::tuple_element_t<RangeInts, DimTuple>>()...))
107 m_layout.toIndices(linear_index, camp::get<RangeInts>(indices)...);
108 return m_lambda(camp::get<RangeInts>(indices)...);
113 template<camp::idx_t... RangeInts>
115 camp::idx_seq<RangeInts...>)
const
116 -> decltype(m_lambda(
117 camp::val<camp::tuple_element_t<RangeInts, DimTuple>>()...))
120 m_layout.toIndices(linear_index, camp::get<RangeInts>(indices)...);
121 return m_lambda(camp::get<RangeInts>(indices)...);
128 template<
typename C_Lambda,
typename C_Layout>
130 : m_lambda(
std::forward<C_Lambda>(lambda)),
131 m_layout(
std::forward<C_Layout>(layout))
140 -> decltype(call_helper(linear_index,
IndexRange()))
142 return call_helper(linear_index,
IndexRange());
147 -> decltype(call_helper(linear_index,
IndexRange()))
149 return call_helper(linear_index,
IndexRange());
159 return m_layout.size_noproj();
213 template<
typename Lambda,
typename Layout>
220 std::forward<Lambda>(lambda), std::forward<Layout>(layout));
224 template<
typename Lambda,
typename... IdxTs>
236 using IdxLin =
typename std::common_type<strip_index_type_t<IdxTs>...>::type;
240 Layout layout(
static_cast<IdxLin
>(distance(begin(segs), end(segs)))...);
241 OffsetLayout offset_layout = OffsetLayout::from_layout_and_offsets(
242 {{(distance(begin(segs), end(segs)) ?
static_cast<IdxLin
>(*begin(segs))
243 :
static_cast<IdxLin
>(0))...}},
246 std::move(offset_layout));
250 template<
typename Perm,
typename Lambda,
typename... IdxTs>
262 using IdxLin =
typename std::common_type<strip_index_type_t<IdxTs>...>::type;
266 {{
static_cast<IdxLin
>(distance(begin(segs), end(segs)))...}},
268 OffsetLayout offset_layout = OffsetLayout::from_layout_and_offsets(
269 {{(distance(begin(segs), end(segs)) ?
static_cast<IdxLin
>(*begin(segs))
270 :
static_cast<IdxLin
>(0))...}},
274 std::move(offset_layout));
RAJA header file defining Layout, a N-dimensional index calculator.
RAJA header file defining Layout, a N-dimensional index calculator with offset indices.
Header file containing definitions of RAJA range segment classes.
Header file with aliases to camp types.
Header file for RAJA concept definitions.
Header file for common RAJA internal macro definitions.
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
#define RAJA_SUPPRESS_HD_WARN
Definition: macros.hpp:68
Definition: AlignedRangeIndexSetBuilders.cpp:35
RAJA_HOST_DEVICE RAJA_INLINE auto make_CombiningAdapter_from_layout(Lambda &&lambda, Layout &&layout)
Creates a CombiningAdapter class from a lambda and segments.
Definition: CombiningAdapter.hpp:214
RAJA_SUPPRESS_HD_WARN RAJA_INLINE auto make_CombiningAdapter(Lambda &&lambda, ::RAJA::TypedRangeSegment< IdxTs > const &... segs)
Definition: CombiningAdapter.hpp:225
RAJA_HOST_DEVICE constexpr RAJA_INLINE RAJA::zip_tuple_element_t< I, zip_tuple< is_val, Ts... > > & get(zip_tuple< is_val, Ts... > &z) noexcept
Definition: zip_tuple.hpp:56
RAJA_SUPPRESS_HD_WARN RAJA_INLINE auto make_PermutedCombiningAdapter(Lambda &&lambda, ::RAJA::TypedRangeSegment< IdxTs > const &... segs)
Definition: CombiningAdapter.hpp:251
camp::idx_seq< Ints... > Perm
Definition: PermutedLayout.hpp:101
constexpr RAJA_INLINE RAJA_HOST_DEVICE auto make_permuted_layout(std::array< IdxLin, Rank > sizes, std::array< camp::idx_t, Rank > permutation) -> Layout< Rank, IdxLin >
Creates a permuted Layout object.
Definition: PermutedLayout.hpp:66
Definition: ListSegment.hpp:416
A holder for adapting lambdas meant for multidimensional index spaces to allow their use in 1-dimensi...
Definition: CombiningAdapter.hpp:84
RAJA_HOST_DEVICE RAJA_INLINE auto operator()(IndexLinear linear_index) -> decltype(call_helper(linear_index, IndexRange()))
Definition: CombiningAdapter.hpp:139
Layout_ Layout
Definition: CombiningAdapter.hpp:85
RAJA_HOST_DEVICE RAJA_INLINE IndexLinear size() const
Definition: CombiningAdapter.hpp:157
RAJA_HOST_DEVICE CombiningAdapter(C_Lambda &&lambda, C_Layout &&layout)
Definition: CombiningAdapter.hpp:129
typename Layout::IndexRange IndexRange
Definition: CombiningAdapter.hpp:87
RAJA_HOST_DEVICE RAJA_INLINE auto operator()(IndexLinear linear_index) const -> decltype(call_helper(linear_index, IndexRange()))
Definition: CombiningAdapter.hpp:146
RAJA_HOST_DEVICE RAJA_INLINE RangeLinear getRange() const
Definition: CombiningAdapter.hpp:168
RAJA::TypedRangeSegment< IndexLinear > RangeLinear
Definition: CombiningAdapter.hpp:93
typename Layout::IndexLinear IndexLinear
Definition: CombiningAdapter.hpp:89
typename Layout::DimArr DimArr
Definition: CombiningAdapter.hpp:91
typename Layout::StrippedIdxLin StrippedIdxLin
Definition: CombiningAdapter.hpp:88
typename Layout::DimTuple DimTuple
Definition: CombiningAdapter.hpp:90
Definition: OffsetLayout.hpp:172
Definition: OffsetLayout.hpp:188
Segment class representing a contiguous range of typed indices.
Definition: RangeSegment.hpp:100
Definition: Layout.hpp:46