RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
For.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_simd_kernel_For_HPP
21 #define RAJA_policy_simd_kernel_For_HPP
22 
23 #include "RAJA/config.hpp"
24 
25 #include <iostream>
26 #include <type_traits>
27 
31 
32 namespace RAJA
33 {
34 
35 namespace internal
36 {
37 
38 
44 template<class T>
46 {
47  static const bool value = false;
48 };
49 
50 template<camp::idx_t BodyIdx, typename... Args>
51 struct TypeIsLambda<RAJA::statement::Lambda<BodyIdx, Args...>>
52 {
53  static const bool value = true;
54 };
55 
62 template<typename Types, class... Statements>
64 
65 template<typename Types>
66 struct Invoke_all_Lambda<Types>
67 {
68 
69  template<typename Data>
70  static RAJA_INLINE void lambda_special(Data&&)
71  {
72  // NOP terminator
73  }
74 };
75 
76 template<typename Types, class Statement, class... StatementRest>
77 struct Invoke_all_Lambda<Types, Statement, StatementRest...>
78 {
79 
80  // Lambda check
81  static const bool value = TypeIsLambda<camp::decay<Statement>>::value;
82  static_assert(value, "Lambdas are only supported post RAJA::simd_exec");
83 
84  // Invoke the chain of lambdas
85  template<typename Data>
86  static RAJA_INLINE void lambda_special(Data&& data)
87  {
88 
89  // Execute this Lambda
91 
92  // Execute next Lambda
94  }
95 };
96 
103 template<camp::idx_t ArgumentId, typename... EnclosedStmts, typename Types>
105  statement::For<ArgumentId, RAJA::simd_exec, EnclosedStmts...>,
106  Types>
107 {
108 
109  template<typename Data>
110  static RAJA_INLINE void exec(Data&& data)
111  {
112 
113  // Set the argument type for this loop
115 
116  auto iter = get<ArgumentId>(data.segment_tuple);
117  auto begin = std::begin(iter);
118  auto end = std::end(iter);
119  auto distance = std::distance(begin, end);
120 
121  RAJA_SIMD
122  for (decltype(distance) i = 0; i < distance; ++i)
123  {
124 
125  // Privatize data for SIMD correctness reasons
127  auto privatizer = thread_privatize(data);
128  auto& private_data = privatizer.get_priv();
129 
130  // Assign offset on privatized data
131  private_data.template assign_offset<ArgumentId>(i);
132 
134  private_data);
135  }
136  }
137 };
138 
139 
140 } // namespace internal
141 } // end namespace RAJA
142 
143 
144 #endif /* RAJA_pattern_nested_HPP */
value_type::device_call &[i_loop] iter
Definition: WorkRunner.hpp:216
setSegmentType< Types, Segment, camp::at_v< typename camp::decay< Data >::index_types_t, Segment > > setSegmentTypeFromData
Definition: LoopTypes.hpp:95
RAJA_HOST_DEVICE auto thread_privatize(const T &item) -> Privatizer< T >
Create a private copy of the argument to be stored on the current thread's stack in a class of the Pr...
Definition: privatizer.hpp:88
Definition: AlignedRangeIndexSetBuilders.cpp:35
auto privatizer
Definition: launch.hpp:176
Header file for kernel lambda executor.
Header file for loop kernel internals.
Header file containing RAJA simd policy definitions.
static RAJA_INLINE void lambda_special(Data &&data)
Definition: For.hpp:86
static RAJA_INLINE void lambda_special(Data &&)
Definition: For.hpp:70
Definition: For.hpp:63
Definition: Statement.hpp:48
Definition: Statement.hpp:35
Definition: For.hpp:46
static const bool value
Definition: For.hpp:47
Definition: Lambda.hpp:128