RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
For.hpp
Go to the documentation of this file.
1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
2 // Copyright (c) Lawrence Livermore National Security, LLC and other
3 // RAJA Project Developers. See top-level LICENSE and COPYRIGHT
4 // files for dates and other details. No copyright assignment is required
5 // to contribute to RAJA.
6 //
7 // SPDX-License-Identifier: (BSD-3-Clause)
8 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
9 
10 #ifndef RAJA_policy_openmp_target_kernel_For_HPP
11 #define RAJA_policy_openmp_target_kernel_For_HPP
12 
14 
15 namespace RAJA
16 {
17 namespace internal
18 {
19 
20 template<camp::idx_t ArgumentId,
21  typename Data,
22  typename Types,
23  typename... EnclosedStmts>
25 {
26  using data_t = camp::decay<Data>;
27 
29 
33  RAJA_INLINE
34  constexpr explicit OpenMPTargetForWrapper(data_t& d) : data {d} {}
35 
36  RAJA_INLINE
37  void exec()
38  {
39  execute_statement_list<camp::list<EnclosedStmts...>, Types>(data);
40  }
41 
42  template<typename InIndexType>
43  RAJA_INLINE void operator()(InIndexType i)
44  {
45  data.template assign_offset<ArgumentId>(i);
46  exec();
47  }
48 };
49 
50 template<camp::idx_t ArgumentId,
51  int N,
52  typename... EnclosedStmts,
53  typename Types>
54 struct StatementExecutor<statement::For<ArgumentId,
55  omp_target_parallel_for_exec<N>,
56  EnclosedStmts...>,
57  Types>
58 {
59 
60  template<typename Data>
61  static RAJA_INLINE void exec(Data&& data)
62  {
63  // Set the argument type for this loop
65 
66  OpenMPTargetForWrapper<ArgumentId, Data, NewTypes, EnclosedStmts...>
67  for_wrapper(data);
68 
69  auto len = segment_length<ArgumentId>(data);
70  using len_t = decltype(len);
71 
72  auto r = resources::Omp::get_default();
73  forall_impl(r, omp_target_parallel_for_exec<N> {},
74  TypedRangeSegment<len_t>(0, len), for_wrapper,
75  RAJA::expt::get_empty_forall_param_pack());
76  }
77 };
78 
79 
80 } // namespace internal
81 } // namespace RAJA
82 
83 #endif // RAJA_policy_openmp_kernel_For_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
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: privatizer.hpp:47
camp::decay< Data > data_t
Definition: For.hpp:26
RAJA_INLINE void operator()(InIndexType i)
Definition: For.hpp:43
constexpr RAJA_INLINE OpenMPTargetForWrapper(data_t &d)
Deferences data so that it can be mapped to the device.
Definition: For.hpp:34
RAJA_INLINE void exec()
Definition: For.hpp:37
data_t data
Definition: For.hpp:28
Definition: Statement.hpp:48