DPC++ Runtime
Runtime libraries for oneAPI DPC++
properties.hpp
Go to the documentation of this file.
1 //==----- properties.hpp - SYCL properties associated with fpga_mem ---==//
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 <string_view> // for string_view
17 #include <type_traits> // for true_type
18 
19 namespace sycl {
20 inline namespace _V1 {
21 namespace ext {
22 namespace intel::experimental {
23 
24 // Forward declare a class that these properties can be applied to
25 template <typename T, typename PropertyListT> class fpga_mem;
26 
27 // Make sure that we are using the right namespace
28 template <typename PropertyT, typename... Ts>
29 using property_value =
31 
32 // Property definitions
33 enum class resource_enum : std::uint16_t { mlab, block_ram };
34 
36  oneapi::experimental::detail::PropKind::Resource> {
37  template <resource_enum Resource>
38  using value_t =
40  std::integral_constant<resource_enum, Resource>>;
41 };
42 
44  oneapi::experimental::detail::PropKind::NumBanks> {
45  template <size_t Elements>
46  using value_t =
48 };
49 
52  oneapi::experimental::detail::PropKind::StrideSize> {
53  template <size_t Elements>
54  using value_t =
56 };
57 
59  oneapi::experimental::detail::PropKind::WordSize> {
60  template <size_t Elements>
61  using value_t =
63 };
64 
67  oneapi::experimental::detail::PropKind::BiDirectionalPorts> {
68  template <bool Enable>
69  using value_t =
71 };
72 
74  oneapi::experimental::detail::PropKind::Clock2x> {
75  template <bool Enable>
77 };
78 
79 enum class ram_stitching_enum : std::uint16_t { min_ram, max_fmax };
80 
83  oneapi::experimental::detail::PropKind::RAMStitching> {
84  template <ram_stitching_enum RamStitching>
85  using value_t =
87  std::integral_constant<ram_stitching_enum, RamStitching>>;
88 };
89 
92  oneapi::experimental::detail::PropKind::MaxPrivateCopies> {
93  template <size_t N>
94  using value_t =
96 };
97 
100  oneapi::experimental::detail::PropKind::NumReplicates> {
101  template <size_t N>
102  using value_t =
104 };
105 
106 // Convenience aliases
107 template <resource_enum R> inline constexpr resource_key::value_t<R> resource;
111 
112 template <size_t E> inline constexpr num_banks_key::value_t<E> num_banks;
113 
114 template <size_t E> inline constexpr stride_size_key::value_t<E> stride_size;
115 
116 template <size_t E> inline constexpr word_size_key::value_t<E> word_size;
117 
118 template <bool B>
124 
125 template <bool B> inline constexpr clock_2x_key::value_t<B> clock_2x;
128 
129 template <ram_stitching_enum D>
135 
136 template <size_t N>
138 
139 template <size_t N>
141 
142 } // namespace intel::experimental
143 
144 namespace oneapi::experimental {
145 
146 // Associate properties with fpga_mem
147 template <typename T, typename PropertyListT>
148 struct is_property_key_of<intel::experimental::resource_key,
149  intel::experimental::fpga_mem<T, PropertyListT>>
150  : std::true_type {};
151 template <typename T, typename PropertyListT>
152 struct is_property_key_of<intel::experimental::num_banks_key,
153  intel::experimental::fpga_mem<T, PropertyListT>>
154  : std::true_type {};
155 template <typename T, typename PropertyListT>
156 struct is_property_key_of<intel::experimental::stride_size_key,
157  intel::experimental::fpga_mem<T, PropertyListT>>
158  : std::true_type {};
159 template <typename T, typename PropertyListT>
160 struct is_property_key_of<intel::experimental::word_size_key,
161  intel::experimental::fpga_mem<T, PropertyListT>>
162  : std::true_type {};
163 template <typename T, typename PropertyListT>
164 struct is_property_key_of<intel::experimental::bi_directional_ports_key,
165  intel::experimental::fpga_mem<T, PropertyListT>>
166  : std::true_type {};
167 template <typename T, typename PropertyListT>
168 struct is_property_key_of<intel::experimental::clock_2x_key,
169  intel::experimental::fpga_mem<T, PropertyListT>>
170  : std::true_type {};
171 template <typename T, typename PropertyListT>
172 struct is_property_key_of<intel::experimental::ram_stitching_key,
173  intel::experimental::fpga_mem<T, PropertyListT>>
174  : std::true_type {};
175 template <typename T, typename PropertyListT>
176 struct is_property_key_of<intel::experimental::max_private_copies_key,
177  intel::experimental::fpga_mem<T, PropertyListT>>
178  : std::true_type {};
179 template <typename T, typename PropertyListT>
180 struct is_property_key_of<intel::experimental::num_replicates_key,
181  intel::experimental::fpga_mem<T, PropertyListT>>
182  : std::true_type {};
183 
184 namespace detail {
185 // Map Property to MetaInfo
186 template <intel::experimental::resource_enum Value>
187 struct PropertyMetaInfo<intel::experimental::resource_key::value_t<Value>> {
188  static constexpr const char *name = "sycl-resource";
189  static constexpr const char *value =
190  ((Value == intel::experimental::resource_enum::mlab) ? "MLAB"
191  : "BLOCK_RAM");
192 };
193 template <size_t Value>
194 struct PropertyMetaInfo<intel::experimental::num_banks_key::value_t<Value>> {
195  static constexpr const char *name = "sycl-num-banks";
196  static constexpr size_t value = Value;
197 };
198 template <size_t Value>
199 struct PropertyMetaInfo<intel::experimental::stride_size_key::value_t<Value>> {
200  static constexpr const char *name = "sycl-stride-size";
201  static constexpr size_t value = Value;
202 };
203 template <size_t Value>
204 struct PropertyMetaInfo<intel::experimental::word_size_key::value_t<Value>> {
205  static constexpr const char *name = "sycl-word-size";
206  static constexpr size_t value = Value;
207 };
208 template <bool Value>
210  intel::experimental::bi_directional_ports_key::value_t<Value>> {
211  // historical uglyness: single property maps to different SPIRV decorations
212  static constexpr const char *name =
213  (Value ? "sycl-bi-directional-ports-true"
214  : "sycl-bi-directional-ports-false");
215  static constexpr std::nullptr_t value = nullptr;
216 };
217 template <bool Value>
218 struct PropertyMetaInfo<intel::experimental::clock_2x_key::value_t<Value>> {
219  // historical uglyness: single property maps to different SPIRV decorations
220  static constexpr const char *name =
221  (Value ? "sycl-clock-2x-true" : "sycl-clock-2x-false");
222  static constexpr std::nullptr_t value = nullptr;
223 };
224 template <intel::experimental::ram_stitching_enum Value>
226  intel::experimental::ram_stitching_key::value_t<Value>> {
227  static constexpr const char *name = "sycl-ram-stitching";
228  // enum to bool conversion to match with the SPIR-V decoration
229  // ForcePow2DepthINTEL
230  static constexpr size_t value = static_cast<size_t>(
232 };
233 template <size_t Value>
235  intel::experimental::max_private_copies_key::value_t<Value>> {
236  static constexpr const char *name = "sycl-max-private-copies";
237  static constexpr size_t value = Value;
238 };
239 template <size_t Value>
241  intel::experimental::num_replicates_key::value_t<Value>> {
242  static constexpr const char *name = "sycl-num-replicates";
243  static constexpr size_t value = Value;
244 };
245 
246 } // namespace detail
247 } // namespace oneapi::experimental
248 } // namespace ext
249 } // namespace _V1
250 } // namespace sycl
constexpr bi_directional_ports_key::value_t< true > bi_directional_ports_true
Definition: properties.hpp:123
constexpr clock_2x_key::value_t< true > clock_2x_true
Definition: properties.hpp:126
constexpr max_private_copies_key::value_t< N > max_private_copies
Definition: properties.hpp:137
constexpr clock_2x_key::value_t< B > clock_2x
Definition: properties.hpp:125
constexpr resource_key::value_t< R > resource
Definition: properties.hpp:107
constexpr num_banks_key::value_t< E > num_banks
Definition: properties.hpp:112
constexpr ram_stitching_key::value_t< D > ram_stitching
Definition: properties.hpp:130
sycl::ext::oneapi::experimental::property_value< PropertyT, Ts... > property_value
constexpr resource_key::value_t< resource_enum::block_ram > resource_block_ram
Definition: properties.hpp:110
constexpr ram_stitching_key::value_t< ram_stitching_enum::max_fmax > ram_stitching_max_fmax
Definition: properties.hpp:134
constexpr bi_directional_ports_key::value_t< B > bi_directional_ports
Definition: properties.hpp:119
constexpr word_size_key::value_t< E > word_size
Definition: properties.hpp:116
constexpr clock_2x_key::value_t< false > clock_2x_false
Definition: properties.hpp:127
constexpr resource_key::value_t< resource_enum::mlab > resource_mlab
Definition: properties.hpp:108
constexpr ram_stitching_key::value_t< ram_stitching_enum::min_ram > ram_stitching_min_ram
Definition: properties.hpp:132
constexpr bi_directional_ports_key::value_t< false > bi_directional_ports_false
Definition: properties.hpp:121
constexpr num_replicates_key::value_t< N > num_replicates
Definition: properties.hpp:140
constexpr stride_size_key::value_t< E > stride_size
Definition: properties.hpp:114
Definition: access.hpp:18