|
| 1 | += sycl_ext_intel_fpga_annotated_arg_properties |
| 2 | + |
| 3 | +:source-highlighter: coderay |
| 4 | +:coderay-linenums-mode: table |
| 5 | + |
| 6 | +// This section needs to be after the document title. |
| 7 | +:doctype: book |
| 8 | +:toc2: |
| 9 | +:toc: left |
| 10 | +:encoding: utf-8 |
| 11 | +:lang: en |
| 12 | + |
| 13 | +:blank: pass:[ +] |
| 14 | + |
| 15 | +// Set the default source code type in this document to C++, |
| 16 | +// for syntax highlighting purposes. This is needed because |
| 17 | +// docbook uses c++ and html5 uses cpp. |
| 18 | +:language: {basebackend@docbook:c++:cpp} |
| 19 | + |
| 20 | +// This is necessary for asciidoc, but not for asciidoctor |
| 21 | +:cpp: C++ |
| 22 | +:dpcpp: DPC++ |
| 23 | + |
| 24 | +== Notice |
| 25 | + |
| 26 | +Copyright (c) 2021 Intel Corporation. All rights reserved. |
| 27 | + |
| 28 | +NOTE: Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are |
| 29 | +trademarks of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. |
| 30 | +used by permission by Khronos. |
| 31 | + |
| 32 | +== Contact |
| 33 | + |
| 34 | +To report problems with this extension, please open a new issue at: |
| 35 | + |
| 36 | +https://github.com/intel/llvm/issues |
| 37 | + |
| 38 | +== Contributors |
| 39 | + |
| 40 | +Abhishek Tiwari, Intel + |
| 41 | +Joseph Garvey, Intel |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +== Dependencies |
| 47 | + |
| 48 | +This extension is written against the SYCL 2020 specification, revision 4. |
| 49 | + |
| 50 | +It depends on the following extensions: |
| 51 | + |
| 52 | + - link:../experimental/sycl_ext_oneapi_properties.asciidoc[sycl_ext_oneapi_properties] |
| 53 | + - link:sycl_ext_oneapi_annotated_arg.asciidoc[sycl_ext_oneapi_annotated_arg] |
| 54 | + |
| 55 | +== Status |
| 56 | + |
| 57 | +This is a proposed extension specification, intended to gather community |
| 58 | +feedback. Interfaces defined in this specification may not be implemented yet |
| 59 | +or may be in a preliminary state. The specification itself may also change in |
| 60 | +incompatible ways before it is finalized. *Shipping software products should |
| 61 | +not rely on APIs defined in this specification.* |
| 62 | + |
| 63 | +== Overview |
| 64 | + |
| 65 | +This extension introduces properties for the class |
| 66 | +`sycl::ext::oneapi::annotated_arg`. The properties will influence the kernel |
| 67 | +argument interfaces for FPGA kernels and can be ignored for other devices. |
| 68 | + |
| 69 | +Some examples of the syntax are shown below. |
| 70 | + |
| 71 | +.Example 1 |
| 72 | +[source,c++] |
| 73 | +---- |
| 74 | +annotated_arg<MyType, properties<register_map>> ptr_a; |
| 75 | +---- |
| 76 | + |
| 77 | +.Example 2 |
| 78 | +[source,c++] |
| 79 | +---- |
| 80 | +auto data = ... |
| 81 | +auto arg = annotated_arg(data, properties{register_map}); |
| 82 | +---- |
| 83 | + |
| 84 | +== Specification |
| 85 | + |
| 86 | +=== Feature test macro |
| 87 | + |
| 88 | +This extension provides a feature-test macro as described in the core SYCL |
| 89 | +specification. An implementation supporting this extension must predefine the |
| 90 | +macro `SYCL_EXT_INTEL_FPGA_ANNOTATED_ARG_PROPERTIES` to one of the values |
| 91 | +defined in the table below. Applications can test for the existence of this |
| 92 | +macro to determine if the implementation supports this feature, or applications |
| 93 | +can test the macro's value to determine which of the extension's features the |
| 94 | +implementation supports. |
| 95 | + |
| 96 | +[%header,cols="1,5"] |
| 97 | +|=== |
| 98 | +|Value |
| 99 | +|Description |
| 100 | + |
| 101 | +|1 |
| 102 | +|Initial version of this extension. |
| 103 | +|=== |
| 104 | + |
| 105 | +=== `annotated_arg` Properties |
| 106 | + |
| 107 | +Below is a list of compile-time constant properties supported with |
| 108 | +`annotated_arg`. These properties control the kernel argument interface on FPGA |
| 109 | +devices. |
| 110 | + |
| 111 | +```c++ |
| 112 | +namespace sycl::ext::oneapi::experimental { |
| 113 | +struct register_map_key { |
| 114 | + using value_t = property_value<register_map_key>; |
| 115 | +}; |
| 116 | + |
| 117 | +inline constexpr register_map_key::value_t register_map; |
| 118 | + |
| 119 | +template<> struct is_property_key<register_map_key> : std::true_type {}; |
| 120 | + |
| 121 | +template <typename T, typename PropertyListT> |
| 122 | +struct is_property_key_of<register_map_key, |
| 123 | + annotated_arg<T, PropertyListT>> : std::true_type {}; |
| 124 | + |
| 125 | +struct conduit_key { |
| 126 | + using value_t = property_value<conduit_key>; |
| 127 | +}; |
| 128 | + |
| 129 | +inline constexpr conduit_key::value_t conduit; |
| 130 | + |
| 131 | +template<> struct is_property_key<conduit_key> : std::true_type {}; |
| 132 | + |
| 133 | +template <typename T, typename PropertyListT> |
| 134 | +struct is_property_key_of<conduit_key, |
| 135 | + annotated_arg<T, PropertyListT>> : std::true_type {}; |
| 136 | + |
| 137 | +struct stable_key { |
| 138 | + using value_t = property_value<stable_key>; |
| 139 | +}; |
| 140 | + |
| 141 | +inline constexpr stable_key::value_t stable; |
| 142 | + |
| 143 | +template<> struct is_property_key<stable_key> : std::true_type {}; |
| 144 | + |
| 145 | +template <typename T, typename PropertyListT> |
| 146 | +struct is_property_key_of<stable_key, |
| 147 | + annotated_arg<T, PropertyListT>> : std::true_type {}; |
| 148 | +} // namespace experimental::oneapi::ext::sycl |
| 149 | +``` |
| 150 | +-- |
| 151 | + |
| 152 | +[frame="topbot",options="header"] |
| 153 | +|=== |
| 154 | +|Property |Description |
| 155 | + |
| 156 | +a| |
| 157 | +[source,c++] |
| 158 | +---- |
| 159 | +conduit |
| 160 | +---- |
| 161 | +a| |
| 162 | +Directs the compiler to create a dedicated input port on the kernel for the |
| 163 | +input data. |
| 164 | + |
| 165 | +a| |
| 166 | +[source,c++] |
| 167 | +---- |
| 168 | +register_map |
| 169 | +---- |
| 170 | +a| |
| 171 | +Directs the compiler to create a register to store the base address of the |
| 172 | +of the pointer interface as opposed to creating a dedicated input port on the |
| 173 | +kernel for supplying the pointer base address. |
| 174 | + |
| 175 | +a| |
| 176 | +[source,c++] |
| 177 | +---- |
| 178 | +stable |
| 179 | +---- |
| 180 | +a| |
| 181 | +Specifies that the input pointer address to the kernel will not change during |
| 182 | +the execution of the kernel. The input can still change after all active |
| 183 | +kernel invocations have finished. |
| 184 | + |
| 185 | +If the input is changed while the kernel is executing, the behavior is |
| 186 | +undefined. |
| 187 | + |
| 188 | +|=== |
| 189 | +-- |
| 190 | + |
| 191 | +=== Aliases provided for convenience |
| 192 | + |
| 193 | +[source,c++] |
| 194 | +---- |
| 195 | +namespace sycl::ext::oneapi::experimental{ |
| 196 | + template <typename T, typename PropertyListT> |
| 197 | + using register_map = annotated_arg<T, properties{ |
| 198 | + register_map, PropertyListT}>; |
| 199 | +
|
| 200 | + template <typename T, typename PropertyListT> |
| 201 | + using conduit = annotated_arg<T, properties{ |
| 202 | + conduit, PropertyListT}>; |
| 203 | +}; // namespace sycl::ext::oneapi::experimental |
| 204 | +---- |
| 205 | + |
| 206 | +=== Usage Examples |
| 207 | + |
| 208 | +The examples below show a simple kernel with two integer arguments marked with |
| 209 | +`register_map` and `stable` properties. |
| 210 | + |
| 211 | +.Usage example with a SYCL functor |
| 212 | +```c++ |
| 213 | +using sycl::ext::oneapi::experimental; |
| 214 | +struct MyKernel { |
| 215 | + using RegisterMapArg = annotated_arg<int, properties<register_map, stable>>; |
| 216 | + RegisterMapArg a; |
| 217 | + RegisterMapArg b; |
| 218 | + ... |
| 219 | + void operator()() const { |
| 220 | + ... = a * b; |
| 221 | + } |
| 222 | +}; |
| 223 | + |
| 224 | +int main () { |
| 225 | + sycl::queue q; |
| 226 | + int data_a = ... |
| 227 | + int data_b = ... |
| 228 | + |
| 229 | + MyKernel my_k; |
| 230 | + my_k.a = data_a; |
| 231 | + my_k.a = data_b; |
| 232 | + ... |
| 233 | + q.single_task(my_k).wait(); |
| 234 | + ... |
| 235 | +} |
| 236 | +``` |
| 237 | + |
| 238 | +.Usage example with a SYCL lambda |
| 239 | +```c++ |
| 240 | +using sycl::ext::oneapi::experimental; |
| 241 | + |
| 242 | +int main () { |
| 243 | + sycl::queue q; |
| 244 | + int data_a = ... |
| 245 | + int data_b = ... |
| 246 | + auto a = annotated_arg(data_a, properties{register_map, stable}); |
| 247 | + auto b = annotated_arg(data_b, properties{register_map, stable}); |
| 248 | + ... |
| 249 | + q.single_task([=] { |
| 250 | + ... = a * b; |
| 251 | + }).wait(); |
| 252 | + ... |
| 253 | +} |
| 254 | +``` |
| 255 | + |
| 256 | +== Issues |
| 257 | + |
| 258 | +1. How to document the motivation for this without duplicating what we already |
| 259 | +wrote for the `annotated_ptr` extension? Is the duplication acceptable? |
| 260 | + |
| 261 | +2. TODO: Correct the syntax of the aliases provided in this document. |
| 262 | + |
| 263 | +== Revision History |
| 264 | + |
| 265 | +[cols="5,15,15,70"] |
| 266 | +[grid="rows"] |
| 267 | +[options="header"] |
| 268 | +|======================================== |
| 269 | +|Rev|Date|Author|Changes |
| 270 | +|1|2022-04-13|Abhishek Tiwari|*Initial draft* |
| 271 | +|======================================== |
| 272 | + |
| 273 | +//************************************************************************ |
| 274 | +//Other formatting suggestions: |
| 275 | +// |
| 276 | +//* Use *bold* text for host APIs, or [source] syntax highlighting. |
| 277 | +//* Use +mono+ text for device APIs, or [source] syntax highlighting. |
| 278 | +//* Use +mono+ text for extension names, types, or enum values. |
| 279 | +//* Use _italics_ for parameters. |
| 280 | +//************************************************************************ |
0 commit comments