Skip to content

Commit 1a0c6ff

Browse files
committed
Address feedback
1 parent 10dea37 commit 1a0c6ff

File tree

4 files changed

+22
-46
lines changed

4 files changed

+22
-46
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_memory_export.asciidoc

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,6 @@ enum class external_mem_handle_type {
128128
win32_nt_dx11_resource = 4,
129129
};
130130

131-
template <external_mem_handle_type ExternalMemHandleType>
132-
struct exported_mem;
133-
134-
template <>
135-
struct exported_mem<external_mem_handle_type::opaque_fd> {
136-
using type = int;
137-
};
138-
139-
template <>
140-
struct exported_mem<external_mem_handle_type::win32_nt_handle> {
141-
using type = void *;
142-
};
143-
144-
template <external_mem_handle_type ExternalMemHandleType>
145-
using exported_mem_t = typename exported_mem<ExternalMemHandleType>::type;
146-
147131
}
148132
```
149133

@@ -159,14 +143,6 @@ represented by an `int`.
159143
The `win32_nt_handle` handle type corresponds to a Windows NT handle, which is
160144
represented by a `void *`.
161145

162-
The `exported_mem` template struct is specialized for each of the
163-
`external_mem_handle_type` values. Each specialization defines a `type` alias
164-
that represents the type of the exported memory handle for that specific handle.
165-
166-
The `exported_mem_t` type alias allows the user to easily obtain the type of
167-
the exported memory handle based on the `external_mem_handle_type` template
168-
parameter.
169-
170146
=== API of the extension
171147

172148
```c++
@@ -210,13 +186,6 @@ instance of `sycl::property_list`. Currently, this extension does not define
210186
any properties that can be used with this function, so the `propList` parameter
211187
is ignored and reserved for future use.
212188

213-
The passed `externalMemHandleType` must be supported by the operating system
214-
running the SYCL application. Passing an `externalMemHandleType` that is not
215-
supported by the operating system running the SYCL application results in
216-
undefined behavior. The `win32_nt_handle` handle type is only supported on
217-
Windows operating systems, while the `opaque_fd` handle type is only supported
218-
on POSIX compliant operating systems.
219-
220189
Only two values of `externalMemHandleType` are supported by this extension:
221190

222191
- `external_mem_handle_type::opaque_fd` is supported when the host is a Posix
@@ -264,9 +233,6 @@ When `ExternalMemHandleType` is `external_mem_handle_type::win32_nt_handle`, the
264233
The `export_device_mem_handle` function accepts a `void *` representing a device
265234
allocation made using `alloc_exportable_device_mem`.
266235

267-
The return type is determined by the template parameter,
268-
`ExternalMemHandleType`.
269-
270236
The value of `ExternalMemHandleType` must match the value passed to
271237
`alloc_exportable_device_mem` when the memory was allocated. Passing an
272238
`ExternalMemHandleType` value that not match the value passed to
@@ -384,5 +350,5 @@ and plan to address it in future versions of this extension.
384350
[frame="none",options="header"]
385351
|===============================================================================
386352
|Rev |Date | Author | Changes
387-
|1.0 |2025-07-08 | Przemek Malon | Initial draft
353+
|1.0 |2025-07-18 | Przemek Malon | Initial draft
388354
|===============================================================================

