RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
ForICount.hpp
Go to the documentation of this file.
1 
11 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
12 // Copyright (c) Lawrence Livermore National Security, LLC and other
13 // RAJA Project Developers. See top-level LICENSE and COPYRIGHT
14 // files for dates and other details. No copyright assignment is required
15 // to contribute to RAJA.
16 //
17 // SPDX-License-Identifier: (BSD-3-Clause)
18 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
19 
20 #ifndef RAJA_pattern_kernel_ForICount_HPP
21 #define RAJA_pattern_kernel_ForICount_HPP
22 
23 #include "RAJA/config.hpp"
24 
25 #include <iostream>
26 #include <type_traits>
27 
30 
31 namespace RAJA
32 {
33 
34 namespace statement
35 {
36 
37 
44 template<camp::idx_t ArgumentId,
45  typename ParamId,
46  typename ExecPolicy = camp::nil,
47  typename... EnclosedStmts>
48 struct ForICount : public internal::ForList,
49  public internal::ForTraitBase<ArgumentId, ExecPolicy>,
50  public internal::Statement<ExecPolicy, EnclosedStmts...>
51 {
52 
53  static_assert(std::is_base_of<RAJA::expt::detail::ParamBase, ParamId>::value,
54  "Inappropriate ParamId, ParamId must be of type "
55  "RAJA::Statement::Param< # >");
56  // TODO: add static_assert for valid policy in Pol
58 };
59 
60 } // end namespace statement
61 
62 namespace internal
63 {
64 
70 template<camp::idx_t ArgumentId,
71  typename ParamId,
72  typename Data,
73  typename Types,
74  typename... EnclosedStmts>
75 struct ForICountWrapper : public GenericWrapper<Data, Types, EnclosedStmts...>
76 {
77 
78  using Base = GenericWrapper<Data, Types, EnclosedStmts...>;
79  using Base::Base;
81 
82  template<typename InIndexType>
83  RAJA_INLINE void operator()(InIndexType i)
84  {
85  Base::data.template assign_offset<ArgumentId>(i);
86  Base::data.template assign_param<ParamId>(i);
87  Base::exec();
88  }
89 };
90 
96 template<camp::idx_t ArgumentId,
97  typename ParamId,
98  typename ExecPolicy,
99  typename... EnclosedStmts,
100  typename Types>
102  statement::ForICount<ArgumentId, ParamId, ExecPolicy, EnclosedStmts...>,
103  Types>
104 {
105 
106 
107  template<typename Data>
108  static RAJA_INLINE void exec(Data&& data)
109  {
110 
111  // Set the argument type for this loop
113 
114  // Create a wrapper, just in case forall_impl needs to thread_privatize
115  ForICountWrapper<ArgumentId, ParamId, Data, NewTypes, EnclosedStmts...>
116  for_wrapper(data);
117 
118  auto len = segment_length<ArgumentId>(data);
119  using len_t = decltype(len);
120 
122 
123  forall_impl(r, ExecPolicy {}, TypedRangeSegment<len_t>(0, len), for_wrapper,
124  RAJA::expt::get_empty_forall_param_pack());
125  }
126 };
127 
128 
129 } // namespace internal
130 } // end namespace RAJA
131 
132 
133 #endif /* RAJA_pattern_nested_HPP */
Header file for kernel conditional templates.
setSegmentType< Types, Segment, camp::at_v< typename camp::decay< Data >::index_types_t, Segment > > setSegmentTypeFromData
Definition: LoopTypes.hpp:95
RAJA_INLINE void forall_impl(MultiPolicy< Selector, Policies... > p, Iterable &&iter, Body &&body)
Definition: MultiPolicy.hpp:96
Definition: AlignedRangeIndexSetBuilders.cpp:35
Header file for loop kernel internals.
Segment class representing a contiguous range of typed indices.
Definition: RangeSegment.hpp:100
Definition: ForICount.hpp:76
RAJA_INLINE void operator()(InIndexType i)
Definition: ForICount.hpp:83
Definition: LoopData.hpp:48
Definition: LoopData.hpp:58
Definition: LoopData.hpp:196
RAJA_INLINE void exec()
Definition: LoopData.hpp:205
Definition: LoopData.hpp:216
Definition: Statement.hpp:48
Definition: Statement.hpp:35
Definition: IndexSet.hpp:70
Definition: resource.hpp:48
Definition: ForICount.hpp:51