Skip to content

[SYCL] add support for bindless image resource_win32_name (named handles)#21899

Open
cperkinsintel wants to merge 9 commits intointel:syclfrom
cperkinsintel:cperkins-win32-named-handle-dev
Open

[SYCL] add support for bindless image resource_win32_name (named handles)#21899
cperkinsintel wants to merge 9 commits intointel:syclfrom
cperkinsintel:cperkins-win32-named-handle-dev

Conversation

@cperkinsintel
Copy link
Copy Markdown
Contributor

Neither the UR nor L0 have affordances for win32 named handles. SYCL substitutes a regular win32_handle instead.

@cperkinsintel cperkinsintel marked this pull request as ready for review April 29, 2026 15:44
@cperkinsintel cperkinsintel requested review from a team as code owners April 29, 2026 15:44
#if defined(_WIN32) || defined(_WIN64)
#include <mutex>
#include <unordered_map>
#define WIN32_LEAN_AND_MEAN
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't really get why we define this macro here? Maybe add a comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a standard windows thing. You do it right before including windows.h if you want "the minimum".

Copy link
Copy Markdown
Contributor

@uditagarwal97 uditagarwal97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Windows-only support for importing bindless image interop resources via resource_win32_name (Win32 named handles) by opening the named handle through a D3D12 device and delegating to the existing resource_win32_handle import path.

Changes:

  • Add resource_win32_name import support for external memory and external semaphores on Windows (open-by-name + handle lifetime tracking).
  • Extend the interop descriptor type to carry the originating D3D device pointer needed to open the named handle.
  • Add a DX12 end-to-end test and update the Windows ABI symbol dump.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
sycl/source/detail/bindless_images.cpp Implements resource_win32_name imports on Windows and adds handle tracking/cleanup logic.
sycl/include/sycl/ext/oneapi/bindless_images_interop.hpp Extends resource_win32_name to include a device pointer for opening named handles.
sycl/test-e2e/bindless_images/dx12_interop/D3D12_sycl_buffer_win32_name_native.cpp Adds an e2e DX12↔SYCL interop test that imports buffers/fence by name.
sycl/test/abi/sycl_symbols_windows.dump Updates ABI symbol expectations for the new template instantiations.

Comment on lines +1115 to +1129
// Delegate to existing resource_win32_handle implementation
external_semaphore_descriptor<resource_win32_handle> handleDesc{
{openedHandle}, externalSemaphoreDesc.handle_type};

external_semaphore result =
import_external_semaphore(handleDesc, syclDevice, syclContext);

// Track the opened handle so we can close it on release
{
std::lock_guard<std::mutex> lock(g_win32NameHandlesMutex);
g_win32NameHandles[reinterpret_cast<ur_exp_external_mem_handle_t>(
result.raw_handle)] = openedHandle;
}

return result;
// Windows external name type
struct resource_win32_name {
const void *name;
void *device; // ID3D12Device* or ID3D11Device* for opening named handle
Comment on lines +90 to +92
std::cout << "[D3D12] Created named buffer: " << name << std::endl;

return result;
Comment on lines +114 to +116
std::cout << "[D3D12] Created named fence: " << name << std::endl;

return result;
Comment thread sycl/source/detail/bindless_images.cpp Outdated
Comment on lines +728 to +735
#if defined(_WIN32) || defined(_WIN64)
// Close handle if it was opened via resource_win32_name
{
std::lock_guard<std::mutex> lock(g_win32NameHandlesMutex);
auto it =
g_win32NameHandles.find(reinterpret_cast<ur_exp_external_mem_handle_t>(
externalSemaphore.raw_handle));
if (it != g_win32NameHandles.end()) {
Comment on lines +1069 to +1083
// Use existing resource_win32_handle implementation
external_mem_descriptor<resource_win32_handle> handleDesc{
{openedHandle},
externalMemDesc.handle_type,
externalMemDesc.size_in_bytes};

// Delegate to existing resource_win32_handle implementation
external_mem result = import_external_memory<resource_win32_handle>(
handleDesc, syclDevice, syclContext);

// Track the opened handle so we can close it on release
{
std::lock_guard<std::mutex> lock(g_win32NameHandlesMutex);
g_win32NameHandles[result.raw_handle] = openedHandle;
}
@cperkinsintel cperkinsintel changed the title [SYCL][WIP] add support for bindless image resource_win32_name (named handles) [SYCL] add support for bindless image resource_win32_name (named handles) May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants