|
| 1 | += sycl_ext_oneapi_peer_access |
| 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 | + |
| 14 | +// Set the default source code type in this document to C++, |
| 15 | +// for syntax highlighting purposes. This is needed because |
| 16 | +// docbook uses c++ and html5 uses cpp. |
| 17 | +:language: {basebackend@docbook:c++:cpp} |
| 18 | + |
| 19 | + |
| 20 | +== Notice |
| 21 | + |
| 22 | +[%hardbreaks] |
| 23 | +Copyright (C) 2022-2023 Intel Corporation. All rights reserved. |
| 24 | + |
| 25 | +Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks |
| 26 | +of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by |
| 27 | +permission by Khronos. |
| 28 | + |
| 29 | + |
| 30 | +== Contact |
| 31 | + |
| 32 | +To report problems with this extension, please open a new issue at: |
| 33 | + |
| 34 | +https://github.com/intel/llvm/issues |
| 35 | + |
| 36 | + |
| 37 | +== Dependencies |
| 38 | + |
| 39 | +This extension is written against the SYCL 2020 revision 6 specification. All |
| 40 | +references below to the "core SYCL specification" or to section numbers in the |
| 41 | +SYCL specification refer to that revision. |
| 42 | + |
| 43 | +== Status |
| 44 | + |
| 45 | +This is a proposed extension specification, intended to gather community |
| 46 | +feedback. Interfaces defined in this specification may not be implemented yet |
| 47 | +or may be in a preliminary state. The specification itself may also change in |
| 48 | +incompatible ways before it is finalized. *Shipping software products should |
| 49 | +not rely on APIs defined in this specification.* |
| 50 | + |
| 51 | + |
| 52 | +== Overview |
| 53 | + |
| 54 | +This extension adds support for mechanisms to query and enable support for |
| 55 | +memory access between peer devices in a system. |
| 56 | +In particular, this allows one device to access USM Device allocations |
| 57 | +for a peer device. This extension does not apply to USM Shared allocations. |
| 58 | +Peer to peer capabilities are useful as they can provide |
| 59 | +access to a peer device's memory inside a compute kernel and optimized memory |
| 60 | +copies between peer devices. |
| 61 | + |
| 62 | +== Specification |
| 63 | + |
| 64 | +=== Feature test macro |
| 65 | + |
| 66 | +This extension provides a feature-test macro as described in the core SYCL |
| 67 | +specification. An implementation supporting this extension must predefine the |
| 68 | +macro `SYCL_EXT_ONEAPI_PEER_ACCESS` to one of the values defined in the table |
| 69 | +below. Applications can test for the existence of this macro to determine if |
| 70 | +the implementation supports this feature, or applications can test the macro's |
| 71 | +value to determine which of the extension's features the implementation |
| 72 | +supports. |
| 73 | + |
| 74 | +[%header,cols="1,5"] |
| 75 | +|=== |
| 76 | +|Value |
| 77 | +|Description |
| 78 | + |
| 79 | +|1 |
| 80 | +|Initial version of this extension. |
| 81 | +|=== |
| 82 | + |
| 83 | + |
| 84 | +=== Peer to Peer (P2P) Memory Access APIs |
| 85 | + |
| 86 | +This extension adds support for mechanisms to query and enable support for |
| 87 | +direct memory access between peer devices in a system. |
| 88 | +In particular, this allows one device to directly access USM Device |
| 89 | +allocations for a peer device in the same context. |
| 90 | +Peer to peer capabilities are useful as they can provide access to a peer |
| 91 | +device's memory inside a compute kernel and also optimized memory copies between |
| 92 | +peer devices. |
| 93 | + |
| 94 | +This extension adds the following new member functions to the device class, as described |
| 95 | +below. |
| 96 | + |
| 97 | +[source,c++] |
| 98 | +---- |
| 99 | +namespace sycl { |
| 100 | +namespace ext { |
| 101 | +namespace oneapi { |
| 102 | +enum class peer_access { |
| 103 | + access_supported, |
| 104 | + access_enabled, |
| 105 | + atomics_supported, |
| 106 | +}; |
| 107 | +} // namespace oneapi |
| 108 | +} // namespace ext |
| 109 | +
|
| 110 | +class device { |
| 111 | +public: |
| 112 | + bool ext_oneapi_can_access_peer(const device &peer, |
| 113 | + ext::oneapi::peer_access value = |
| 114 | + ext::oneapi::peer_access::access_supported); |
| 115 | + void ext_oneapi_enable_peer_access(const device &peer); |
| 116 | + void ext_oneapi_disable_peer_access(const device &peer); |
| 117 | +}; |
| 118 | +
|
| 119 | +} // namespace sycl |
| 120 | +---- |
| 121 | + |
| 122 | +The semantics of the new functions are: |
| 123 | + |
| 124 | +|=== |
| 125 | +|Member Function |Description |
| 126 | + |
| 127 | +|bool ext_oneapi_can_access_peer(const device &peer, |
| 128 | + ext::oneapi::peer_access value = |
| 129 | + ext::oneapi::peer_access::access_supported) |
| 130 | +a|Queries the peer access status between this device and `peer` according to |
| 131 | +the query `value`: |
| 132 | + |
| 133 | +* `ext::oneapi::peer_access::access_supported`: Returns true only if it is |
| 134 | +possible for this device to enable peer access to USM device memory allocations |
| 135 | +located on the `peer` device. |
| 136 | + |
| 137 | +* `ext::oneapi::peer_access::atomics_supported`: When this query returns true, |
| 138 | +it indicates that this device may concurrently access and atomically modify USM |
| 139 | +device memory allocations located on the `peer` device when peer access is enabled |
| 140 | +to that device. Atomics performed on a peer device's memory must have |
| 141 | +`memory_scope::system` scope. |
| 142 | +If the query returns false, attempting to concurrently access or atomically |
| 143 | +modify USM device memory located on the `peer` device results in undefined |
| 144 | +behavior. |
| 145 | + |
| 146 | +|void enable_peer_access(const device &peer) |
| 147 | +|Enables this device to access USM device allocations located on the peer |
| 148 | +device. This does not permit the peer device to access this device's memory. |
| 149 | +Once this access is enabled, SYCL kernel functions and the explicit memory |
| 150 | +functions may access USM device allocations on the peer device subject to the |
| 151 | +normal rules about context as described in the core SYCL specification. |
| 152 | +If this device does not support peer access (as defined by |
| 153 | +`peer_access::access_supported`), throws an `exception` with the |
| 154 | +`errc::feature_not_supported` error code. If access is already enabled, |
| 155 | +throws an exception with the `errc::invalid` error code. |
| 156 | + |
| 157 | + |
| 158 | +|void disable_peer_access(const device &peer) |
| 159 | +|Disables access to the peer device's memory from this device. If peer access |
| 160 | +is not enabled, throws an `exception` with the `errc::invalid` error code. |
| 161 | + |
| 162 | +|=== |
| 163 | + |
0 commit comments