RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
TileTCount.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_TileTCount_HPP
21 #define RAJA_pattern_kernel_TileTCount_HPP
22 
23 #include "RAJA/config.hpp"
24 
25 #include <iostream>
26 #include <type_traits>
27 
28 #include "camp/camp.hpp"
29 #include "camp/concepts.hpp"
30 #include "camp/tuple.hpp"
31 
33 #include "RAJA/util/macros.hpp"
34 #include "RAJA/util/types.hpp"
35 
36 namespace RAJA
37 {
38 namespace statement
39 {
40 
41 
47 template<camp::idx_t ArgumentId,
48  typename ParamId,
49  typename TilePolicy,
50  typename ExecPolicy,
51  typename... EnclosedStmts>
52 struct TileTCount : public internal::Statement<ExecPolicy, EnclosedStmts...>
53 {
54  static_assert(std::is_base_of<RAJA::expt::detail::ParamBase, ParamId>::value,
55  "Inappropriate ParamId, ParamId must be of type "
56  "RAJA::Statement::Param< # >");
57  using tile_policy_t = TilePolicy;
59 };
60 
61 
62 } // end namespace statement
63 
64 namespace internal
65 {
66 
72 template<camp::idx_t ArgumentId,
73  typename ParamId,
74  typename Data,
75  typename Types,
76  typename... EnclosedStmts>
77 struct TileTCountWrapper : public GenericWrapper<Data, Types, EnclosedStmts...>
78 {
79 
80  using Base = GenericWrapper<Data, Types, EnclosedStmts...>;
81  using Base::Base;
83 
84  template<typename InSegmentIndexType>
85  RAJA_INLINE void operator()(InSegmentIndexType si)
86  {
87  // Assign the tile's segment to the tuple
88  camp::get<ArgumentId>(Base::data.segment_tuple) = si.s;
89 
90  // Assign the tile's index
91  Base::data.template assign_param<ParamId>(si.i);
92 
93  // Execute enclosed statements
94  Base::exec();
95  }
96 };
97 
103 template<camp::idx_t ArgumentId,
104  typename ParamId,
105  typename TPol,
106  typename EPol,
107  typename... EnclosedStmts,
108  typename Types>
110  statement::TileTCount<ArgumentId, ParamId, TPol, EPol, EnclosedStmts...>,
111  Types>
112 {
113 
114 
115  template<typename Data>
116  static RAJA_INLINE void exec(Data& data)
117  {
118  // Get the segment we are going to tile
119  auto const& segment = camp::get<ArgumentId>(data.segment_tuple);
120 
121  // Get the tiling policies chunk size
122  auto chunk_size = TPol::chunk_size;
123 
124  // Create a tile iterator, needs to survive until the forall is
125  // done executing.
126  IterableTiler<decltype(segment)> tiled_iterable(segment, chunk_size);
127 
128  // Wrap in case forall_impl needs to thread_privatize
129  TileTCountWrapper<ArgumentId, ParamId, Data, Types, EnclosedStmts...>
130  tile_wrapper(data);
131 
132  // Loop over tiles, executing enclosed statement list
134  forall_impl(r, EPol {}, tiled_iterable, tile_wrapper,
135  RAJA::expt::get_empty_forall_param_pack());
136 
137  // Set range back to original values
138  camp::get<ArgumentId>(data.segment_tuple) = tiled_iterable.it;
139  }
140 };
141 
142 
143 } // end namespace internal
144 } // end namespace RAJA
145 
146 #endif /* RAJA_pattern_kernel_HPP */
Header file for common RAJA internal macro definitions.
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.
Definition: LoopData.hpp:196
RAJA_INLINE void exec()
Definition: LoopData.hpp:205
Definition: Tile.hpp:114
value_type it
Definition: Tile.hpp:222
Definition: LoopData.hpp:216
Definition: Statement.hpp:48
Definition: Statement.hpp:35
Definition: TileTCount.hpp:78
RAJA_INLINE void operator()(InSegmentIndexType si)
Definition: TileTCount.hpp:85
Definition: IndexSet.hpp:70
Definition: resource.hpp:48
Definition: TileTCount.hpp:53
TilePolicy tile_policy_t
Definition: TileTCount.hpp:57
Header file for RAJA type definitions.