DPC++ Runtime
Runtime libraries for oneAPI DPC++
annotated_ptr_properties.hpp
Go to the documentation of this file.
1 //==-- annotated_ptr_properties.hpp - Specific properties of annotated_ptr
2 //--==//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #pragma once
11 
13 #include <sycl/ext/oneapi/properties/properties.hpp> // for properties_t
14 #include <sycl/usm/usm_enums.hpp>
15 
16 #include <type_traits> // for false_type, con...
17 #include <utility> // for declval
18 
19 namespace sycl {
20 inline namespace _V1 {
21 namespace ext {
22 namespace oneapi {
23 namespace experimental {
24 
25 template <typename T, typename PropertyListT> class annotated_ptr;
26 
28  : detail::compile_time_property_key<detail::PropKind::UsmKind> {
29  template <sycl::usm::alloc Kind>
30  using value_t =
32  std::integral_constant<sycl::usm::alloc, Kind>>;
33 };
34 
35 template <sycl::usm::alloc Kind>
42 
43 template <typename T, sycl::usm::alloc Kind>
44 struct is_valid_property<T, usm_kind_key::value_t<Kind>>
45  : std::bool_constant<std::is_pointer<T>::value> {};
46 
47 template <typename T, typename PropertyListT>
48 struct is_property_key_of<usm_kind_key, annotated_ptr<T, PropertyListT>>
49  : std::true_type {};
50 
51 namespace detail {
52 template <sycl::usm::alloc Kind>
53 struct PropertyMetaInfo<usm_kind_key::value_t<Kind>> {
54  static constexpr const char *name = "sycl-usm-kind";
55  static constexpr sycl::usm::alloc value = Kind;
56 };
57 
58 template <typename PropertyListT> struct IsUsmKindDevice : std::false_type {};
59 template <typename... Props>
60 struct IsUsmKindDevice<detail::properties_t<Props...>>
61  : detail::ContainsProperty<std::remove_const_t<decltype(usm_kind_device)>,
62  std::tuple<Props...>> {};
63 
64 template <typename PropertyListT> struct IsUsmKindHost : std::false_type {};
65 template <typename... Props>
66 struct IsUsmKindHost<detail::properties_t<Props...>>
67  : detail::ContainsProperty<std::remove_const_t<decltype(usm_kind_host)>,
68  std::tuple<Props...>> {};
69 
70 template <typename PropertyListT> struct IsUsmKindShared : std::false_type {};
71 template <typename... Props>
72 struct IsUsmKindShared<detail::properties_t<Props...>>
73  : detail::ContainsProperty<std::remove_const_t<decltype(usm_kind_shared)>,
74  std::tuple<Props...>> {};
75 
76 } // namespace detail
77 
78 } // namespace experimental
79 } // namespace oneapi
80 } // namespace ext
81 } // namespace _V1
82 } // namespace sycl
constexpr usm_kind_key::value_t< sycl::usm::alloc::host > usm_kind_host
constexpr usm_kind_key::value_t< Kind > usm_kind
constexpr usm_kind_key::value_t< sycl::usm::alloc::shared > usm_kind_shared
constexpr usm_kind_key::value_t< sycl::usm::alloc::device > usm_kind_device
Definition: access.hpp:18