DPC++ Runtime
Runtime libraries for oneAPI DPC++
properties.hpp
Go to the documentation of this file.
1 //==----- properties.hpp - SYCL properties associated with device_global ---==//
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 device_global;
21 
22 struct device_image_scope_key {
23  using value_t = property_value<device_image_scope_key>;
24 };
25 
26 enum class host_access_enum : std::uint16_t { read, write, read_write, none };
27 
28 struct host_access_key {
29  template <host_access_enum Access>
30  using value_t =
31  property_value<host_access_key,
32  std::integral_constant<host_access_enum, Access>>;
33 };
34 
35 enum class init_mode_enum : std::uint16_t { reprogram, reset };
36 
37 struct init_mode_key {
38  template <init_mode_enum Trigger>
39  using value_t =
40  property_value<init_mode_key,
41  std::integral_constant<init_mode_enum, Trigger>>;
42 };
43 
44 struct implement_in_csr_key {
45  template <bool Enable>
46  using value_t =
47  property_value<implement_in_csr_key, sycl::detail::bool_constant<Enable>>;
48 };
49 
50 #if __cplusplus >= 201703L // inline variables
51 inline constexpr device_image_scope_key::value_t device_image_scope;
52 
53 template <host_access_enum Access>
54 inline constexpr host_access_key::value_t<Access> host_access;
55 inline constexpr host_access_key::value_t<host_access_enum::read>
56  host_access_read;
57 inline constexpr host_access_key::value_t<host_access_enum::write>
58  host_access_write;
59 inline constexpr host_access_key::value_t<host_access_enum::read_write>
60  host_access_read_write;
61 inline constexpr host_access_key::value_t<host_access_enum::none>
62  host_access_none;
63 
64 template <init_mode_enum Trigger>
65 inline constexpr init_mode_key::value_t<Trigger> init_mode;
66 inline constexpr init_mode_key::value_t<init_mode_enum::reprogram>
67  init_mode_reprogram;
68 inline constexpr init_mode_key::value_t<init_mode_enum::reset> init_mode_reset;
69 
70 template <bool Enable>
71 inline constexpr implement_in_csr_key::value_t<Enable> implement_in_csr;
72 inline constexpr implement_in_csr_key::value_t<true> implement_in_csr_on;
73 inline constexpr implement_in_csr_key::value_t<false> implement_in_csr_off;
74 #endif // __cplusplus >= 201703L
75 
76 template <> struct is_property_key<device_image_scope_key> : std::true_type {};
77 template <> struct is_property_key<host_access_key> : std::true_type {};
78 template <> struct is_property_key<init_mode_key> : std::true_type {};
79 template <> struct is_property_key<implement_in_csr_key> : std::true_type {};
80 
81 template <typename T, typename PropertyListT>
82 struct is_property_key_of<device_image_scope_key,
83  device_global<T, PropertyListT>> : std::true_type {};
84 template <typename T, typename PropertyListT>
85 struct is_property_key_of<host_access_key, device_global<T, PropertyListT>>
86  : std::true_type {};
87 template <typename T, typename PropertyListT>
88 struct is_property_key_of<init_mode_key, device_global<T, PropertyListT>>
89  : std::true_type {};
90 template <typename T, typename PropertyListT>
91 struct is_property_key_of<implement_in_csr_key, device_global<T, PropertyListT>>
92  : std::true_type {};
93 
94 namespace detail {
95 template <> struct PropertyToKind<device_image_scope_key> {
96  static constexpr PropKind Kind = PropKind::DeviceImageScope;
97 };
98 template <> struct PropertyToKind<host_access_key> {
99  static constexpr PropKind Kind = PropKind::HostAccess;
100 };
101 template <> struct PropertyToKind<init_mode_key> {
102  static constexpr PropKind Kind = PropKind::InitMode;
103 };
104 template <> struct PropertyToKind<implement_in_csr_key> {
105  static constexpr PropKind Kind = PropKind::ImplementInCSR;
106 };
107 
108 template <>
109 struct IsCompileTimeProperty<device_image_scope_key> : std::true_type {};
110 template <> struct IsCompileTimeProperty<host_access_key> : std::true_type {};
111 template <> struct IsCompileTimeProperty<init_mode_key> : std::true_type {};
112 template <>
113 struct IsCompileTimeProperty<implement_in_csr_key> : std::true_type {};
114 
115 template <> struct PropertyMetaInfo<device_image_scope_key::value_t> {
116  static constexpr const char *name = "sycl-device-image-scope";
117  static constexpr std::nullptr_t value = nullptr;
118 };
119 template <host_access_enum Access>
120 struct PropertyMetaInfo<host_access_key::value_t<Access>> {
121  static constexpr const char *name = "sycl-host-access";
122  static constexpr host_access_enum value = Access;
123 };
124 template <init_mode_enum Trigger>
125 struct PropertyMetaInfo<init_mode_key::value_t<Trigger>> {
126  static constexpr const char *name = "sycl-init-mode";
127  static constexpr init_mode_enum value = Trigger;
128 };
129 template <bool Enable>
130 struct PropertyMetaInfo<implement_in_csr_key::value_t<Enable>> {
131  static constexpr const char *name = "sycl-implement-in-csr";
132  static constexpr bool value = Enable;
133 };
134 
135 } // namespace detail
136 } // namespace experimental
137 } // namespace oneapi
138 } // namespace ext
139 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
140 } // namespace sycl
sycl::__SYCL_INLINE_VER_NAMESPACE
__SYCL_INLINE_VER_NAMESPACE(_V1)
Definition: access.hpp:14
sycl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
property_value.hpp
property.hpp