[DEBUG] Devel#22092
Draft
ldorau wants to merge 16 commits into
Draft
Conversation
Add physical memory IPC doc Specify the namespace of handle struct (and aliases). Fix typo. Add a physical_mem properties constructor arg, clarify the device requirement for the open function, add enable_ipc property. Minor review comments. Add const. Minor fixes. Make ipc_memory namespace deprecated and add a new section which puts IPC for memory in ipc::memory namespace. Add a note that the get function throws an exception if phys_mem was not created with the enable_ipc property. Add a note about deprecating the ipc_memory namespace. Address review comments + namespace nesting change with [[deprecated]] Add missing put functions, change the physical memory lifetime description. Describe the ctx argument for put function. Change ext_oneapi_ipc_enabled() to ipc_enabled() in physical_mem.
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 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_api.h, ur_api_funcs.def, ur_ddi.h: function declarations - ur_print.h/hpp, ur_print.cpp: printing support - ur_ldrddi.cpp, ur_libapi.cpp, ur_api.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 - opencl common.hpp: updated generated include Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Add ipc::memory and ipc::physical_memory namespaces as the
non-deprecated replacements for the old ipc_memory namespace, plus
new IPC support for physical_mem objects (sycl_ext_oneapi_virtual_mem).
SYCL layer changes:
- ipc_memory.hpp: add ipc::handle generic handle type with proper
forward-declaration pattern; add ipc::memory and ipc::physical_memory
namespaces with get/put/open/close free functions; deprecate the old
ipc_memory namespace
- ipc_memory.cpp: implement ipc::memory::{get,put,close},
ipc::physical_memory::{get,put,open}, and detail::openIPCPhysMemHandle
- physical_mem.hpp: add enable_ipc property struct and is_property_key_of
specialization; add templated constructors that extract the property;
add ext_oneapi_ipc_enabled() query method
- physical_mem_impl.hpp: add bool EnableIpc parameter and MEnabledIpc
member; add second constructor for opening from an existing UR handle
(used by ipc::physical_memory::open)
- physical_mem.cpp: propagate EnableIpc through to impl; add
ext_oneapi_ipc_enabled(); check ext_oneapi_ipc_physical_memory aspect
- aspects.def: add ext_oneapi_ipc_physical_memory (aspect 96)
- property.hpp: add PropKind::EnableIpc = 50, bump PropKindSize to 51
UR adapter changes:
- All adapter memory.cpp files: add empty stub implementations returning
UR_RESULT_ERROR_UNSUPPORTED_FEATURE for the 4 new IPC functions
- Non-level_zero adapter ur_interface_loader.cpp files: wire stubs into
the IPC DDI table (after pfnCloseMemHandleExp)
Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Add UR_PHYSICAL_MEM_FLAG_ENABLE_IPC = UR_BIT(1) to ur_physical_mem_flags_t in virtual_memory.yml. This flag allows callers to request IPC-exportable physical memory allocations at creation time via urPhysicalMemCreate. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Regenerate ur_api.h and ur_print.hpp to include the new UR_PHYSICAL_MEM_FLAG_ENABLE_IPC flag and update UR_PHYSICAL_MEM_FLAGS_MASK from 0xfffffffe to 0xfffffffc. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Implement the four experimental IPC functions for physical memory objects in the Level Zero (v1 and v2) adapters: - urIPCGetPhysMemHandleExp - urIPCPutPhysMemHandleExp - urIPCOpenPhysMemHandleExp - urIPCClosePhysMemHandleExp Level Zero adapter changes (shared by v1 and v2): - physical_mem.hpp: add Size member to ur_physical_mem_handle_t_ (needed on the import side); add ZeIPCPhysMemHandleData struct that holds a ze_ipc_mem_handle_t and the allocation size (72 bytes total) - physical_mem.cpp: chain ze_external_memory_export_desc_t into ze_physical_mem_desc_t.pNext when UR_PHYSICAL_MEM_FLAG_ENABLE_IPC is set, so the allocation is IPC-exportable; fix ZePhysicalMem leak in exception handlers of urPhysicalMemCreate - memory.cpp and v2/memory.cpp: replace UNSUPPORTED_FEATURE stubs with full implementations using zePhysicalMemGetProperties, zeMemGetIpcHandleFromFileDescriptorExp, zeMemGetFileDescriptorFromIpcHandleExp, zeMemPutIpcHandle, zePhysicalMemCreate, zePhysicalMemDestroy SYCL layer changes: - physical_mem_impl.hpp: pass UR_PHYSICAL_MEM_FLAG_ENABLE_IPC in ur_physical_mem_properties_t when EnableIpc is true, so the adapter creates an exportable allocation Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Fix urPhysicalMemCreate conformance test:
Replace UR_PHYSICAL_MEM_FLAG_TBD (removed from ur_physical_mem_flags_t)
with UR_PHYSICAL_MEM_FLAG_ENABLE_IPC in urPhysicalMemCreateWithFlagsParamTest.
Add conformance tests for the four experimental IPC physical memory functions:
- urIPCGetPhysMemHandleExp
- urIPCPutPhysMemHandleExp
- urIPCOpenPhysMemHandleExp
- urIPCClosePhysMemHandleExp
Tests are placed in test/conformance/virtual_memory/ alongside the existing
physical memory tests. A shared fixture header urIPCPhysMemHandleExpFixtures.hpp
defines three fixture classes:
- urIPCPhysMemTest: creates a physical_mem with UR_PHYSICAL_MEM_FLAG_ENABLE_IPC;
skips if the device does not support IPC memory
(UR_DEVICE_INFO_IPC_MEMORY_SUPPORT_EXP) or if urPhysicalMemCreate returns
UR_RESULT_ERROR_UNSUPPORTED_FEATURE
- urIPCPhysMemHandleTest: additionally acquires an IPC handle via
urIPCGetPhysMemHandleExp; skips on UR_RESULT_ERROR_UNSUPPORTED_FEATURE
- urIPCOpenedPhysMemTest: additionally opens the IPC handle via
urIPCOpenPhysMemHandleExp
Also add a standalone Level Zero e2e diagnostic test ze_ipc_phys_mem_e2e.cpp
that exercises the full IPC flow directly through the L0 API (not part of the
CMake build; build instructions are in the file header comment).
Fix L0 adapter IPC phys_mem handle implementation:
Replace the zeMemGetIpcHandleFromFileDescriptorExp /
zeMemGetFileDescriptorFromIpcHandleExp round-trip (which returns
ZE_RESULT_ERROR_INVALID_ARGUMENT on current NEO drivers) with a direct
file-descriptor approach:
- ZeIPCPhysMemHandleData now stores int Fd + size_t Size instead of
ze_ipc_mem_handle_t + size_t Size
- urIPCGetPhysMemHandleExp: export fd via zePhysicalMemGetProperties and
store it directly; the fd lifetime is owned by the handle data
- urIPCPutPhysMemHandleExp: close(fd) and delete handle data
- urIPCOpenPhysMemHandleExp: use the fd directly in
ze_external_memory_import_fd_t without converting via
zeMemGetFileDescriptorFromIpcHandleExp
- urIPCClosePhysMemHandleExp: zePhysicalMemDestroy + delete handle
- Add explicit null-argument checks (INVALID_NULL_HANDLE /
INVALID_NULL_POINTER) at the top of all four functions so that the
conformance negative tests pass without reaching L0
Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Use pidfd_getfd(2) to transfer DMA-BUF file descriptors between processes, enabling true cross-process sharing of physical_mem objects via the IPC API. Changes: - ZeIPCPhysMemHandleData: add Pid field (exporting process PID) - urIPCGetPhysMemHandleExp: store getpid() in handle data; keep fd open until urIPCPutPhysMemHandleExp closes it - urIPCOpenPhysMemHandleExp: same-process → dup(), cross-process → pidfd_open(Pid) + pidfd_getfd() to obtain a local copy of the DMA-BUF fd; close the local copy after zePhysicalMemCreate (fixes the fd leak bug identified in code review) - Add UR_DEVICE_INFO_IPC_PHYSICAL_MEMORY_SUPPORT_EXP = 0x2024 to virtual_memory.yml spec and regenerate ur_api.h / ur_print.hpp - Implement new device info in L0 adapter (returns true on Linux) - Add false stub in CUDA, HIP, OpenCL, native_cpu adapters Print step-by-step status for both spawner and consumer so users can follow what is happening and clearly see PASSED/FAILED outcome. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
urIPCClosePhysMemHandleExp was unconditionally calling zePhysicalMemDestroy and deleting the handle object, bypassing the reference count mechanism. If a caller had previously called urPhysicalMemRetain (refcount > 1), the subsequent delete would leave dangling references and a use-after-free on the next urPhysicalMemRelease call. Fix: delegate to ur::level_zero::urPhysicalMemRelease which properly decrements the refcount and only destroys when it reaches zero. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
The urIPCPhysMemTest fixture was querying UR_DEVICE_INFO_IPC_MEMORY_SUPPORT_EXP (USM allocation IPC) instead of UR_DEVICE_INFO_IPC_PHYSICAL_MEMORY_SUPPORT_EXP to guard the IPC physical_mem tests. These are distinct capabilities and could diverge on future adapters, causing tests to run on unsupported devices or to be incorrectly skipped. Also update the skip message to be specific about physical memory. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Two related fixes: 1. urPhysicalMemGetInfo (L0 adapter) only returned REFERENCE_COUNT; all other queries (CONTEXT, DEVICE, SIZE, PROPERTIES) returned UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION despite the data being available in the handle struct. Fix: add Device and EnableIpc fields to ur_physical_mem_handle_t_, populate them in urPhysicalMemCreate and urIPCOpenPhysMemHandleExp, and implement all five info cases in urPhysicalMemGetInfo. 2. physical_mem objects created via urIPCOpenPhysMemHandleExp were constructed with NumBytes=0, making physical_mem::size() return 0 instead of the actual allocation size. Fix: after opening, query UR_PHYSICAL_MEM_INFO_SIZE and pass the result to the physical_mem_impl constructor. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
After urIPCOpenPhysMemHandleExp succeeds, a failure in the subsequent urPhysicalMemGetInfo call (or std::bad_alloc in make_shared) would throw without releasing PhysMemHandle, leaking the GPU resource. Wrap the post-open work in a try-catch that calls urIPCClosePhysMemHandleExp on any exception before re-throwing, ensuring the handle is always released. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
- Move UR_DEVICE_INFO_IPC_PHYSICAL_MEMORY_SUPPORT_EXP enum extension from virtual_memory.yml to exp-inter-process-communication.yml where all other IPC-related spec content lives - Regenerate tools/urinfo/urinfo.hpp to include the new device info entry (fixes 'check-generated' CI failure on Windows) - Replace mixed-type ternary with if/else in physical_mem_impl.hpp to fix -Werror=extra: 'enumerated and non-enumerated type in conditional expression' (fixes SYCL build CI failure)
Restore clang-format 20 correct indentation for CL_API_ENTRY function pointer type declarations that was accidentally reverted during rebase. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Guard ZeIPCPhysMemHandleData struct and Linux-specific IPC function bodies in L0 v1 and v2 adapters with #ifdef __linux__ to fix Windows build errors (pid_t and sys/syscall.h are Linux-only). - Add ext_oneapi_ipc_physical_memory aspect to DeviceConfigFile.td to fix device_config_file_aspects LIT test failure. - Update sycl_symbols_linux.dump ABI reference: replace old 3-param physical_mem constructor with new 4-param one (adds bool EnableIpc), and add all new IPC physical_memory API symbols. 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.
No description provided.