sycl/include/sycl/ext/oneapi/memory_export.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ namespace sycl {
2020
inline namespace _V1 {
2121
namespace ext::oneapi::experimental {
2222

23+
namespace detail {
24+
2325
template <external_mem_handle_type ExternalMemHandleType> struct exported_mem;
2426

2527
template <> struct exported_mem<external_mem_handle_type::opaque_fd> {
@@ -33,8 +35,6 @@ template <> struct exported_mem<external_mem_handle_type::win32_nt_handle> {
3335
template <external_mem_handle_type ExternalMemHandleType>
3436
using exported_mem_t = typename exported_mem<ExternalMemHandleType>::type;
3537

36-
namespace detail {
37-
3838
__SYCL_EXPORT int export_device_mem_opaque_fd(void *deviceMemory,
3939
const sycl::device &syclDevice,
4040
const sycl::context &syclContext);
@@ -76,7 +76,7 @@ template <external_mem_handle_type ExternalMemHandleType,
7676
std::enable_if_t<ExternalMemHandleType ==
7777
external_mem_handle_type::opaque_fd,
7878
bool> = true>
79-
inline exported_mem_t<ExternalMemHandleType>
79+
inline detail::exported_mem_t<ExternalMemHandleType>
8080
export_device_mem_handle(void *deviceMemory, const sycl::device &syclDevice,
8181
const sycl::context &syclContext) {
8282
return detail::export_device_mem_opaque_fd(deviceMemory, syclDevice,
@@ -89,7 +89,7 @@ template <external_mem_handle_type ExternalMemHandleType,
8989
std::enable_if_t<ExternalMemHandleType ==
9090
external_mem_handle_type::opaque_fd,
9191
bool> = true>
92-
inline exported_mem_t<ExternalMemHandleType>
92+
inline detail::exported_mem_t<ExternalMemHandleType>
9393
export_device_mem_handle(void *deviceMemory, const sycl::queue &syclQueue) {
9494
return export_device_mem_handle<ExternalMemHandleType>(
9595
deviceMemory, syclQueue.get_device(), syclQueue.get_context());
@@ -101,7 +101,7 @@ template <external_mem_handle_type ExternalMemHandleType,
101101
std::enable_if_t<ExternalMemHandleType ==
102102
external_mem_handle_type::win32_nt_handle,
103103
bool> = true>
104-
inline exported_mem_t<ExternalMemHandleType>
104+
inline detail::exported_mem_t<ExternalMemHandleType>
105105
export_device_mem_handle(void *deviceMemory, const sycl::device &syclDevice,
106106
const sycl::context &syclContext) {
107107
return detail::export_device_mem_win32_nt(deviceMemory, syclDevice,
@@ -114,7 +114,7 @@ template <external_mem_handle_type ExternalMemHandleType,
114114
std::enable_if_t<ExternalMemHandleType ==
115115
external_mem_handle_type::win32_nt_handle,
116116
bool> = true>
117-
inline exported_mem_t<ExternalMemHandleType>
117+
inline detail::exported_mem_t<ExternalMemHandleType>
118118
export_device_mem_handle(void *deviceMemory, const sycl::queue &syclQueue) {
119119
return export_device_mem_handle<ExternalMemHandleType>(
120120
deviceMemory, syclQueue.get_device(), syclQueue.get_context());

sycl/test-e2e/MemoryExport/export_memory_api_test.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
namespace syclexp = sycl::ext::oneapi::experimental;
1111

12+
#ifdef _WIN32
13+
using exported_handle_type = void *;
14+
#else
15+
using exported_handle_type = int;
16+
#endif // _WIN32
17+
1218
int main() {
1319
sycl::device device;
1420
sycl::context context = sycl::context(device);
@@ -40,7 +46,7 @@ int main() {
4046
0 /* alignment */, size, exportHandleType, device, context);
4147

4248
// Export the memory handle.
43-
syclexp::exported_mem_t<exportHandleType> exportableMemoryHandle =
49+
exported_handle_type exportableMemoryHandle =
4450
syclexp::export_device_mem_handle<exportHandleType>(mem, device,
4551
context);
4652
std::cout << "Exported memory handle == " << exportableMemoryHandle << "\n";

sycl/test-e2e/MemoryExport/export_memory_to_vulkan.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ namespace syclexp = sycl::ext::oneapi::experimental;
1515

1616
using DataT = uint32_t;
1717

18+
#ifdef _WIN32
19+
using exported_handle_type = void *;
20+
#else
21+
using exported_handle_type = int;
22+
#endif // _WIN32
1823
namespace {
1924
void *syclExportableLinearMemory;
2025

@@ -28,7 +33,7 @@ constexpr auto exportHandleType =
2833
constexpr auto exportHandleType = syclexp::external_mem_handle_type::opaque_fd;
2934
#endif // _WIN32
3035

31-
syclexp::exported_mem_t<exportHandleType> exportableMemoryHandle;
36+
exported_handle_type exportableMemoryHandle;
3237

3338
} // namespace
3439

@@ -81,9 +86,8 @@ int runTest(sycl::device &syclDevice, const size_t memorySizeBytes) {
8186
auto inputBufferMemTypeIndex = vkutil::getBufferMemoryTypeIndex(
8287
vkImportedBuffer, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
8388

84-
vkImportedBufferMemory =
85-
vkutil::importDeviceMemory<syclexp::exported_mem_t<exportHandleType>>(
86-
memorySizeBytes, inputBufferMemTypeIndex, exportableMemoryHandle);
89+
vkImportedBufferMemory = vkutil::importDeviceMemory<exported_handle_type>(
90+
memorySizeBytes, inputBufferMemTypeIndex, exportableMemoryHandle);
8791

8892
VK_CHECK_CALL(vkBindBufferMemory(vk_device, vkImportedBuffer,
8993
vkImportedBufferMemory,

0 commit comments

Comments
 (0)