DPC++ Runtime
Runtime libraries for oneAPI DPC++
properties.hpp
Go to the documentation of this file.
1 //==-- properties.hpp - SYCL properties associated with annotated_arg/ptr --==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
13 
14 namespace sycl {
16 namespace ext {
17 namespace oneapi {
18 namespace experimental {
19 
20 template <typename T, typename PropertyListT> class annotated_arg;
21 template <typename T, typename PropertyListT> class annotated_ptr;
22 
23 //===----------------------------------------------------------------------===//
24 // Common properties of annotated_arg/annotated_ptr
25 //===----------------------------------------------------------------------===//
28 };
29 
30 struct conduit_key {
32 };
33 
34 struct stable_key {
36 };
37 
39  template <int K>
40  using value_t =
42 };
43 
44 struct awidth_key {
45  template <int K>
47 };
48 
49 struct dwidth_key {
50  template <int K>
52 };
53 
54 struct latency_key {
55  template <int K>
57 };
58 
59 enum class read_write_mode_enum : std::uint16_t { read, write, read_write };
60 
62  template <read_write_mode_enum Mode>
63  using value_t =
65  std::integral_constant<read_write_mode_enum, Mode>>;
66 };
67 
68 struct maxburst_key {
69  template <int K>
71 };
72 
74  template <int K>
75  using value_t =
77 };
78 
79 // non-mmhost properties
81 inline constexpr conduit_key::value_t conduit;
82 inline constexpr stable_key::value_t stable;
83 
84 // mmhost properties
85 template <int N>
87 template <int W> inline constexpr awidth_key::value_t<W> awidth;
88 template <int W> inline constexpr dwidth_key::value_t<W> dwidth;
89 template <int N> inline constexpr latency_key::value_t<N> latency;
90 template <int N> inline constexpr maxburst_key::value_t<N> maxburst;
91 template <int Enable>
95 
96 template <read_write_mode_enum Mode>
104 
105 template <> struct is_property_key<register_map_key> : std::true_type {};
106 template <> struct is_property_key<conduit_key> : std::true_type {};
107 template <> struct is_property_key<stable_key> : std::true_type {};
108 
109 template <> struct is_property_key<buffer_location_key> : std::true_type {};
110 template <> struct is_property_key<awidth_key> : std::true_type {};
111 template <> struct is_property_key<dwidth_key> : std::true_type {};
112 template <> struct is_property_key<latency_key> : std::true_type {};
113 template <> struct is_property_key<read_write_mode_key> : std::true_type {};
114 template <> struct is_property_key<maxburst_key> : std::true_type {};
115 template <> struct is_property_key<wait_request_key> : std::true_type {};
116 
117 template <typename T, typename PropertyListT>
119  : std::true_type {};
120 
121 template <typename T, typename PropertyListT>
122 struct is_property_key_of<conduit_key, annotated_arg<T, PropertyListT>>
123  : std::true_type {};
124 
125 template <typename T, typename PropertyListT>
126 struct is_property_key_of<stable_key, annotated_arg<T, PropertyListT>>
127  : std::true_type {};
128 
129 template <typename T, typename PropertyListT>
131  : std::true_type {};
132 
133 template <typename T, typename PropertyListT>
134 struct is_property_key_of<awidth_key, annotated_arg<T, PropertyListT>>
135  : std::true_type {};
136 
137 template <typename T, typename PropertyListT>
138 struct is_property_key_of<dwidth_key, annotated_arg<T, PropertyListT>>
139  : std::true_type {};
140 
141 template <typename T, typename PropertyListT>
142 struct is_property_key_of<latency_key, annotated_arg<T, PropertyListT>>
143  : std::true_type {};
144 
145 template <typename T, typename PropertyListT>
147  : std::true_type {};
148 
149 template <typename T, typename PropertyListT>
151  : std::true_type {};
152 
153 template <typename T, typename PropertyListT>
155  : std::true_type {};
156 
157 template <typename T, typename PropertyListT>
159  : std::true_type {};
160 
161 template <typename T, typename PropertyListT>
162 struct is_property_key_of<conduit_key, annotated_ptr<T, PropertyListT>>
163  : std::true_type {};
164 
165 template <typename T, typename PropertyListT>
166 struct is_property_key_of<stable_key, annotated_ptr<T, PropertyListT>>
167  : std::true_type {};
168 
169 template <typename T, typename PropertyListT>
171  : std::true_type {};
172 
173 template <typename T, typename PropertyListT>
174 struct is_property_key_of<awidth_key, annotated_ptr<T, PropertyListT>>
175  : std::true_type {};
176 
177 template <typename T, typename PropertyListT>
178 struct is_property_key_of<dwidth_key, annotated_ptr<T, PropertyListT>>
179  : std::true_type {};
180 
181 template <typename T, typename PropertyListT>
182 struct is_property_key_of<latency_key, annotated_ptr<T, PropertyListT>>
183  : std::true_type {};
184 
185 template <typename T, typename PropertyListT>
187  : std::true_type {};
188 
189 template <typename T, typename PropertyListT>
191  : std::true_type {};
192 
193 template <typename T, typename PropertyListT>
195  : std::true_type {};
196 
197 namespace detail {
198 template <> struct PropertyToKind<register_map_key> {
199  static constexpr PropKind Kind = PropKind::RegisterMap;
200 };
201 template <> struct PropertyToKind<conduit_key> {
202  static constexpr PropKind Kind = PropKind::Conduit;
203 };
204 template <> struct PropertyToKind<stable_key> {
205  static constexpr PropKind Kind = PropKind::Stable;
206 };
207 template <> struct PropertyToKind<buffer_location_key> {
208  static constexpr PropKind Kind = PropKind::BufferLocation;
209 };
210 template <> struct PropertyToKind<awidth_key> {
211  static constexpr PropKind Kind = PropKind::AddrWidth;
212 };
213 template <> struct PropertyToKind<dwidth_key> {
214  static constexpr PropKind Kind = PropKind::DataWidth;
215 };
216 template <> struct PropertyToKind<latency_key> {
217  static constexpr PropKind Kind = PropKind::Latency;
218 };
219 template <> struct PropertyToKind<read_write_mode_key> {
220  static constexpr PropKind Kind = PropKind::RWMode;
221 };
222 template <> struct PropertyToKind<maxburst_key> {
223  static constexpr PropKind Kind = PropKind::MaxBurst;
224 };
225 template <> struct PropertyToKind<wait_request_key> {
226  static constexpr PropKind Kind = PropKind::WaitRequest;
227 };
228 
229 template <> struct IsCompileTimeProperty<register_map_key> : std::true_type {};
230 template <> struct IsCompileTimeProperty<conduit_key> : std::true_type {};
231 template <> struct IsCompileTimeProperty<stable_key> : std::true_type {};
232 
233 template <>
234 struct IsCompileTimeProperty<buffer_location_key> : std::true_type {};
235 template <> struct IsCompileTimeProperty<awidth_key> : std::true_type {};
236 template <> struct IsCompileTimeProperty<dwidth_key> : std::true_type {};
237 template <>
238 struct IsCompileTimeProperty<read_write_mode_key> : std::true_type {};
239 template <> struct IsCompileTimeProperty<latency_key> : std::true_type {};
240 template <> struct IsCompileTimeProperty<maxburst_key> : std::true_type {};
241 template <> struct IsCompileTimeProperty<wait_request_key> : std::true_type {};
242 
243 template <> struct PropertyMetaInfo<register_map_key::value_t> {
244  static constexpr const char *name = "sycl-register-map";
245  static constexpr std::nullptr_t value = nullptr;
246 };
247 template <> struct PropertyMetaInfo<conduit_key::value_t> {
248  static constexpr const char *name = "sycl-conduit";
249  static constexpr std::nullptr_t value = nullptr;
250 };
251 template <> struct PropertyMetaInfo<stable_key::value_t> {
252  static constexpr const char *name = "sycl-stable";
253  static constexpr std::nullptr_t value = nullptr;
254 };
255 
256 template <int N> struct PropertyMetaInfo<buffer_location_key::value_t<N>> {
257  static constexpr const char *name = "sycl-buffer-location";
258  static constexpr int value = N;
259 };
260 template <int W> struct PropertyMetaInfo<awidth_key::value_t<W>> {
261  static constexpr const char *name = "sycl-awidth";
262  static constexpr int value = W;
263 };
264 template <int W> struct PropertyMetaInfo<dwidth_key::value_t<W>> {
265  static constexpr const char *name = "sycl-dwidth";
266  static constexpr int value = W;
267 };
268 template <int N> struct PropertyMetaInfo<latency_key::value_t<N>> {
269  static constexpr const char *name = "sycl-latency";
270  static constexpr int value = N;
271 };
272 template <int N> struct PropertyMetaInfo<maxburst_key::value_t<N>> {
273  static constexpr const char *name = "sycl-maxburst";
274  static constexpr int value = N;
275 };
276 template <int Enable>
277 struct PropertyMetaInfo<wait_request_key::value_t<Enable>> {
278  static constexpr const char *name = "sycl-wait-request";
279  static constexpr int value = Enable;
280 };
281 template <read_write_mode_enum Mode>
282 struct PropertyMetaInfo<read_write_mode_key::value_t<Mode>> {
283  static constexpr const char *name = "sycl-read-write-mode";
284  static constexpr read_write_mode_enum value = Mode;
285 };
286 
287 } // namespace detail
288 
289 // 'buffer_location' and mmhost properties are pointers-only
290 template <typename T, typename PropertyValueT>
291 struct is_valid_property : std::false_type {};
292 
293 template <typename T, int N>
295  : std::bool_constant<std::is_pointer<T>::value> {};
296 
297 template <typename T, int W>
298 struct is_valid_property<T, awidth_key::value_t<W>>
299  : std::bool_constant<std::is_pointer<T>::value> {};
300 
301 template <typename T, int W>
302 struct is_valid_property<T, dwidth_key::value_t<W>>
303  : std::bool_constant<std::is_pointer<T>::value> {};
304 
305 template <typename T, int N>
306 struct is_valid_property<T, latency_key::value_t<N>>
307  : std::bool_constant<std::is_pointer<T>::value> {};
308 
309 template <typename T, read_write_mode_enum Mode>
310 struct is_valid_property<T, read_write_mode_key::value_t<Mode>>
311  : std::bool_constant<std::is_pointer<T>::value> {};
312 
313 template <typename T, int N>
314 struct is_valid_property<T, maxburst_key::value_t<N>>
315  : std::bool_constant<std::is_pointer<T>::value> {};
316 
317 template <typename T, int Enable>
318 struct is_valid_property<T, wait_request_key::value_t<Enable>>
319  : std::bool_constant<std::is_pointer<T>::value> {};
320 
321 // 'register_map', 'conduit', 'stable' are common properties for pointers
322 // and non pointers;
323 template <typename T>
324 struct is_valid_property<T, register_map_key::value_t> : std::true_type {};
325 template <typename T>
326 struct is_valid_property<T, conduit_key::value_t> : std::true_type {};
327 template <typename T>
328 struct is_valid_property<T, stable_key::value_t> : std::true_type {};
329 
330 template <typename T, typename... Props>
331 struct check_property_list : std::true_type {};
332 
333 template <typename T, typename Prop, typename... Props>
334 struct check_property_list<T, Prop, Props...>
335  : std::conditional_t<is_valid_property<T, Prop>::value,
336  check_property_list<T, Props...>, std::false_type> {
337  static_assert(is_valid_property<T, Prop>::value,
338  "Property is invalid for the given type.");
339 };
340 
341 //===----------------------------------------------------------------------===//
342 // Specific properties of annotated_ptr
343 //===----------------------------------------------------------------------===//
345  template <int K>
347 };
348 
349 template <int K> inline constexpr alignment_key::value_t<K> alignment;
350 
351 template <> struct is_property_key<alignment_key> : std::true_type {};
352 
353 template <typename T, typename PropertyListT>
355  : std::true_type {};
356 
357 namespace detail {
358 
359 template <> struct PropertyToKind<alignment_key> {
360  static constexpr PropKind Kind = PropKind::Alignment;
361 };
362 
363 template <> struct IsCompileTimeProperty<alignment_key> : std::true_type {};
364 
365 template <int N> struct PropertyMetaInfo<alignment_key::value_t<N>> {
366  static constexpr const char *name = "sycl-alignment";
367  static constexpr int value = N;
368 };
369 
370 } // namespace detail
371 
372 } // namespace experimental
373 } // namespace oneapi
374 } // namespace ext
375 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
376 } // namespace sycl
sycl::_V1::ext::oneapi::experimental::latency_key
Definition: properties.hpp:54
sycl::_V1::ext::oneapi::experimental::buffer_location_key
Definition: properties.hpp:38
sycl::_V1::ext::oneapi::experimental::detail::PropKind
PropKind
Definition: property.hpp:165
sycl::_V1::ext::oneapi::experimental::awidth_key
Definition: properties.hpp:44
sycl::_V1::ext::oneapi::experimental::detail::WaitRequest
@ WaitRequest
Definition: property.hpp:188
sycl::_V1::ext::oneapi::experimental::read_write_mode_readwrite
constexpr read_write_mode_key::value_t< read_write_mode_enum::read_write > read_write_mode_readwrite
Definition: properties.hpp:103
sycl::_V1::ext::oneapi::experimental::read_write_mode_read
constexpr read_write_mode_key::value_t< read_write_mode_enum::read > read_write_mode_read
Definition: properties.hpp:99
sycl::_V1::ext::oneapi::experimental::annotated_arg
Definition: annotated_arg.hpp:58
sycl::_V1::detail::bool_constant
std::integral_constant< bool, V > bool_constant
Definition: stl_type_traits.hpp:40
sycl::_V1::ext::oneapi::experimental::buffer_location
constexpr buffer_location_key::value_t< N > buffer_location
Definition: properties.hpp:86
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:11
sycl::_V1::ext::oneapi::experimental::detail::IsCompileTimeProperty
Definition: property.hpp:209
sycl::_V1::ext::oneapi::experimental::wait_request
constexpr wait_request_key::value_t< Enable > wait_request
Definition: properties.hpp:92
sycl::_V1::ext::oneapi::experimental::alignment
constexpr alignment_key::value_t< K > alignment
Definition: properties.hpp:349
sycl::_V1::ext::oneapi::experimental::wait_request_not_requested
constexpr wait_request_key::value_t< 0 > wait_request_not_requested
Definition: properties.hpp:94
sycl::_V1::ext::oneapi::experimental::register_map
constexpr register_map_key::value_t register_map
Definition: properties.hpp:80
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
sycl::_V1::ext::oneapi::experimental::dwidth_key
Definition: properties.hpp:49
sycl::_V1::ext::oneapi::experimental::maxburst_key
Definition: properties.hpp:68
sycl::_V1::ext::oneapi::experimental::wait_request_requested
constexpr wait_request_key::value_t< 1 > wait_request_requested
Definition: properties.hpp:93
sycl::_V1::ext::oneapi::experimental::alignment_key
Definition: properties.hpp:344
sycl::_V1::ext::oneapi::experimental::is_property_key_of
Definition: property.hpp:222
sycl::_V1::ext::oneapi::experimental::detail::RegisterMap
@ RegisterMap
Definition: property.hpp:179
sycl::_V1::ext::oneapi::experimental::awidth
constexpr awidth_key::value_t< W > awidth
Definition: properties.hpp:87
sycl::_V1::ext::oneapi::experimental::annotated_ptr
friend class annotated_ptr
Definition: annotated_ptr.hpp:111
sycl::_V1::ext::oneapi::experimental::register_map_key
Definition: properties.hpp:26
sycl::_V1::ext::oneapi::experimental::maxburst
constexpr maxburst_key::value_t< N > maxburst
Definition: properties.hpp:90
sycl::_V1::ext::oneapi::experimental::latency
constexpr latency_key::value_t< N > latency
Definition: properties.hpp:89
sycl::_V1::ext::oneapi::experimental::stable
constexpr stable_key::value_t stable
Definition: properties.hpp:82
sycl::_V1::ext::oneapi::experimental::conduit
constexpr conduit_key::value_t conduit
Definition: properties.hpp:81
property_value.hpp
sycl::_V1::ext::oneapi::experimental::detail::RWMode
@ RWMode
Definition: property.hpp:186
sycl::_V1::ext::oneapi::experimental::wait_request_key
Definition: properties.hpp:73
sycl::_V1::ext::oneapi::experimental::detail::MaxBurst
@ MaxBurst
Definition: property.hpp:187
sycl::_V1::ext::oneapi::experimental::detail::Conduit
@ Conduit
Definition: property.hpp:180
sycl::_V1::ext::oneapi::experimental::detail::Alignment
@ Alignment
Definition: property.hpp:189
sycl::_V1::read_write
constexpr mode_tag_t< access_mode::read_write > read_write
Definition: access.hpp:74
sycl::_V1::ext::oneapi::experimental::detail::PropertyMetaInfo
Definition: property.hpp:212
sycl::_V1::ext::oneapi::experimental::read_write_mode_write
constexpr read_write_mode_key::value_t< read_write_mode_enum::write > read_write_mode_write
Definition: properties.hpp:101
sycl::_V1::ext::oneapi::experimental::detail::AddrWidth
@ AddrWidth
Definition: property.hpp:183
sycl::_V1::ext::oneapi::experimental::check_property_list
Definition: properties.hpp:331
sycl::_V1::ext::oneapi::experimental::detail::Stable
@ Stable
Definition: property.hpp:181
sycl::_V1::ext::oneapi::experimental::is_valid_property
Definition: properties.hpp:291
sycl::_V1::ext::oneapi::experimental::stable_key
Definition: properties.hpp:34
sycl::_V1::ext::oneapi::experimental::conduit_key
Definition: properties.hpp:30
sycl::_V1::ext::oneapi::experimental::read_write_mode_key
Definition: properties.hpp:61
sycl::_V1::ext::oneapi::experimental::read_write_mode
constexpr read_write_mode_key::value_t< Mode > read_write_mode
Definition: properties.hpp:97
sycl::_V1::ext::oneapi::experimental::annotated_ptr
Definition: annotated_ptr.hpp:90
property.hpp
sycl::_V1::ext::oneapi::experimental::detail::PropertyToKind
Definition: property.hpp:197
sycl::_V1::ext::oneapi::experimental::dwidth
constexpr dwidth_key::value_t< W > dwidth
Definition: properties.hpp:88
sycl::_V1::ext::oneapi::experimental::detail::BufferLocation
@ BufferLocation
Definition: property.hpp:182
sycl::_V1::detail::conditional_t
typename std::conditional< B, T, F >::type conditional_t
Definition: stl_type_traits.hpp:27
sycl::_V1::ext::oneapi::experimental::property_value
Definition: property_utils.hpp:22
sycl::_V1::ext::oneapi::experimental::read_write_mode_enum
read_write_mode_enum
Definition: properties.hpp:59
sycl::_V1::ext::oneapi::experimental::detail::DataWidth
@ DataWidth
Definition: property.hpp:184
sycl::_V1::ext::oneapi::experimental::annotated_arg
friend class annotated_arg
Definition: annotated_arg.hpp:78
sycl::_V1::ext::oneapi::experimental::is_property_key
Definition: property.hpp:221
sycl::_V1::ext::oneapi::experimental::detail::Latency
@ Latency
Definition: property.hpp:185