[UR] Implement IPC physical_mem API in UR#22115
Open
ldorau wants to merge 3 commits into
Open
Conversation
slawekptak
reviewed
May 26, 2026
70701a0 to
523e104
Compare
Contributor
Author
|
Rebased |
523e104 to
4cbcfa8
Compare
Contributor
Author
|
The Offload CI job fails because of #22125 |
a9eb70a to
6dac91d
Compare
Contributor
Author
|
Rebased |
29aee2c to
4a61124
Compare
6113038 to
572be16
Compare
kswiecicki
reviewed
May 28, 2026
| ur_physical_mem_handle_t hPhysMem, | ||
| void **ppIPCPhysMemHandleData, | ||
| size_t *pIPCPhysMemHandleDataSizeRet) { | ||
| #ifdef __linux__ |
Contributor
There was a problem hiding this comment.
Are L0 driver IPC calls specific to Linux?
Contributor
Author
There was a problem hiding this comment.
No, currently only implementation for Linux is needed. A Windows one will differ.
| void **ppIPCPhysMemHandleData, | ||
| size_t *pIPCPhysMemHandleDataSizeRet) { | ||
| #ifdef __linux__ | ||
| if (!hContext) |
Contributor
There was a problem hiding this comment.
Majority of those checks should probably be done on the validation layer side.
572be16 to
37d96d9
Compare
Add four new function specs to exp-inter-process-communication.yml and update registry.yml to support IPC operations on physical memory objects: - urIPCGetPhysMemHandleExp: export an IPC handle for a physical_mem - urIPCPutPhysMemHandleExp: release the exported IPC handle - urIPCOpenPhysMemHandleExp: import an IPC handle into a physical_mem - urIPCClosePhysMemHandleExp: close the imported physical_mem Also add ENABLE_IPC flag to ur_physical_mem_flags_t in virtual_memory.yml to allow allocating physical memory that can be shared via IPC handles. Add a new enumerator to ur_physical_mem_info_t that allows querying the virtual address established by zeMemOpenIpcHandle when a physical memory handle is opened via urIPCOpenPhysMemHandleExp. Returns nullptr for non-IPC handles. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Add auto-generated files based on the IPC physical_mem spec changes (urIPCGetPhysMemHandleExp, urIPCPutPhysMemHandleExp, urIPCOpenPhysMemHandleExp, urIPCClosePhysMemHandleExp, UR_PHYSICAL_MEM_FLAG_ENABLE_IPC, UR_DEVICE_INFO_IPC_PHYSICAL_MEMORY_SUPPORT_EXP): - ur_api.h, ur_api_funcs.def, ur_ddi.h: function declarations - ur_print.h/hpp, ur_print.cpp: printing support - ur_api.cpp: API dispatch stubs - ur_ldrddi.cpp, ur_libapi.cpp: loader implementations - ur_trcddi.cpp, ur_valddi.cpp: tracing and validation layers - ur_mockddi.cpp: mock adapter - loader.def.in, loader.map.in: loader symbol exports - level_zero ur_interface_loader.cpp/.hpp: Level-Zero DDI table entries - urinfo.hpp: updated urinfo tool Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
75afc3f to
3c08b2b
Compare
Contributor
Author
|
The Offload CI job fails because of #22125 |
dc8e61e to
95c1d4a
Compare
Contributor
Author
|
@nrspruit please review 2 files: |
Contributor
Author
|
The Offload CI job fails because of #22125 |
88e952f to
fe60cba
Compare
Implement urIPCGetPhysMemHandleExp, urIPCPutPhysMemHandleExp, urIPCOpenPhysMemHandleExp, and urIPCClosePhysMemHandleExp. Level Zero v2 adapter (Linux, BMG/Xe2+ only): - physical_mem.hpp and physical_mem.cpp moved to v2/ subdirectory - urIPCGetPhysMemHandleExp: calls zeMemGetIpcHandleWithProperties passing ze_physical_mem_handle_t cast to (const void *) directly, using ze_ipc_mem_handle_type_ext_desc_t with ZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT; detects fd-based handles via fcntl(F_GETFD) and returns UR_RESULT_ERROR_UNSUPPORTED_FEATURE - urIPCOpenPhysMemHandleExp: calls zeMemOpenIpcHandle with flags=0 - urIPCPutPhysMemHandleExp: calls zeMemPutIpcHandle - urIPCClosePhysMemHandleExp: delegates to urPhysicalMemRelease - virtual_mem.cpp: urVirtualMemMap returns UR_RESULT_ERROR_INVALID_ARGUMENT for IPC-opened handles; the virtual address is already established by zeMemOpenIpcHandle and is accessed via urPhysicalMemGetInfo(UR_PHYSICAL_MEM_INFO_IPC_VIRTUAL_ADDRESS) - device.cpp: report UR_DEVICE_INFO_IPC_PHYSICAL_MEMORY_SUPPORT_EXP as isIntelBMGOrNewer() on Linux, false on Windows - Add isIntelBMGOrNewer() helper (IP version threshold 0x05004000, first Xe2 stepping BMG_G21_A0); IPC entry points return UR_RESULT_ERROR_UNSUPPORTED_FEATURE on pre-Xe2 devices Level Zero v1 adapter: - physical_mem.cpp provides only the four non-IPC functions (urPhysicalMemCreate/Retain/Release/GetInfo) - Add stub definitions for the four IPC functions returning UR_RESULT_ERROR_UNSUPPORTED_FEATURE so the L0v1 adapter links correctly Other adapters (CUDA, HIP, OpenCL, Native CPU, Offload): - Return UR_RESULT_ERROR_UNSUPPORTED_FEATURE from all four functions - Report UR_DEVICE_INFO_IPC_PHYSICAL_MEMORY_SUPPORT_EXP as false Conformance tests: - Add urIPCGetPhysMemHandleExp.cpp, urIPCPutPhysMemHandleExp.cpp, urIPCOpenPhysMemHandleExp.cpp, urIPCClosePhysMemHandleExp.cpp - Add urIPCPhysMemHandleExpFixtures.hpp with urIPCPhysMemTest, urIPCPhysMemHandleTest, urIPCOpenedPhysMemTest fixtures Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement
urIPCGetPhysMemHandleExp,urIPCPutPhysMemHandleExp,urIPCOpenPhysMemHandleExp, andurIPCClosePhysMemHandleExp.Level Zero v2 adapter (Linux, BMG/Xe2+ only)
physical_mem.hpp/cppmoved tov2/;ur_physical_mem_handle_t_extendedwith
Device,Size,EnableIpc,IpcVirtualAddressfields.isIntelBMGOrNewer()helper (IP version >=0x05004000); IPC functionsreturn
UR_RESULT_ERROR_UNSUPPORTED_FEATUREon pre-Xe2 devices.urIPCGetPhysMemHandleExp: callszeMemGetIpcHandleWithPropertieswithZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT; detects fd-based handles viafcntl(F_GETFD)and rejects withUNSUPPORTED_FEATURE.urIPCOpenPhysMemHandleExp: callszeMemOpenIpcHandle(flags=0); storesvirtual address in
IpcVirtualAddress.urVirtualMemMap: returnsUR_RESULT_ERROR_INVALID_ARGUMENTforIPC-opened handles (address already set by
zeMemOpenIpcHandle).UR_DEVICE_INFO_IPC_PHYSICAL_MEMORY_SUPPORT_EXP:isIntelBMGOrNewer()onLinux,
falseon Windows.Level Zero v1 adapter
physical_mem.cppprovides onlyurPhysicalMemCreate/Retain/Release/GetInfo.UR_RESULT_ERROR_UNSUPPORTED_FEATUREso the L0v1 adapter links correctly.Other adapters (CUDA, HIP, OpenCL, Native CPU, Offload)
UR_RESULT_ERROR_UNSUPPORTED_FEATURE; report device info asfalse.Conformance tests