|
| 1 | += sycl_ext_oneapi_memcpy2d |
| 2 | +:source-highlighter: coderay |
| 3 | +:coderay-linenums-mode: table |
| 4 | + |
| 5 | +// This section needs to be after the document title. |
| 6 | +:doctype: book |
| 7 | +:toc2: |
| 8 | +:toc: left |
| 9 | +:encoding: utf-8 |
| 10 | +:lang: en |
| 11 | +:dpcpp: pass:[DPC++] |
| 12 | + |
| 13 | +// Set the default source code type in this document to C++, |
| 14 | +// for syntax highlighting purposes. This is needed because |
| 15 | +// docbook uses c++ and html5 uses cpp. |
| 16 | +:language: {basebackend@docbook:c++:cpp} |
| 17 | + |
| 18 | +== Notice |
| 19 | + |
| 20 | +[%hardbreaks] |
| 21 | +Copyright (C) 2022-2022 Intel Corporation. All rights reserved. |
| 22 | + |
| 23 | +Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks |
| 24 | +of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by |
| 25 | +permission by Khronos. |
| 26 | + |
| 27 | +== Contact |
| 28 | + |
| 29 | +To report problems with this extension, please open a new issue at: |
| 30 | + |
| 31 | +https://github.com/intel/llvm/issues |
| 32 | + |
| 33 | + |
| 34 | +== Dependencies |
| 35 | + |
| 36 | +This extension is written against the SYCL 2020 revision 4 specification. All |
| 37 | +references below to the "core SYCL specification" or to section numbers in the |
| 38 | +SYCL specification refer to that revision. |
| 39 | + |
| 40 | +== Status |
| 41 | + |
| 42 | +This is a proposed extension specification, intended to gather community |
| 43 | +feedback. Interfaces defined in this specification may not be implemented yet |
| 44 | +or may be in a preliminary state. The specification itself may also change in |
| 45 | +incompatible ways before it is finalized. *Shipping software products should |
| 46 | +not rely on APIs defined in this specification.* |
| 47 | + |
| 48 | +== Specification |
| 49 | + |
| 50 | +This extension adds support for 2D memcpy and associated routines that can |
| 51 | +copy a specified rectangular region in the presence of array padding. |
| 52 | + |
| 53 | +=== Feature test macro |
| 54 | + |
| 55 | +This extension provides a feature-test macro as described in the core SYCL |
| 56 | +specification. An implementation supporting this extension must predefine the |
| 57 | +macro `SYCL_EXT_ONEAPI_MEMCPY2D` to one of the values defined in the table |
| 58 | +below. Applications can test for the existence of this macro to determine if |
| 59 | +the implementation supports this feature, or applications can test the macro's |
| 60 | +value to determine which of the extension's features the implementation |
| 61 | +supports. |
| 62 | + |
| 63 | +[%header,cols="1,5"] |
| 64 | +|=== |
| 65 | +|Value |
| 66 | +|Description |
| 67 | + |
| 68 | +|1 |
| 69 | +|Initial version of this extension. |
| 70 | +|=== |
| 71 | + |
| 72 | +=== API Additions |
| 73 | + |
| 74 | + |
| 75 | +The handler class gains the following new methods: |
| 76 | + |
| 77 | +[cols="60a,40"] |
| 78 | +|=== |
| 79 | +| Member Function | Description |
| 80 | + |
| 81 | +a| |
| 82 | +[source,c++] |
| 83 | +---- |
| 84 | +void ext_oneapi_memcpy2d(void *dest, size_t destPitch, |
| 85 | + const void *src, size_t srcPitch, |
| 86 | + size_t width, size_t height) |
| 87 | +---- |
| 88 | + |
| 89 | +| Copies the data located at `src` to `dest`. The width of a row in bytes, |
| 90 | +including any padding, is specified by `destPitch` for `dest` and `srcPitch` |
| 91 | +for `src`. The amount of data to copy is specified as `width` bytes per row |
| 92 | +times `height` number of rows. `width` must not be larger than either |
| 93 | +`srcPitch` or `destPitch`, otherwise this function throws a synchronous |
| 94 | +`exception` with the `errc::invalid` error code. The `dest` and `src` |
| 95 | +parameters must each either be a host pointer or a pointer within a USM |
| 96 | +allocation that is accessible on the handler's device. If a pointer is to a |
| 97 | +USM allocation, that allocation must have been created from the same context |
| 98 | +as the handler's queue. |
| 99 | + |
| 100 | +a| |
| 101 | +[source,c++] |
| 102 | +---- |
| 103 | +template <typename T> |
| 104 | +void ext_oneapi_copy2d(const T *src, size_t srcPitch, |
| 105 | + T *dest, size_t destPitch, |
| 106 | + size_t width, size_t height) |
| 107 | +---- |
| 108 | + |
| 109 | +| Copies the data located at `src` to `dest`. The width of a row in number |
| 110 | +of elements, including any padding, is specified by `destPitch` for `dest` |
| 111 | +and `srcPitch` for `src`. The amount of data to copy is specified as `width` |
| 112 | +elements per row times `height` number of rows. `width` must not be larger |
| 113 | +than either `srcPitch` or `destPitch`, otherwise this function throws a |
| 114 | +synchronous `exception` with the `errc::invalid` error code. The `dest` |
| 115 | +and `src` parameters must each either be a host pointer or a pointer within |
| 116 | +a USM allocation that is accessible on the handler's device. If a pointer is |
| 117 | +to a USM allocation, that allocation must have been created from the same context |
| 118 | +as the handler's queue. |
| 119 | + |
| 120 | +a| |
| 121 | +[source,c++] |
| 122 | +---- |
| 123 | +void ext_oneapi_memset2d(void *dest, size_t destPitch, |
| 124 | + int value, size_t width, size_t height) |
| 125 | +---- |
| 126 | + |
| 127 | +| Fills the data located at `dest` with `value`. Note that `value` is |
| 128 | +interpreted as an `unsigned char`. The width of a row in bytes, |
| 129 | +including any padding, is specified by `destPitch` for `dest`. |
| 130 | +The amount of data to fill is specified as `width` bytes per row |
| 131 | +times `height` number of rows. `width` must not be larger than `destPitch`, |
| 132 | +otherwise this function throws a synchronous `exception` with the |
| 133 | +`errc::invalid` error code. The `dest` parameter must be a pointer |
| 134 | +within a USM allocation that is accessible on the handler's device and |
| 135 | +that allocation must have been created from the same context as the |
| 136 | +handler's queue. |
| 137 | + |
| 138 | +a| |
| 139 | +[source,c++] |
| 140 | +---- |
| 141 | +template <typename T> |
| 142 | +void ext_oneapi_fill2d(void *dest, size_t destPitch, |
| 143 | + const T& pattern, size_t width, size_t height) |
| 144 | +---- |
| 145 | + |
| 146 | +| Fills the data located at `dest` with `pattern`. The width of a row in |
| 147 | +number of elements, including any padding, is specified by `destPitch`. |
| 148 | +The amount of data to fill is specified as `width` elements per row |
| 149 | +times `height` number of rows. `width` must not be larger than `destPitch`, |
| 150 | +otherwise this function throws a synchronous `exception` with the |
| 151 | +`errc::invalid` error code. The `dest` parameter must be a pointer within |
| 152 | +a USM allocation that is accessible on the handler's device and that |
| 153 | +allocation must have been created from the same context as the handler's |
| 154 | +queue. |
| 155 | + |
| 156 | +|=== |
| 157 | + |
| 158 | +This extension also defines additional shortcut methods. The `queue` class |
| 159 | +gains several new methods: |
| 160 | + |
| 161 | +[cols="60a,40"] |
| 162 | +|=== |
| 163 | +| Member Function | Description |
| 164 | + |
| 165 | +| |
| 166 | +[source,c++] |
| 167 | +---- |
| 168 | +event ext_oneapi_memcpy2d(void *dest, size_t destPitch, |
| 169 | + const void *src, size_t srcPitch, |
| 170 | + size_t width, size_t height) |
| 171 | +
|
| 172 | +event ext_oneapi_memcpy2d(void *dest, size_t destPitch, |
| 173 | + const void *src, size_t srcPitch, |
| 174 | + size_t width, size_t height, |
| 175 | + event depEvent) |
| 176 | +
|
| 177 | +event ext_oneapi_memcpy2d(void *dest, size_t destPitch, |
| 178 | + const void *src, size_t srcPitch, |
| 179 | + size_t width, size_t height, |
| 180 | + const std::vector<event> &depEvents) |
| 181 | +
|
| 182 | +template <typename T> |
| 183 | +event ext_oneapi_copy2d(const T *src, size_t srcPitch, |
| 184 | + T *dest, size_t destPitch, |
| 185 | + size_t width, size_t height) |
| 186 | +
|
| 187 | +template <typename T> |
| 188 | +event ext_oneapi_copy2d(const T *src, size_t srcPitch, |
| 189 | + T *dest, size_t destPitch, |
| 190 | + size_t width, size_t height, |
| 191 | + event depEvent) |
| 192 | +
|
| 193 | +template <typename T> |
| 194 | +event ext_oneapi_copy2d(const T *src, size_t srcPitch, |
| 195 | + T *dest, size_t destPitch, |
| 196 | + size_t width, size_t height, |
| 197 | + const std::vector<event> &depEvents) |
| 198 | +
|
| 199 | +event ext_oneapi_memset2d(void *dest, size_t destPitch, |
| 200 | + int value, size_t width, size_t height) |
| 201 | +
|
| 202 | +event ext_oneapi_memset2d(void *dest, size_t destPitch, |
| 203 | + int value, size_t width, size_t height, |
| 204 | + event depEvent) |
| 205 | +
|
| 206 | +event ext_oneapi_memset2d(void *dest, size_t destPitch, |
| 207 | + int value, size_t width, size_t height, |
| 208 | + const std::vector<event> &depEvents) |
| 209 | +
|
| 210 | +template <typename T> |
| 211 | +event ext_oneapi_fill2d(void *dest, size_t destPitch, |
| 212 | + const T& pattern, size_t width, size_t height) |
| 213 | +
|
| 214 | +template <typename T> |
| 215 | +event ext_oneapi_fill2d(void *dest, size_t destPitch, |
| 216 | + const T& pattern, size_t width, size_t height, |
| 217 | + event depEvent) |
| 218 | +
|
| 219 | +template <typename T> |
| 220 | +event ext_oneapi_fill2d(void *dest, size_t destPitch, |
| 221 | + const T& pattern, size_t width, size_t height, |
| 222 | + const std::vector<event> &depEvents) |
| 223 | +
|
| 224 | +---- |
| 225 | + |
| 226 | +| Equivalent to submitting a command group containing the corresponding |
| 227 | +method in the `handler` class. Dependences may be specified through |
| 228 | +the parameters `depEvent` or `depEvents` as if the handler contained a call to |
| 229 | +`depends_on`. |
| 230 | + |
| 231 | +|=== |
| 232 | + |
| 233 | + |
| 234 | + |
| 235 | + |
0 commit comments