From bb5bcc9ce0dfe3bfc252efb0a2f01fd769abdc0b Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Thu, 30 Oct 2025 14:29:37 +0000 Subject: [PATCH] feature: connecting append api calls to implementations Related-To: NEO-15440 Signed-off-by: Zbigniew Zdanowicz --- .../public/zex_cmdlist.cpp | 86 +++++++++++++++++++ .../driver/extension_function_address.cpp | 2 + .../unit_tests/sources/driver/test_driver.cpp | 12 +++ .../driver_experimental/zex_cmdlist.h | 23 +++++ 4 files changed, 123 insertions(+) diff --git a/level_zero/api/driver_experimental/public/zex_cmdlist.cpp b/level_zero/api/driver_experimental/public/zex_cmdlist.cpp index cd17bbaa1b..d047fc45c6 100644 --- a/level_zero/api/driver_experimental/public/zex_cmdlist.cpp +++ b/level_zero/api/driver_experimental/public/zex_cmdlist.cpp @@ -90,6 +90,65 @@ zexCommandListAppendHostFunction( return L0::CommandList::fromHandle(hCommandList)->appendHostFunction(pHostFunction, pUserData, pNext, hSignalEvent, numWaitEvents, phWaitEvents, parameters); } +ze_result_t ZE_APICALL +zexCommandListAppendMemoryCopyWithParameters( + ze_command_list_handle_t hCommandList, + void *dstptr, + const void *srcptr, + size_t size, + const void *pNext, + uint32_t numWaitEvents, + ze_event_handle_t *phWaitEvents, + ze_event_handle_t hSignalEvent) { + + if (nullptr == hCommandList) { + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (nullptr == dstptr) { + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (nullptr == srcptr) { + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + } + if ((nullptr == phWaitEvents) && (0 < numWaitEvents)) { + return ZE_RESULT_ERROR_INVALID_SIZE; + } + + auto cmdList = L0::CommandList::fromHandle(hCommandList); + + return cmdList->appendMemoryCopyWithParameters(dstptr, srcptr, size, pNext, hSignalEvent, numWaitEvents, phWaitEvents); +} + +ze_result_t ZE_APICALL +zexCommandListAppendMemoryFillWithParameters( + ze_command_list_handle_t hCommandList, + void *ptr, + const void *pattern, + size_t patternSize, + size_t size, + const void *pNext, + ze_event_handle_t hEvent, + uint32_t numWaitEvents, + ze_event_handle_t *phWaitEvents) { + + if (nullptr == hCommandList) { + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (nullptr == ptr) { + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (nullptr == pattern) { + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + } + if ((nullptr == phWaitEvents) && (0 < numWaitEvents)) { + return ZE_RESULT_ERROR_INVALID_SIZE; + } + + auto cmdList = L0::CommandList::fromHandle(hCommandList); + + return cmdList->appendMemoryFillWithParameters(ptr, pattern, patternSize, size, pNext, hEvent, numWaitEvents, phWaitEvents); +} + } // namespace L0 extern "C" { @@ -135,4 +194,31 @@ zexCommandListAppendHostFunction( return L0::zexCommandListAppendHostFunction(hCommandList, pHostFunction, pUserData, pNext, hSignalEvent, numWaitEvents, phWaitEvents); } +ZE_APIEXPORT ze_result_t ZE_APICALL +zexCommandListAppendMemoryCopyWithParameters( + ze_command_list_handle_t hCommandList, + void *dstptr, + const void *srcptr, + size_t size, + const void *pNext, + uint32_t numWaitEvents, + ze_event_handle_t *phWaitEvents, + ze_event_handle_t hSignalEvent) { + return L0::zexCommandListAppendMemoryCopyWithParameters(hCommandList, dstptr, srcptr, size, pNext, numWaitEvents, phWaitEvents, hSignalEvent); +} + +ZE_APIEXPORT ze_result_t ZE_APICALL +zexCommandListAppendMemoryFillWithParameters( + ze_command_list_handle_t hCommandList, + void *ptr, + const void *pattern, + size_t patternSize, + size_t size, + const void *pNext, + ze_event_handle_t hEvent, + uint32_t numWaitEvents, + ze_event_handle_t *phWaitEvents) { + return L0::zexCommandListAppendMemoryFillWithParameters(hCommandList, ptr, pattern, patternSize, size, pNext, hEvent, numWaitEvents, phWaitEvents); +} + } // extern "C" diff --git a/level_zero/core/source/driver/extension_function_address.cpp b/level_zero/core/source/driver/extension_function_address.cpp index 59576bba5c..7a7e54a577 100644 --- a/level_zero/core/source/driver/extension_function_address.cpp +++ b/level_zero/core/source/driver/extension_function_address.cpp @@ -88,6 +88,8 @@ void *ExtensionFunctionAddressHelper::getExtensionFunctionAddress(const std::str RETURN_FUNC_PTR_IF_EXIST(zetDeviceEnableMetricsExp); RETURN_FUNC_PTR_IF_EXIST(zetDeviceDisableMetricsExp); RETURN_FUNC_PTR_IF_EXIST(zexCommandListAppendHostFunction); + RETURN_FUNC_PTR_IF_EXIST(zexCommandListAppendMemoryCopyWithParameters); + RETURN_FUNC_PTR_IF_EXIST(zexCommandListAppendMemoryFillWithParameters); // mutable command list extension RETURN_FUNC_PTR_IF_EXIST(zeCommandListGetNextCommandIdExp); diff --git a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp index 9101de7c79..3db276b1a9 100644 --- a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp +++ b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp @@ -1343,6 +1343,12 @@ TEST_F(DriverExperimentalApiTest, whenRetrievingApiFunctionThenExpectProperPoint decltype(&zexCommandListAppendHostFunction) expectedCommandListAppendHostFunction = zexCommandListAppendHostFunction; + using pfnCommandListAppendMemoryCopyWithParameters = decltype(&zexCommandListAppendMemoryCopyWithParameters); + using pfnCommandListAppendMemoryFillWithParameters = decltype(&zexCommandListAppendMemoryFillWithParameters); + + pfnCommandListAppendMemoryCopyWithParameters expectedCommandListAppendMemoryCopyWithParameters = zexCommandListAppendMemoryCopyWithParameters; + pfnCommandListAppendMemoryFillWithParameters expectedCommandListAppendMemoryFillWithParameters = zexCommandListAppendMemoryFillWithParameters; + void *funPtr = nullptr; EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetExtensionFunctionAddress(driverHandle, "zexDriverImportExternalPointer", &funPtr)); @@ -1416,6 +1422,12 @@ TEST_F(DriverExperimentalApiTest, whenRetrievingApiFunctionThenExpectProperPoint EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetExtensionFunctionAddress(driverHandle, "zexCommandListAppendHostFunction", &funPtr)); EXPECT_EQ(expectedCommandListAppendHostFunction, reinterpret_cast(funPtr)); + + EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetExtensionFunctionAddress(driverHandle, "zexCommandListAppendMemoryCopyWithParameters", &funPtr)); + EXPECT_EQ(expectedCommandListAppendMemoryCopyWithParameters, reinterpret_cast(funPtr)); + + EXPECT_EQ(ZE_RESULT_SUCCESS, zeDriverGetExtensionFunctionAddress(driverHandle, "zexCommandListAppendMemoryFillWithParameters", &funPtr)); + EXPECT_EQ(expectedCommandListAppendMemoryFillWithParameters, reinterpret_cast(funPtr)); } TEST_F(DriverExperimentalApiTest, givenHostPointerApiExistWhenImportingPtrThenExpectProperBehavior) { diff --git a/level_zero/include/level_zero/driver_experimental/zex_cmdlist.h b/level_zero/include/level_zero/driver_experimental/zex_cmdlist.h index b7977ce006..3a5c26c501 100644 --- a/level_zero/include/level_zero/driver_experimental/zex_cmdlist.h +++ b/level_zero/include/level_zero/driver_experimental/zex_cmdlist.h @@ -52,6 +52,29 @@ zexCommandListAppendHostFunction( uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents); +ZE_APIEXPORT ze_result_t ZE_APICALL +zexCommandListAppendMemoryCopyWithParameters( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + void *dstptr, ///< [in] destination pointer + const void *srcptr, ///< [in] source pointer + size_t size, ///< [in] size in bytes to copy + const void *pNext, ///< [in][optional] additional copy parameters + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching + ze_event_handle_t *phWaitEvents, ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching + ze_event_handle_t hSignalEvent); ///< [in][optional] handle of the event to signal on completion + +ZE_APIEXPORT ze_result_t ZE_APICALL +zexCommandListAppendMemoryFillWithParameters( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + void *ptr, ///< [in] pointer to memory to initialize + const void *pattern, ///< [in] pointer to value to initialize memory to + size_t patternSize, ///< [in] size in bytes of the value to initialize memory to + size_t size, ///< [in] size in bytes to initialize + const void *pNext, ///< [in][optional] additional copy parameters + ze_event_handle_t hEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching + ze_event_handle_t *phWaitEvents); ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait on before launching + #if defined(__cplusplus) } // extern "C" #endif