From 6d91859a433d70e86e2e57c7b4071ccf7e17cbf3 Mon Sep 17 00:00:00 2001 From: "Dunajski, Bartosz" Date: Thu, 23 Nov 2023 11:51:15 +0000 Subject: [PATCH] feature: experimental API to query data size for append wait on memory Related-To: NEO-8145 New API helps to define supported input data size for wait API: zexCommandListAppendWaitOnMemory[64]. If user uses API with greater size than supported, API call may return error. Signed-off-by: Dunajski, Bartosz --- .../WAIT_AND_WRITE_ON_MEMORY.md | 7 +++++ level_zero/include/ze_intel_gpu.h | 31 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/level_zero/doc/experimental_extensions/WAIT_AND_WRITE_ON_MEMORY.md b/level_zero/doc/experimental_extensions/WAIT_AND_WRITE_ON_MEMORY.md index 01db9ae705..01647a8f4c 100644 --- a/level_zero/doc/experimental_extensions/WAIT_AND_WRITE_ON_MEMORY.md +++ b/level_zero/doc/experimental_extensions/WAIT_AND_WRITE_ON_MEMORY.md @@ -13,12 +13,19 @@ SPDX-License-Identifier: MIT # Overview +Implementation must support `ZE_intel_experimental_command_list_memory_sync` extension. + ## Wait On Memory Wait On Memory provides a low level dependency mechanism through memory locations. It could be used to implement event-like synchronization mechanism where the wait on a memory location is on a value written by a EU thread. A potential use case is to hide context switching latencies between different engine classes. This functionality is also useful in heterogenous multi-device synchronization setups where, for example, a network card could write to memory location to indicate a packet is ready for consumption and the device waits on memory location via this extension. +Depending on HW, implementation may support different data size to wait (`zexCommandListAppendWaitOnMemory` / `zexCommandListAppendWaitOnMemory64`). + +Application must query minimal supported size via `ze_intel_device_command_list_wait_on_memory_data_size_exp_desc_t` struct. +Not supported API will return error. + ## Write To Memory Write To Memory is a counterpart to the wait on memory method to allow for scenarios where user prefers to write to the memory location from the accelerator device. diff --git a/level_zero/include/ze_intel_gpu.h b/level_zero/include/ze_intel_gpu.h index 2325d0bba9..6f3b4fe86d 100644 --- a/level_zero/include/ze_intel_gpu.h +++ b/level_zero/include/ze_intel_gpu.h @@ -62,6 +62,37 @@ typedef struct _ze_intel_device_module_dp_exp_properties_t { ze_intel_device_module_dp_exp_flags_t flags; ///< [out] 0 (none) or a valid combination of ::ze_intel_device_module_dp_flag_t } ze_intel_device_module_dp_exp_properties_t; +#ifndef ZE_INTEL_COMMAND_LIST_MEMORY_SYNC +/// @brief wait on memory extension name +#define ZE_INTEL_COMMAND_LIST_MEMORY_SYNC "ZE_intel_experimental_command_list_memory_sync" +#endif // ZE_INTEL_COMMAND_LIST_MEMORY_SYNC + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Cmd List memory sync extension Version(s) +typedef enum _ze_intel_command_list_memory_sync_exp_version_t { + ZE_INTEL_COMMAND_LIST_MEMORY_SYNC_EXP_VERSION_1_0 = ZE_MAKE_VERSION(1, 0), ///< version 1.0 + ZE_INTEL_COMMAND_LIST_MEMORY_SYNC_EXP_VERSION_CURRENT = ZE_MAKE_VERSION(1, 0), ///< latest known version + ZE_INTEL_COMMAND_LIST_MEMORY_SYNC_EXP_VERSION_FORCE_UINT32 = 0x7fffffff +} ze_intel_command_list_memory_sync_exp_version_t; + +#ifndef ZE_INTEL_STRUCTURE_TYPE_DEVICE_COMMAND_LIST_WAIT_ON_MEMORY_DATA_SIZE_EXP_DESC +/// @brief stype for _ze_intel_device_command_list_wait_on_memory_data_size_exp_desc_t +#define ZE_INTEL_STRUCTURE_TYPE_DEVICE_COMMAND_LIST_WAIT_ON_MEMORY_DATA_SIZE_EXP_DESC (ze_structure_type_t)0x00030017 +#endif + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Extended descriptor for cmd list memory sync +/// +/// @details +/// - Implementation must support ::ZE_intel_experimental_command_list_memory_sync extension +/// - May be passed to ze_device_properties_t through pNext. +typedef struct _ze_intel_device_command_list_wait_on_memory_data_size_exp_desc_t { + ze_structure_type_t stype = ZE_INTEL_STRUCTURE_TYPE_DEVICE_COMMAND_LIST_WAIT_ON_MEMORY_DATA_SIZE_EXP_DESC; ///< [in] type of this structure + const void *pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + uint32_t cmdListWaitOnMemoryDataSizeInBytes; /// Defines supported data size for zexCommandListAppendWaitOnMemory[64] API +} ze_intel_device_command_list_wait_on_memory_data_size_exp_desc_t; + #ifndef ZE_INTEL_EVENT_SYNC_MODE /// @brief Event sync mode extension name #define ZE_INTEL_EVENT_SYNC_MODE "ZE_intel_experimental_event_sync_mode"