RAJA
RAJA provides a collection of platform portability abstractions for C++ HPC applications.
resource.hpp
Go to the documentation of this file.
1 
13 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
14 // Copyright (c) Lawrence Livermore National Security, LLC and other
15 // RAJA Project Developers. See top-level LICENSE and COPYRIGHT
16 // files for dates and other details. No copyright assignment is required
17 // to contribute to RAJA.
18 //
19 // SPDX-License-Identifier: (BSD-3-Clause)
20 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
21 
22 #ifndef RAJA_resource_HPP
23 #define RAJA_resource_HPP
24 
25 #include "camp/resource.hpp"
26 #if defined(RAJA_CUDA_ACTIVE)
28 #endif
29 #if defined(RAJA_HIP_ACTIVE)
31 #endif
32 #if defined(RAJA_SYCL_ACTIVE)
34 #endif
38 
39 namespace RAJA
40 {
41 
42 namespace resources
43 {
44 using namespace camp::resources;
45 
46 template<typename e>
48 {
49  using type = camp::resources::Host;
50 };
51 
52 template<Platform>
54 {
55  using type = camp::resources::Host;
56 };
57 
58 template<typename ExecPol>
61 
62 template<typename ExecPol>
64 {
66 }
67 
68 #if defined(RAJA_CUDA_ACTIVE)
69 template<>
70 struct get_resource_from_platform<Platform::cuda>
71 {
72  using type = camp::resources::Cuda;
73 };
74 
75 template<typename IterationMapping,
76  typename IterationGetter,
77  typename Concretizer,
78  size_t BLOCKS_PER_SM,
79  bool Async>
80 struct get_resource<::RAJA::policy::cuda::cuda_exec_explicit<IterationMapping,
81  IterationGetter,
82  Concretizer,
83  BLOCKS_PER_SM,
84  Async>>
85 {
86  using type = camp::resources::Cuda;
87 };
88 
89 template<bool Async, int num_threads, size_t BLOCKS_PER_SM>
90 struct get_resource<::RAJA::policy::cuda::cuda_launch_explicit_t<Async,
91  num_threads,
92  BLOCKS_PER_SM>>
93 {
94  using type = camp::resources::Cuda;
95 };
96 
97 template<typename ISetIter,
98  typename IterationMapping,
99  typename IterationGetter,
100  typename Concretizer,
101  size_t BLOCKS_PER_SM,
102  bool Async>
103 struct get_resource<
104  ExecPolicy<ISetIter,
105  ::RAJA::policy::cuda::cuda_exec_explicit<IterationMapping,
106  IterationGetter,
107  Concretizer,
108  BLOCKS_PER_SM,
109  Async>>>
110 {
111  using type = camp::resources::Cuda;
112 };
113 #endif
114 
115 #if defined(RAJA_HIP_ACTIVE)
116 template<>
117 struct get_resource_from_platform<Platform::hip>
118 {
119  using type = camp::resources::Hip;
120 };
121 
122 template<typename IterationMapping,
123  typename IterationGetter,
124  typename Concretizer,
125  bool Async>
126 struct get_resource<
127  ::RAJA::policy::hip::
128  hip_exec<IterationMapping, IterationGetter, Concretizer, Async>>
129 {
130  using type = camp::resources::Hip;
131 };
132 
133 template<bool Async, int num_threads>
134 struct get_resource<::RAJA::policy::hip::hip_launch_t<Async, num_threads>>
135 {
136  using type = camp::resources::Hip;
137 };
138 
139 template<typename ISetIter,
140  typename IterationMapping,
141  typename IterationGetter,
142  typename Concretizer,
143  bool Async>
144 struct get_resource<ExecPolicy<
145  ISetIter,
146  ::RAJA::policy::hip::
147  hip_exec<IterationMapping, IterationGetter, Concretizer, Async>>>
148 {
149  using type = camp::resources::Hip;
150 };
151 #endif
152 
153 #if defined(RAJA_SYCL_ACTIVE)
154 template<>
155 struct get_resource_from_platform<Platform::sycl>
156 {
157  using type = camp::resources::Sycl;
158 };
159 
160 template<size_t BlockSize, bool Async>
161 struct get_resource<::RAJA::policy::sycl::sycl_exec<BlockSize, Async>>
162 {
163  using type = camp::resources::Sycl;
164 };
165 
166 template<bool Async, int num_threads>
167 struct get_resource<::RAJA::policy::sycl::sycl_launch_t<Async, num_threads>>
168 {
169  using type = camp::resources::Sycl;
170 };
171 
172 template<typename ISetIter, size_t BlockSize, bool Async>
173 struct get_resource<
174  ExecPolicy<ISetIter, ::RAJA::policy::sycl::sycl_exec<BlockSize, Async>>>
175 {
176  using type = camp::resources::Sycl;
177 };
178 #endif
179 
180 #if defined(RAJA_ENABLE_TARGET_OPENMP)
181 template<>
182 struct get_resource_from_platform<Platform::omp_target>
183 {
184  using type = camp::resources::Omp;
185 };
186 
187 template<>
189 {
190  using type = camp::resources::Omp;
191 };
192 
193 template<size_t ThreadsPerTeam>
194 struct get_resource<
196 {
197  using type = camp::resources::Omp;
198 };
199 
200 template<typename ISetIter>
201 struct get_resource<
203 {
204  using type = camp::resources::Omp;
205 };
206 
207 template<typename ISetIter, size_t ThreadsPerTeam>
208 struct get_resource<ExecPolicy<
209  ISetIter,
211 {
212  using type = camp::resources::Omp;
213 };
214 #endif
215 
216 } // end namespace resources
217 
218 namespace type_traits
219 {
220 template<typename T>
221 struct is_resource : std::false_type
222 {};
223 
224 template<>
225 struct is_resource<resources::Host> : std::true_type
226 {};
227 #if defined(RAJA_CUDA_ACTIVE)
228 template<>
229 struct is_resource<resources::Cuda> : std::true_type
230 {};
231 #endif
232 #if defined(RAJA_HIP_ACTIVE)
233 template<>
234 struct is_resource<resources::Hip> : std::true_type
235 {};
236 #endif
237 #if defined(RAJA_SYCL_ACTIVE)
238 template<>
239 struct is_resource<resources::Sycl> : std::true_type
240 {};
241 #endif
242 #if defined(RAJA_ENABLE_TARGET_OPENMP)
243 template<>
244 struct is_resource<resources::Omp> : std::true_type
245 {};
246 #endif
247 } // end namespace type_traits
248 
249 } // end namespace RAJA
250 
251 #endif // RAJA_resources_HPP#
Header file containing RAJA CUDA policy definitions.
Header file containing RAJA HIP policy definitions.
constexpr resource_from_pol_t< ExecPol > get_default_resource()
Definition: resource.hpp:63
typename get_resource_from_platform< detail::get_platform< ExecPol >::value >::type resource_from_pol_t
Definition: resource.hpp:60
Definition: AlignedRangeIndexSetBuilders.cpp:35
Header file containing RAJA sequential policy definitions.
Definition: get_platform.hpp:42
camp::resources::Host type
Definition: resource.hpp:55
Definition: resource.hpp:48
camp::resources::Host type
Definition: resource.hpp:49
Definition: resource.hpp:222
Header file containing RAJA SYCL policy definitions.