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 
25  : detail::compile_time_property_key<detail::PropKind::DeviceImageScope> {
27 };
28 
29 enum class host_access_enum : std::uint16_t { read, write, read_write, none };
30 
32  : detail::compile_time_property_key<detail::PropKind::HostAccess> {
33  template <host_access_enum Access>
34  using value_t =
36  std::integral_constant<host_access_enum, Access>>;
37 };
38 
39 enum class init_mode_enum : std::uint16_t { reprogram, reset };
40 
42  : detail::compile_time_property_key<detail::PropKind::InitMode> {
43  template <init_mode_enum Trigger>
44  using value_t =
46  std::integral_constant<init_mode_enum, Trigger>>;
47 };
48 
50  : detail::compile_time_property_key<detail::PropKind::ImplementInCSR> {
51  template <bool Enable>
52  using value_t =
54 };
55 
57 
58 template <host_access_enum Access>
68 
69 template <init_mode_enum Trigger>
74 
75 template <bool Enable>
79 
80 template <typename T, typename PropertyListT>
82  device_global<T, PropertyListT>> : std::true_type {};
83 template <typename T, typename PropertyListT>
85  : std::true_type {};
86 template <typename T, typename PropertyListT>
88  : std::true_type {};
89 template <typename T, typename PropertyListT>
91  : std::true_type {};
92 
93 namespace detail {
94 template <> struct PropertyMetaInfo<device_image_scope_key::value_t> {
95  static constexpr const char *name = "sycl-device-image-scope";
96  static constexpr std::nullptr_t value = nullptr;
97 };
98 template <host_access_enum Access>
99 struct PropertyMetaInfo<host_access_key::value_t<Access>> {
100  static constexpr const char *name = "sycl-host-access";
101  static constexpr host_access_enum value = Access;
102 };
103 template <init_mode_enum Trigger>
104 struct PropertyMetaInfo<init_mode_key::value_t<Trigger>> {
105  static constexpr const char *name = "sycl-init-mode";
106  static constexpr init_mode_enum value = Trigger;
107 };
108 template <bool Enable>
109 struct PropertyMetaInfo<implement_in_csr_key::value_t<Enable>> {
110  static constexpr const char *name = "sycl-implement-in-csr";
111  static constexpr bool value = Enable;
112 };
113 
114 // Filter allowing additional conditions for selecting when to include meta
115 // information for properties for device_global.
116 template <typename PropT, typename Properties>
117 struct DeviceGlobalMetaInfoFilter : std::true_type {};
118 
119 // host_access cannot be honored for device_global variables without the
120 // device_image_scope property, as the runtime needs to write the common USM
121 // pointer during first launch.
122 template <host_access_enum Access, typename Properties>
123 struct DeviceGlobalMetaInfoFilter<host_access_key::value_t<Access>, Properties>
124  : std::bool_constant<
125  Properties::template has_property<device_image_scope_key>()> {};
126 
127 } // namespace detail
128 } // namespace ext::oneapi::experimental
129 } // namespace _V1
130 } // namespace sycl
constexpr host_access_key::value_t< Access > host_access
Definition: properties.hpp:59
constexpr init_mode_key::value_t< init_mode_enum::reset > init_mode_reset
Definition: properties.hpp:73
constexpr host_access_key::value_t< host_access_enum::read_write > host_access_read_write
Definition: properties.hpp:65
constexpr implement_in_csr_key::value_t< Enable > implement_in_csr
Definition: properties.hpp:76
constexpr init_mode_key::value_t< Trigger > init_mode
Definition: properties.hpp:70
constexpr implement_in_csr_key::value_t< true > implement_in_csr_on
Definition: properties.hpp:77
constexpr host_access_key::value_t< host_access_enum::write > host_access_write
Definition: properties.hpp:63
constexpr host_access_key::value_t< host_access_enum::none > host_access_none
Definition: properties.hpp:67
constexpr init_mode_key::value_t< init_mode_enum::reprogram > init_mode_reprogram
Definition: properties.hpp:72
constexpr host_access_key::value_t< host_access_enum::read > host_access_read
Definition: properties.hpp:61
constexpr device_image_scope_key::value_t device_image_scope
Definition: properties.hpp:56
constexpr implement_in_csr_key::value_t< false > implement_in_csr_off
Definition: properties.hpp:78
Definition: access.hpp:18