Skip to content

Commit eec1fe5

Browse files
committed
[SYCL][Docs] Add sycl_ext_oneapi_inter_process_communication
This commit adds a new extension for inter-process communicable SYCL object handles. As part of the initial version of this extension, only inter-process communicable memory is exposed. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent d84a020 commit eec1fe5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4053
-4
lines changed

llvm/include/llvm/SYCLLowerIR/DeviceConfigFile.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def Aspectext_oneapi_exportable_device_mem : Aspect<"ext_oneapi_exportable_devic
9797
def Aspectext_oneapi_clock_sub_group : Aspect<"ext_oneapi_clock_sub_group">;
9898
def Aspectext_oneapi_clock_work_group : Aspect<"ext_oneapi_clock_work_group">;
9999
def Aspectext_oneapi_clock_device : Aspect<"ext_oneapi_clock_device">;
100+
def Aspectext_oneapi_ipc_memory : Aspect<"ext_oneapi_ipc_memory">;
100101

101102
// Deprecated aspects
102103
def AspectInt64_base_atomics : Aspect<"int64_base_atomics">;
@@ -174,7 +175,8 @@ def : TargetInfo<"__TestAspectList",
174175
Aspectext_oneapi_exportable_device_mem,
175176
Aspectext_oneapi_clock_sub_group,
176177
Aspectext_oneapi_clock_work_group,
177-
Aspectext_oneapi_clock_device],
178+
Aspectext_oneapi_clock_device,
179+
Aspectext_oneapi_ipc_memory],
178180
[]>;
179181
// This definition serves the only purpose of testing whether the deprecated aspect list defined in here and in SYCL RT
180182
// match.
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
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: &#8212;{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+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//==------- ipc_memory.hpp --- SYCL inter-process communicable memory ------==//
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/detail/defines_elementary.hpp>
12+
#include <sycl/detail/export.hpp>
13+
#include <sycl/detail/owner_less_base.hpp>
14+
#include <sycl/sycl_span.hpp>
15+
16+
#include <memory>
17+
18+
namespace sycl {
19+
inline namespace _V1 {
20+
21+
class context;
22+
class device;
23+
24+
namespace detail {
25+
class ipc_memory_impl;
26+
}
27+
28+
namespace ext::oneapi::experimental {
29+
class __SYCL_EXPORT ipc_memory
30+
: public sycl::detail::OwnerLessBase<ipc_memory> {
31+
public:
32+
ipc_memory(void *Ptr, const sycl::context &Ctx);
33+
ipc_memory(const span<const char, sycl::dynamic_extent> IPCMemoryHandleData,
34+
const sycl::context &Ctx, const sycl::device &Dev);
35+
36+
sycl::span<const char, sycl::dynamic_extent> get_handle_data() const;
37+
38+
void *get_ptr() const;
39+
40+
private:
41+
ipc_memory(std::shared_ptr<sycl::detail::ipc_memory_impl> IPCMemImpl)
42+
: impl{IPCMemImpl} {}
43+
44+
std::shared_ptr<sycl::detail::ipc_memory_impl> impl;
45+
46+
template <class Obj>
47+
friend const decltype(Obj::impl) &
48+
sycl::detail::getSyclObjImpl(const Obj &SyclObject);
49+
50+
template <class T>
51+
friend T sycl::detail::createSyclObjFromImpl(
52+
std::add_rvalue_reference_t<decltype(T::impl)> ImplObj);
53+
template <class T>
54+
friend T sycl::detail::createSyclObjFromImpl(
55+
std::add_lvalue_reference_t<const decltype(T::impl)> ImplObj);
56+
};
57+
} // namespace ext::oneapi::experimental
58+
} // namespace _V1
59+
} // namespace sycl

sycl/include/sycl/info/aspects.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,4 @@ __SYCL_ASPECT(ext_oneapi_exportable_device_mem, 90)
8383
__SYCL_ASPECT(ext_oneapi_clock_sub_group, 91)
8484
__SYCL_ASPECT(ext_oneapi_clock_work_group, 92)
8585
__SYCL_ASPECT(ext_oneapi_clock_device, 93)
86+
__SYCL_ASPECT(ext_oneapi_ipc_memory, 94)

sycl/include/sycl/sycl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ can be disabled by setting SYCL_DISABLE_FSYCL_SYCLHPP_WARNING macro.")
128128
#include <sycl/ext/oneapi/experimental/group_helpers_sorters.hpp>
129129
#include <sycl/ext/oneapi/experimental/group_load_store.hpp>
130130
#include <sycl/ext/oneapi/experimental/group_sort.hpp>
131+
#include <sycl/ext/oneapi/experimental/ipc_memory.hpp>
131132
#include <sycl/ext/oneapi/experimental/prefetch.hpp>
132133
#include <sycl/ext/oneapi/experimental/profiling_tag.hpp>
133134
#include <sycl/ext/oneapi/experimental/raw_kernel_arg.hpp>

sycl/source/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ set(SYCL_COMMON_SOURCES
321321
"handler.cpp"
322322
"image.cpp"
323323
"interop_handle.cpp"
324+
"ipc_memory.cpp"
324325
"kernel.cpp"
325326
"kernel_bundle.cpp"
326327
"physical_mem.cpp"

sycl/source/detail/device_impl.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,6 +1591,10 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
15911591
// Will be updated in a follow-up UR patch.
15921592
return false;
15931593
}
1594+
CASE(ext_oneapi_ipc_memory) {
1595+
return get_info_impl_nocheck<UR_DEVICE_INFO_IPC_MEMORY_SUPPORT_EXP>()
1596+
.value_or(0);
1597+
}
15941598
else {
15951599
return false; // This device aspect has not been implemented yet.
15961600
}

0 commit comments

Comments
 (0)