Skip to content

Commit cae8ee3

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 5da31d4 commit cae8ee3

Some content is hidden

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

64 files changed

+3650
-4
lines changed

llvm/include/llvm/SYCLLowerIR/DeviceConfigFile.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def AspectExt_oneapi_async_memory_alloc : Aspect<"ext_oneapi_async_memory_alloc"
9494
def AspectExt_intel_device_info_luid : Aspect<"ext_intel_device_info_luid">;
9595
def AspectExt_intel_device_info_node_mask : Aspect<"ext_intel_device_info_node_mask">;
9696
def Aspectext_oneapi_exportable_device_mem : Aspect<"ext_oneapi_exportable_device_mem">;
97+
def Aspectext_oneapi_ipc_memory : Aspect<"ext_oneapi_ipc_memory">;
9798

9899
// Deprecated aspects
99100
def AspectInt64_base_atomics : Aspect<"int64_base_atomics">;
@@ -168,7 +169,8 @@ def : TargetInfo<"__TestAspectList",
168169
AspectExt_oneapi_async_memory_alloc,
169170
AspectExt_intel_device_info_luid,
170171
AspectExt_intel_device_info_node_mask,
171-
Aspectext_oneapi_exportable_device_mem],
172+
Aspectext_oneapi_exportable_device_mem,
173+
Aspectext_oneapi_ipc_memory],
172174
[]>;
173175
// This definition serves the only purpose of testing whether the deprecated aspect list defined in here and in SYCL RT
174176
// match.
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
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+
TODO
68+
69+
70+
== Specification
71+
72+
=== Feature test macro
73+
74+
This extension provides a feature-test macro as described in the core SYCL
75+
specification. An implementation supporting this extension must predefine the
76+
macro `SYCL_EXT_ONEAPI_IPC` to one of the values defined in the table
77+
below. Applications can test for the existence of this macro to determine if
78+
the implementation supports this feature, or applications can test the macro's
79+
value to determine which of the extension's features the implementation
80+
supports.
81+
82+
_And follow the text with a table like this *unless the extension is
83+
"experimental"*. Note that your table may have more than one row if it
84+
has multiple versions._
85+
86+
[%header,cols="1,5"]
87+
|===
88+
|Value
89+
|Description
90+
91+
|1
92+
|The APIs of this experimental extension are not versioned, so the
93+
feature-test macro always has this value.
94+
|===
95+
96+
=== Inter-process communicable memory
97+
98+
99+
This extension adds the new `ipc_memory` class. This new class adheres to the
100+
common reference semantics described in
101+
https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:reference-semantics[Section 4.5.2.]
102+
in the SYCL 2020 specification.
103+
104+
```
105+
namespace sycl::ext::oneapi::experimental {
106+
107+
class ipc_memory {
108+
public:
109+
ipc_memory(void *ptr, sycl::context &ctx);
110+
ipc_memory(span<const char, sycl::dynamic_extent> ipc_memory_handle_data,
111+
const sycl::context &ctx, const sycl::device &dev);
112+
113+
span<const char, sycl::dynamic_extent> get_handle_data() const;
114+
115+
void *get_ptr() const;
116+
};
117+
118+
}
119+
```
120+
121+
|====
122+
a|
123+
[frame=all,grid=none]
124+
!====
125+
a!
126+
[source]
127+
----
128+
ipc_memory(void *ptr, const sycl::context &ctx)
129+
----
130+
!====
131+
132+
_Effects:_ Constructs an IPC memory object in `ctx` from a pointer `ptr` to
133+
device USM memory.
134+
If `ptr` is not pointing to device USM memory, the behaviors of this constructor
135+
and any resulting objects are undefined.
136+
137+
!====
138+
a!
139+
[source]
140+
----
141+
ipc_memory(span<const char, sycl::dynamic_extent> ipc_memory_handle_data,
142+
const sycl::context &ctx, const sycl::device &dev)
143+
----
144+
!====
145+
146+
_Effects:_ Constructs an IPC memory object in `ctx` from the handle data
147+
`ipc_memory_handle_data` of returned by the `get_handle_data()` member function
148+
of another `ipc_memory` object.
149+
The `ipc_memory` object that the handle data originated from is allowed to be
150+
from another process on the host system.
151+
If the `ipc_memory` object that the handle data originated from has been
152+
destroyed, the behaviors of this constructor and any resulting objects are
153+
undefined.
154+
If the device USM memory the original `ipc_memory` object was created with was
155+
not originally allocated on `dev`, the behaviors of this constructor and any
156+
resulting objects are undefined.
157+
158+
!====
159+
a!
160+
[source]
161+
----
162+
span<const char, sycl::dynamic_extent> get_handle_data() const
163+
----
164+
!====
165+
166+
_Returns:_ The handle data of the `ipc_memory` object.
167+
Accessing the handle data returned by this API after the `ipc_memory` object has
168+
been destroyed results in undefined behavior.
169+
170+
!====
171+
a!
172+
[source]
173+
----
174+
void *get_ptr() const
175+
----
176+
!====
177+
178+
_Returns:_ A pointer to device USM memory corresponding to the pointer used to
179+
construct the original `ipc_memory` object.
180+
Accessing the pointer returned by this API after the `ipc_memory` object has
181+
been destroyed results in undefined behavior.
182+
183+
|====
184+
185+
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
@@ -80,4 +80,5 @@ __SYCL_ASPECT(ext_oneapi_async_memory_alloc, 87)
8080
__SYCL_ASPECT(ext_intel_device_info_luid, 88)
8181
__SYCL_ASPECT(ext_intel_device_info_node_mask, 89)
8282
__SYCL_ASPECT(ext_oneapi_exportable_device_mem, 90)
83+
__SYCL_ASPECT(ext_oneapi_ipc_memory, 91)
8384

sycl/include/sycl/sycl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ can be disabled by setting SYCL_DISABLE_FSYCL_SYCLHPP_WARNING macro.")
127127
#include <sycl/ext/oneapi/experimental/group_helpers_sorters.hpp>
128128
#include <sycl/ext/oneapi/experimental/group_load_store.hpp>
129129
#include <sycl/ext/oneapi/experimental/group_sort.hpp>
130+
#include <sycl/ext/oneapi/experimental/ipc_memory.hpp>
130131
#include <sycl/ext/oneapi/experimental/prefetch.hpp>
131132
#include <sycl/ext/oneapi/experimental/profiling_tag.hpp>
132133
#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
@@ -1579,6 +1579,10 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
15791579
UR_DEVICE_INFO_MEMORY_EXPORT_EXPORTABLE_DEVICE_MEM_EXP>()
15801580
.value_or(0);
15811581
}
1582+
CASE(ext_oneapi_ipc_memory) {
1583+
return get_info_impl_nocheck<UR_DEVICE_INFO_IPC_MEMORY_SUPPORT_EXP>()
1584+
.value_or(0);
1585+
}
15821586
else {
15831587
return false; // This device aspect has not been implemented yet.
15841588
}

0 commit comments

Comments
 (0)