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 
11 #include <sycl/ext/oneapi/properties/property.hpp> // for PropKind
12 #include <sycl/ext/oneapi/properties/property_value.hpp> // for property_value
13 
14 #include <cstdint> // for uint16_t
15 #include <iosfwd> // for nullptr_t
16 #include <type_traits> // for true_type
17 
18 namespace sycl {
19 inline namespace _V1 {
20 namespace ext::oneapi::experimental {
21 
22 template <typename T, typename PropertyListT> class device_global;
23 
26 };
27 
28 enum class host_access_enum : std::uint16_t { read, write, read_write, none };
29 
31  template <host_access_enum Access>
32  using value_t =
34  std::integral_constant<host_access_enum, Access>>;
35 };
36 
37 enum class init_mode_enum : std::uint16_t { reprogram, reset };
38 
39 struct init_mode_key {
40  template <init_mode_enum Trigger>
41  using value_t =
43  std::integral_constant<init_mode_enum, Trigger>>;
44 };
45 
47  template <bool Enable>
48  using value_t =
50 };
51 
53 
54 template <host_access_enum Access>
64 
65 template <init_mode_enum Trigger>
70 
71 template <bool Enable>
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>
83  device_global<T, PropertyListT>> : std::true_type {};
84 template <typename T, typename PropertyListT>
86  : std::true_type {};
87 template <typename T, typename PropertyListT>
89  : std::true_type {};
90 template <typename T, typename PropertyListT>
92  : std::true_type {};
93 
94 namespace detail {
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 };
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 // Filter allowing additional conditions for selecting when to include meta
136 // information for properties for device_global.
137 template <typename PropT, typename Properties>
138 struct DeviceGlobalMetaInfoFilter : std::true_type {};
139 
140 // host_access cannot be honored for device_global variables without the
141 // device_image_scope property, as the runtime needs to write the common USM
142 // pointer during first launch.
143 template <host_access_enum Access, typename Properties>
144 struct DeviceGlobalMetaInfoFilter<host_access_key::value_t<Access>, Properties>
145  : std::bool_constant<
146  Properties::template has_property<device_image_scope_key>()> {};
147 
148 } // namespace detail
149 } // namespace ext::oneapi::experimental
150 } // namespace _V1
151 } // namespace sycl
constexpr host_access_key::value_t< Access > host_access
Definition: properties.hpp:55
constexpr init_mode_key::value_t< init_mode_enum::reset > init_mode_reset
Definition: properties.hpp:69
constexpr host_access_key::value_t< host_access_enum::read_write > host_access_read_write
Definition: properties.hpp:61
constexpr implement_in_csr_key::value_t< Enable > implement_in_csr
Definition: properties.hpp:72
constexpr init_mode_key::value_t< Trigger > init_mode
Definition: properties.hpp:66
constexpr implement_in_csr_key::value_t< true > implement_in_csr_on
Definition: properties.hpp:73
constexpr host_access_key::value_t< host_access_enum::write > host_access_write
Definition: properties.hpp:59
constexpr host_access_key::value_t< host_access_enum::none > host_access_none
Definition: properties.hpp:63
constexpr init_mode_key::value_t< init_mode_enum::reprogram > init_mode_reprogram
Definition: properties.hpp:68
constexpr host_access_key::value_t< host_access_enum::read > host_access_read
Definition: properties.hpp:57
constexpr device_image_scope_key::value_t device_image_scope
Definition: properties.hpp:52
constexpr implement_in_csr_key::value_t< false > implement_in_csr_off
Definition: properties.hpp:74
Definition: access.hpp:18