|
| 1 | += sycl_ext_oneapi_inter_process_communication |
| 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 | +:dpcpp: pass:[DPC++] |
| 13 | +:endnote: —{nbsp}end{nbsp}note |
| 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 | + |
| 21 | +== Notice |
| 22 | + |
| 23 | +[%hardbreaks] |
| 24 | +Copyright (C) 2025 Intel Corporation. All rights reserved. |
| 25 | + |
| 26 | +Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks |
| 27 | +of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by |
| 28 | +permission by Khronos. |
| 29 | + |
| 30 | + |
| 31 | +== Contact |
| 32 | + |
| 33 | +To report problems with this extension, please open a new issue at: |
| 34 | + |
| 35 | +https://github.com/intel/llvm/issues |
| 36 | + |
| 37 | + |
| 38 | +== Dependencies |
| 39 | + |
| 40 | +This extension is written against the SYCL 2020 revision 10 specification. All |
| 41 | +references below to the "core SYCL specification" or to section numbers in the |
| 42 | +SYCL specification refer to that revision. |
| 43 | + |
| 44 | + |
| 45 | +== Status |
| 46 | + |
| 47 | +This is an experimental extension specification, intended to provide early |
| 48 | +access to features and gather community feedback. Interfaces defined in this |
| 49 | +specification are implemented in {dpcpp}, but they are not finalized and may |
| 50 | +change incompatibly in future versions of {dpcpp} without prior notice. |
| 51 | +*Shipping software products should not rely on APIs defined in this |
| 52 | +specification.* |
| 53 | + |
| 54 | + |
| 55 | +== Backend support status |
| 56 | + |
| 57 | +The APIs in this extension may be used only on a device that has |
| 58 | +`aspect::ext_oneapi_ipc_memory`. The application must check that the device has |
| 59 | +this aspect before submitting a kernel using any of the APIs in this |
| 60 | +extension. If the application fails to do this, the implementation throws |
| 61 | +a synchronous exception with the `errc::kernel_not_supported` error code |
| 62 | +when the kernel is submitted to the queue. |
| 63 | + |
| 64 | + |
| 65 | +== Overview |
| 66 | + |
| 67 | +This extension adds the ability for SYCL programs to share device USM memory |
| 68 | +allocations between processes. This is done by the allocating process creating |
| 69 | +a new `ipc_memory` object and transferring the "handle data" to the other |
| 70 | +processes. The other processes can use the handle data to recreate the |
| 71 | +`ipc_memory` object and get a pointer to the corresponding device USM memory. |
| 72 | + |
| 73 | + |
| 74 | +== Specification |
| 75 | + |
| 76 | +=== Feature test macro |
| 77 | + |
| 78 | +This extension provides a feature-test macro as described in the core SYCL |
| 79 | +specification. An implementation supporting this extension must predefine the |
| 80 | +macro `SYCL_EXT_ONEAPI_IPC` to one of the values defined in the table |
| 81 | +below. Applications can test for the existence of this macro to determine if |
| 82 | +the implementation supports this feature, or applications can test the macro's |
| 83 | +value to determine which of the extension's features the implementation |
| 84 | +supports. |
| 85 | + |
| 86 | +_And follow the text with a table like this *unless the extension is |
| 87 | +"experimental"*. Note that your table may have more than one row if it |
| 88 | +has multiple versions._ |
| 89 | + |
| 90 | +[%header,cols="1,5"] |
| 91 | +|=== |
| 92 | +|Value |
| 93 | +|Description |
| 94 | + |
| 95 | +|1 |
| 96 | +|The APIs of this experimental extension are not versioned, so the |
| 97 | + feature-test macro always has this value. |
| 98 | +|=== |
| 99 | + |
| 100 | +=== Inter-process communicable memory |
| 101 | + |
| 102 | + |
| 103 | +This extension adds the new `ipc_memory` class. This new class adheres to the |
| 104 | +common reference semantics described in |
| 105 | +https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:reference-semantics[Section 4.5.2.] |
| 106 | +in the SYCL 2020 specification. |
| 107 | + |
| 108 | +``` |
| 109 | +namespace sycl::ext::oneapi::experimental { |
| 110 | + |
| 111 | +class ipc_memory { |
| 112 | +public: |
| 113 | + ipc_memory(void *ptr, sycl::context &ctx); |
| 114 | + ipc_memory(span<const char, sycl::dynamic_extent> ipc_memory_handle_data, |
| 115 | + const sycl::context &ctx, const sycl::device &dev); |
| 116 | + |
| 117 | + span<const char, sycl::dynamic_extent> get_handle_data() const; |
| 118 | + |
| 119 | + void *get_ptr() const; |
| 120 | +}; |
| 121 | + |
| 122 | +} |
| 123 | +``` |
| 124 | + |
| 125 | +|==== |
| 126 | +a| |
| 127 | +[frame=all,grid=none] |
| 128 | +!==== |
| 129 | +a! |
| 130 | +[source] |
| 131 | +---- |
| 132 | +ipc_memory(void *ptr, const sycl::context &ctx) |
| 133 | +---- |
| 134 | +!==== |
| 135 | + |
| 136 | +_Effects:_ Constructs an IPC memory object in `ctx` from a pointer `ptr` to |
| 137 | +device USM memory. |
| 138 | +If `ptr` is not pointing to device USM memory, the behaviors of this constructor |
| 139 | +and any resulting objects are undefined. |
| 140 | + |
| 141 | +!==== |
| 142 | +a! |
| 143 | +[source] |
| 144 | +---- |
| 145 | +ipc_memory(span<const char, sycl::dynamic_extent> ipc_memory_handle_data, |
| 146 | + const sycl::context &ctx, const sycl::device &dev) |
| 147 | +---- |
| 148 | +!==== |
| 149 | + |
| 150 | +_Effects:_ Constructs an IPC memory object in `ctx` from the handle data |
| 151 | +`ipc_memory_handle_data` of returned by the `get_handle_data()` member function |
| 152 | +of another `ipc_memory` object. |
| 153 | +The `ipc_memory` object that the handle data originated from is allowed to be |
| 154 | +from another process on the host system. |
| 155 | +If the `ipc_memory` object that the handle data originated from has been |
| 156 | +destroyed, the behaviors of this constructor and any resulting objects are |
| 157 | +undefined. |
| 158 | +If the device USM memory the original `ipc_memory` object was created with was |
| 159 | +not originally allocated on `dev`, the behaviors of this constructor and any |
| 160 | +resulting objects are undefined. |
| 161 | + |
| 162 | +!==== |
| 163 | +a! |
| 164 | +[source] |
| 165 | +---- |
| 166 | +span<const char, sycl::dynamic_extent> get_handle_data() const |
| 167 | +---- |
| 168 | +!==== |
| 169 | + |
| 170 | +_Returns:_ The handle data of the `ipc_memory` object. |
| 171 | +Accessing the handle data returned by this API after the `ipc_memory` object has |
| 172 | +been destroyed results in undefined behavior. |
| 173 | + |
| 174 | +!==== |
| 175 | +a! |
| 176 | +[source] |
| 177 | +---- |
| 178 | +void *get_ptr() const |
| 179 | +---- |
| 180 | +!==== |
| 181 | + |
| 182 | +_Returns:_ A pointer to device USM memory corresponding to the pointer used to |
| 183 | +construct the original `ipc_memory` object. |
| 184 | +Accessing the pointer returned by this API after the `ipc_memory` object has |
| 185 | +been destroyed results in undefined behavior. |
| 186 | + |
| 187 | +|==== |
| 188 | + |
| 189 | + |
0 commit comments