RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
Collapse.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_policy_sequential_kernel_Collapse_HPP
21 #define RAJA_policy_sequential_kernel_Collapse_HPP
22 
23 #include "RAJA/pattern/kernel.hpp"
24 
25 namespace RAJA
26 {
27 
28 namespace internal
29 {
30 
31 
32 //
33 // Termination case for seq_exec collapsed loops
34 //
35 template<typename... EnclosedStmts, typename Types>
37  statement::Collapse<seq_exec, ArgList<>, EnclosedStmts...>,
38  Types>
39 {
40 
41  template<typename Data>
42  static RAJA_INLINE void exec(Data& data)
43  {
44  // termination case: no more loops, just execute enclosed statements
45  execute_statement_list<camp::list<EnclosedStmts...>, Types>(data);
46  }
47 };
48 
49 //
50 // Executor that handles collapsing of an arbitrarily deep set of seq_exec
51 // loops
52 //
53 template<camp::idx_t Arg0,
54  camp::idx_t... ArgRest,
55  typename... EnclosedStmts,
56  typename Types>
58  statement::Collapse<seq_exec, ArgList<Arg0, ArgRest...>, EnclosedStmts...>,
59  Types>
60 {
61 
62  template<typename Data>
63  static RAJA_INLINE void exec(Data& data)
64  {
65 
66  // Set the argument type for this loop
68 
69  // compute next-most inner loop Executor
70  using next_loop_t = StatementExecutor<
71  statement::Collapse<seq_exec, ArgList<ArgRest...>, EnclosedStmts...>,
72  NewTypes>;
73 
74  auto len0 = segment_length<Arg0>(data);
75 
76  for (auto i0 = 0; i0 < len0; ++i0)
77  {
78  data.template assign_offset<Arg0>(i0);
79 
80  next_loop_t::exec(data);
81  }
82  }
83 };
84 
85 
86 } // namespace internal
87 
88 } // end namespace RAJA
89 
90 
91 #endif /* RAJA_pattern_kernel_HPP */
setSegmentType< Types, Segment, camp::at_v< typename camp::decay< Data >::index_types_t, Segment > > setSegmentTypeFromData
Definition: LoopTypes.hpp:95
RAJA_INLINE void execute_statement_list(Data &&data)
Definition: StatementList.hpp:84
Definition: AlignedRangeIndexSetBuilders.cpp:35
camp::idx_seq< ArgumentId... > ArgList
Definition: kernel.hpp:53
RAJA header file containing user interface for RAJA::kernel.
Definition: Statement.hpp:48
Definition: policy.hpp:78
Definition: Collapse.hpp:35