diff --git a/conformance_tests/core/test_ipc/src/test_ipc_memory.cpp b/conformance_tests/core/test_ipc/src/test_ipc_memory.cpp index 9218b38b..a47bed08 100644 --- a/conformance_tests/core/test_ipc/src/test_ipc_memory.cpp +++ b/conformance_tests/core/test_ipc/src/test_ipc_memory.cpp @@ -261,6 +261,98 @@ static void run_ipc_host_mem_access_test_opaque(size_t size, lzt::destroy_context(context); } +static void run_ipc_mem_access_test_opaque_with_properties( + ipc_mem_access_test_t test_type, size_t size, bool reserved, + ze_ipc_memory_flags_t flags, bool is_immediate, + ze_ipc_mem_handle_type_flags_t handle_type_flags) { + ze_result_t result = zeInit(0); + if (result != ZE_RESULT_SUCCESS) { + throw std::runtime_error("Parent zeInit failed: " + + level_zero_tests::to_string(result)); + } + LOG_DEBUG << "[Parent] Driver initialized\n"; + lzt::print_platform_overview(); + + bipc::shared_memory_object::remove("ipc_memory_test"); + + ze_ipc_mem_handle_t ipc_handle = {}; + + auto driver = lzt::get_default_driver(); + auto context = lzt::create_context(driver); + auto device = lzt::zeDevice::get_instance()->get_device(); + auto cmd_bundle = lzt::create_command_bundle(context, device, is_immediate); + + void *buffer = lzt::allocate_host_memory(size, 1, context); + memset(buffer, 0, size); + lzt::write_data_pattern(buffer, size, 1); + size_t allocSize = size; + ze_physical_mem_handle_t reservedPhysicalMemory = {}; + void *memory = nullptr; + if (reserved) { + memory = lzt::reserve_allocate_and_map_device_memory( + context, device, allocSize, &reservedPhysicalMemory); + } else { + memory = lzt::allocate_device_memory(size, 1, 0, context); + } + lzt::append_memory_copy(cmd_bundle.list, memory, buffer, size); + lzt::close_command_list(cmd_bundle.list); + lzt::execute_and_sync_command_bundle(cmd_bundle, UINT64_MAX); + + // Use zeMemGetIpcHandleWithProperties with extension properties + ze_ipc_mem_handle_type_ext_desc_t handle_type_desc = {}; + handle_type_desc.stype = ZE_STRUCTURE_TYPE_IPC_MEM_HANDLE_TYPE_EXT_DESC; + handle_type_desc.pNext = nullptr; + handle_type_desc.typeFlags = handle_type_flags; + + ASSERT_ZE_RESULT_SUCCESS(zeMemGetIpcHandleWithProperties( + context, memory, &handle_type_desc, &ipc_handle)); + + ze_ipc_mem_handle_t ipc_handle_zero{}; + ASSERT_NE(0, memcmp((void *)&ipc_handle, (void *)&ipc_handle_zero, + sizeof(ipc_handle))); + + // launch child +#ifdef _WIN32 + std::string helper_path = ".\\ipc\\test_ipc_memory_helper.exe"; +#else + std::string helper_path = "./ipc/test_ipc_memory_helper"; +#endif + boost::process::child c; + try { + c = boost::process::child(helper_path); + } catch (const boost::process::process_error &e) { + std::cerr << "Failed to launch child process: " << e.what() << std::endl; + throw; + } + + bipc::shared_memory_object shm(bipc::create_only, "ipc_memory_test", + bipc::read_write); + shm.truncate(sizeof(shared_data_t)); + bipc::mapped_region region(shm, bipc::read_write); + + // copy ipc handle data to shm + shared_data_t test_data = {test_type, TEST_NONSOCK, to_u32(size), + flags, is_immediate, ipc_handle}; + std::memcpy(region.get_address(), &test_data, sizeof(shared_data_t)); + + // Free device memory once receiver is done + c.wait(); + EXPECT_EQ(c.exit_code(), 0); + + ASSERT_ZE_RESULT_SUCCESS(zeMemPutIpcHandle(context, ipc_handle)); + bipc::shared_memory_object::remove("ipc_memory_test"); + + if (reserved) { + lzt::unmap_and_free_reserved_memory(context, memory, reservedPhysicalMemory, + allocSize); + } else { + lzt::free_memory(context, memory); + } + lzt::free_memory(context, buffer); + lzt::destroy_command_bundle(cmd_bundle); + lzt::destroy_context(context); +} + #ifdef __linux__ LZT_TEST( IpcMemoryAccessTest, @@ -415,6 +507,166 @@ LZT_TEST( run_ipc_host_mem_access_test_opaque(4096, ZE_IPC_MEMORY_FLAG_BIAS_CACHED); } +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0MemoryAllocatedInChildProcessWhenUsingL0IPCWithDefaultHandleTypeThenParentProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, false, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, false, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0MemoryAllocatedInChildProcessWhenUsingL0IPCWithDefaultHandleTypeOnImmediateCmdListThenParentProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, false, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0MemoryAllocatedInChildProcessBiasCachedWhenUsingL0IPCWithDefaultHandleTypeThenParentProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, false, ZE_IPC_MEMORY_FLAG_BIAS_CACHED, false, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0MemoryAllocatedInChildProcessBiasCachedWhenUsingL0IPCWithDefaultHandleTypeOnImmediateCmdListThenParentProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, false, ZE_IPC_MEMORY_FLAG_BIAS_CACHED, true, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessWhenUsingL0IPCWithDefaultHandleTypeThenChildProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, false, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessWhenUsingL0IPCWithDefaultHandleTypeOnImmediateCmdListThenChildProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessBiasCachedWhenUsingL0IPCWithDefaultHandleTypeThenChildProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_CACHED, false, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessBiasCachedWhenUsingL0IPCWithDefaultHandleTypeOnImmediateCmdListThenChildProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_CACHED, true, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0MemoryAllocatedInChildProcessWhenUsingL0IPCWithFabricAccessibleHandleTypeThenParentProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, false, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, false, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_FABRIC_ACCESSIBLE); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0MemoryAllocatedInChildProcessWhenUsingL0IPCWithFabricAccessibleHandleTypeOnImmediateCmdListThenParentProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, false, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_FABRIC_ACCESSIBLE); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0MemoryAllocatedInChildProcessBiasCachedWhenUsingL0IPCWithFabricAccessibleHandleTypeThenParentProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, false, ZE_IPC_MEMORY_FLAG_BIAS_CACHED, false, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_FABRIC_ACCESSIBLE); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0MemoryAllocatedInChildProcessBiasCachedWhenUsingL0IPCWithFabricAccessibleHandleTypeOnImmediateCmdListThenParentProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, false, ZE_IPC_MEMORY_FLAG_BIAS_CACHED, true, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_FABRIC_ACCESSIBLE); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessWhenUsingL0IPCWithFabricAccessibleHandleTypeThenChildProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, false, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_FABRIC_ACCESSIBLE); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessWhenUsingL0IPCWithFabricAccessibleHandleTypeOnImmediateCmdListThenChildProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_FABRIC_ACCESSIBLE); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessBiasCachedWhenUsingL0IPCWithFabricAccessibleHandleTypeThenChildProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_CACHED, false, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_FABRIC_ACCESSIBLE); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithProperties, + GivenL0PhysicalMemoryAllocatedAndReservedInParentProcessBiasCachedWhenUsingL0IPCWithFabricAccessibleHandleTypeOnImmediateCmdListThenChildProcessReadsMemoryCorrectly) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_DEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_CACHED, true, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_FABRIC_ACCESSIBLE); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithPropertiesSubDevice, + GivenL0PhysicalMemoryAllocatedReservedInParentProcessWhenUsingL0IPCWithDefaultHandleTypeThenChildProcessReadsMemoryCorrectlyUsingSubDeviceQueue) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_SUBDEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, + false, ZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithPropertiesSubDevice, + GivenL0PhysicalMemoryAllocatedReservedInParentProcessWhenUsingL0IPCWithDefaultHandleTypeOnImmediateCmdListThenChildProcessReadsMemoryCorrectlyUsingSubDeviceQueue) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_SUBDEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_DEFAULT); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithPropertiesSubDevice, + GivenL0PhysicalMemoryAllocatedReservedInParentProcessWhenUsingL0IPCWithFabricAccessibleHandleTypeThenChildProcessReadsMemoryCorrectlyUsingSubDeviceQueue) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_SUBDEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, + false, ZE_IPC_MEM_HANDLE_TYPE_FLAG_FABRIC_ACCESSIBLE); +} + +LZT_TEST( + IpcMemoryAccessTestOpaqueIpcHandleWithPropertiesSubDevice, + GivenL0PhysicalMemoryAllocatedReservedInParentProcessWhenUsingL0IPCWithFabricAccessibleHandleTypeOnImmediateCmdListThenChildProcessReadsMemoryCorrectlyUsingSubDeviceQueue) { + run_ipc_mem_access_test_opaque_with_properties( + TEST_SUBDEVICE_ACCESS, 4096, true, ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED, true, + ZE_IPC_MEM_HANDLE_TYPE_FLAG_FABRIC_ACCESSIBLE); +} + } // namespace // We put the main here because L0 doesn't currently specify how diff --git a/scripts/level_zero_report_utils.py b/scripts/level_zero_report_utils.py index 3ad78b0c..4fd52f97 100644 --- a/scripts/level_zero_report_utils.py +++ b/scripts/level_zero_report_utils.py @@ -395,6 +395,7 @@ def assign_test_feature_tag(test_feature: str, test_name: str, test_section: str (re.search('zeCheckMiscFunctionsTestsInstantiate_zeCheckMiscFunctionsTests_GivenFunctionInKernelWhenLaunchingKernelsThenFunctionWorksCorrectly', test_name, re.IGNORECASE)) or \ (re.search('zeCommandListAppendMemoryBackToBackTests_GivenAllUsmAndSvmPermutationsConfirmSuccessfulExecutionBackToBackWithSharedSystemAllocator', test_name, re.IGNORECASE)) or \ re.search('fabric', test_name, re.IGNORECASE) or \ + re.search('IpcMemoryAccessTestOpaqueIpcHandleWithProperties', test_name, re.IGNORECASE) or \ re.search('zeInitDrivers', test_name, re.IGNORECASE): test_feature_tag = "advanced" else: