From 562ef3ed54e2c3e8d1bfc16e6e8930da8eae0e6d Mon Sep 17 00:00:00 2001 From: Hugh Delaney Date: Mon, 30 Sep 2024 10:06:52 +0100 Subject: [PATCH] Add initial spec for async alloc entry points First basic work in progress spec. --- include/ur_api.h | 270 ++++++++++++- include/ur_api_funcs.def | 4 + include/ur_ddi.h | 31 ++ include/ur_print.h | 60 +++ include/ur_print.hpp | 381 ++++++++++++++++++ scripts/core/EXP-ASYNC-ALLOC.rst | 78 ++++ scripts/core/exp-async-alloc.yml | 216 ++++++++++ scripts/core/registry.yml | 12 + source/adapters/cuda/common.cpp | 9 +- source/adapters/cuda/usm.cpp | 120 ++++++ source/adapters/hip/common.cpp | 12 +- source/adapters/hip/usm.cpp | 120 ++++++ .../level_zero/ur_interface_loader.cpp | 4 + .../level_zero/ur_interface_loader.hpp | 20 + source/adapters/level_zero/usm.cpp | 120 ++++++ source/adapters/level_zero/v2/queue_api.cpp | 43 ++ source/adapters/level_zero/v2/queue_api.hpp | 18 + .../v2/queue_immediate_in_order.cpp | 56 +++ .../v2/queue_immediate_in_order.hpp | 19 + source/adapters/mock/ur_mockddi.cpp | 270 +++++++++++++ source/adapters/native_cpu/usm.cpp | 61 +++ source/adapters/opencl/usm.cpp | 45 +++ source/common/logger/ur_sinks.hpp | 4 +- source/common/stype_map_helpers.def | 2 + source/loader/layers/tracing/ur_trcddi.cpp | 240 +++++++++++ source/loader/layers/validation/ur_valddi.cpp | 277 ++++++++++++- source/loader/loader.def.in | 10 + source/loader/loader.map.in | 10 + source/loader/ur_ldrddi.cpp | 274 +++++++++++++ source/loader/ur_libapi.cpp | 199 ++++++++- source/loader/ur_print.cpp | 49 +++ source/ur_api.cpp | 168 +++++++- test/conformance/testing/include/uur/utils.h | 8 +- tools/urinfo/urinfo.cpp | 28 +- tools/urinfo/urinfo.hpp | 3 + 35 files changed, 3203 insertions(+), 38 deletions(-) create mode 100644 scripts/core/EXP-ASYNC-ALLOC.rst create mode 100644 scripts/core/exp-async-alloc.yml diff --git a/include/ur_api.h b/include/ur_api.h index 81d7a92c01..92518da7ba 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -435,6 +435,14 @@ typedef enum ur_function_t { UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER_EXT = 246, /// Enumerator for ::urPhysicalMemGetInfo UR_FUNCTION_PHYSICAL_MEM_GET_INFO = 249, + /// Enumerator for ::urEnqueueUSMDeviceAllocExp + UR_FUNCTION_ENQUEUE_USM_DEVICE_ALLOC_EXP = 250, + /// Enumerator for ::urEnqueueUSMSharedAllocExp + UR_FUNCTION_ENQUEUE_USM_SHARED_ALLOC_EXP = 251, + /// Enumerator for ::urEnqueueUSMHostAllocExp + UR_FUNCTION_ENQUEUE_USM_HOST_ALLOC_EXP = 252, + /// Enumerator for ::urEnqueueUSMFreeExp + UR_FUNCTION_ENQUEUE_USM_FREE_EXP = 253, /// @cond UR_FUNCTION_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -542,6 +550,8 @@ typedef enum ur_structure_type_t { UR_STRUCTURE_TYPE_EXP_IMAGE_COPY_REGION = 0x2007, /// ::ur_exp_enqueue_native_command_properties_t UR_STRUCTURE_TYPE_EXP_ENQUEUE_NATIVE_COMMAND_PROPERTIES = 0x3000, + /// ::ur_exp_enqueue_usm_alloc_properties_t + UR_STRUCTURE_TYPE_EXP_ENQUEUE_USM_ALLOC_PROPERTIES = 0x3001, /// ::ur_exp_enqueue_ext_properties_t UR_STRUCTURE_TYPE_EXP_ENQUEUE_EXT_PROPERTIES = 0x4000, /// @cond @@ -2295,6 +2305,9 @@ typedef enum ur_device_info_t { /// [::ur_exp_device_2d_block_array_capability_flags_t] return a bit-field /// of Intel GPU 2D block array capabilities UR_DEVICE_INFO_2D_BLOCK_ARRAY_CAPABILITIES_EXP = 0x2022, + /// [::ur_bool_t] returns true if the device supports USM allocation + /// enqueueing + UR_DEVICE_INFO_ENQUEUE_USM_ALLOCATIONS_EXP = 0x2023, /// @cond UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -2320,7 +2333,7 @@ typedef enum ur_device_info_t { /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION -/// + `::UR_DEVICE_INFO_2D_BLOCK_ARRAY_CAPABILITIES_EXP < propName` +/// + `::UR_DEVICE_INFO_ENQUEUE_USM_ALLOCATIONS_EXP < propName` /// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION /// + If `propName` is not supported by the adapter. /// - ::UR_RESULT_ERROR_INVALID_SIZE @@ -7047,6 +7060,14 @@ typedef enum ur_command_t { UR_COMMAND_TIMESTAMP_RECORDING_EXP = 0x2002, /// Event created by ::urEnqueueNativeCommandExp UR_COMMAND_ENQUEUE_NATIVE_EXP = 0x2004, + /// Event created by ::urEnqueueUSMDeviceAllocExp + UR_COMMAND_ENQUEUE_USM_DEVICE_ALLOC_EXP = 0x2005, + /// Event created by ::urEnqueueUSMSharedAllocExp + UR_COMMAND_ENQUEUE_USM_SHARED_ALLOC_EXP = 0x2006, + /// Event created by ::urEnqueueUSMHostAllocExp + UR_COMMAND_ENQUEUE_USM_HOST_ALLOC_EXP = 0x2007, + /// Event created by ::urEnqueueUSMFreeExp + UR_COMMAND_ENQUEUE_USM_FREE_EXP = 0x2008, /// @cond UR_COMMAND_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -8941,6 +8962,195 @@ typedef enum ur_exp_device_2d_block_array_capability_flag_t { /// ur_exp_device_2d_block_array_capability_flags_t #define UR_EXP_DEVICE_2D_BLOCK_ARRAY_CAPABILITY_FLAGS_MASK 0xfffffffc +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Unified Runtime Experimental API for enqueuing asynchronous +// USM allocations +#if !defined(__GNUC__) +#pragma region async_alloc_(experimental) +#endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue USM allocation flags +typedef uint32_t ur_exp_enqueue_usm_alloc_flags_t; +typedef enum ur_exp_enqueue_usm_alloc_flag_t { + /// reserved for future use. + UR_EXP_ENQUEUE_USM_ALLOC_FLAG_TBD = UR_BIT(0), + /// @cond + UR_EXP_ENQUEUE_USM_ALLOC_FLAG_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_exp_enqueue_usm_alloc_flag_t; +/// @brief Bit Mask for validating ur_exp_enqueue_usm_alloc_flags_t +#define UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK 0xfffffffe + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue USM allocation properties +typedef struct ur_exp_enqueue_usm_alloc_properties_t { + /// [in] type of this structure, must be + /// ::UR_STRUCTURE_TYPE_EXP_ENQUEUE_USM_ALLOC_PROPERTIES + ur_structure_type_t stype; + /// [in,out][optional] pointer to extension-specific structure + void *pNext; + /// [in] enqueue USM allocation flags + ur_exp_enqueue_usm_alloc_flags_t flags; + +} ur_exp_enqueue_usm_alloc_properties_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM device allocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & +/// pProperties->flags` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM device allocation + ur_event_handle_t *phEvent); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM shared allocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & +/// pProperties->flags` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM shared allocation + ur_event_handle_t *phEvent); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM host allocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & +/// pProperties->flags` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM host allocation + ur_event_handle_t *phEvent); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM deallocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMFreeExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] pointer to USM memory object + void *pMem, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out][optional] return an event object that identifies the + /// asynchronous USM deallocation + ur_event_handle_t *phEvent); + #if !defined(__GNUC__) #pragma endregion #endif @@ -13558,6 +13768,64 @@ typedef struct ur_enqueue_events_wait_with_barrier_ext_params_t { ur_event_handle_t **pphEvent; } ur_enqueue_events_wait_with_barrier_ext_params_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urEnqueueUSMDeviceAllocExp +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_enqueue_usm_device_alloc_exp_params_t { + ur_queue_handle_t *phQueue; + ur_usm_pool_handle_t *ppPool; + const size_t *psize; + const ur_exp_enqueue_usm_alloc_properties_t **ppProperties; + uint32_t *pnumEventsInWaitList; + const ur_event_handle_t **pphEventWaitList; + void ***pppMem; + ur_event_handle_t **pphEvent; +} ur_enqueue_usm_device_alloc_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urEnqueueUSMSharedAllocExp +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_enqueue_usm_shared_alloc_exp_params_t { + ur_queue_handle_t *phQueue; + ur_usm_pool_handle_t *ppPool; + const size_t *psize; + const ur_exp_enqueue_usm_alloc_properties_t **ppProperties; + uint32_t *pnumEventsInWaitList; + const ur_event_handle_t **pphEventWaitList; + void ***pppMem; + ur_event_handle_t **pphEvent; +} ur_enqueue_usm_shared_alloc_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urEnqueueUSMHostAllocExp +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_enqueue_usm_host_alloc_exp_params_t { + ur_queue_handle_t *phQueue; + ur_usm_pool_handle_t *ppPool; + const size_t *psize; + const ur_exp_enqueue_usm_alloc_properties_t **ppProperties; + uint32_t *pnumEventsInWaitList; + const ur_event_handle_t **pphEventWaitList; + void ***pppMem; + ur_event_handle_t **pphEvent; +} ur_enqueue_usm_host_alloc_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urEnqueueUSMFreeExp +/// @details Each entry is a pointer to the parameter passed to the function; +/// allowing the callback the ability to modify the parameter's value +typedef struct ur_enqueue_usm_free_exp_params_t { + ur_queue_handle_t *phQueue; + ur_usm_pool_handle_t *ppPool; + void **ppMem; + uint32_t *pnumEventsInWaitList; + const ur_event_handle_t **pphEventWaitList; + ur_event_handle_t **pphEvent; +} ur_enqueue_usm_free_exp_params_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urEnqueueCooperativeKernelLaunchExp /// @details Each entry is a pointer to the parameter passed to the function; diff --git a/include/ur_api_funcs.def b/include/ur_api_funcs.def index 9aef728a58..f0f7096c4f 100644 --- a/include/ur_api_funcs.def +++ b/include/ur_api_funcs.def @@ -132,6 +132,10 @@ _UR_API(urEnqueueReadHostPipe) _UR_API(urEnqueueWriteHostPipe) _UR_API(urEnqueueEventsWaitWithBarrierExt) _UR_API(urEnqueueKernelLaunchCustomExp) +_UR_API(urEnqueueUSMDeviceAllocExp) +_UR_API(urEnqueueUSMSharedAllocExp) +_UR_API(urEnqueueUSMHostAllocExp) +_UR_API(urEnqueueUSMFreeExp) _UR_API(urEnqueueCooperativeKernelLaunchExp) _UR_API(urEnqueueTimestampRecordingExp) _UR_API(urEnqueueNativeCommandExp) diff --git a/include/ur_ddi.h b/include/ur_ddi.h index 9e27b87f17..1936a1feec 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -1117,6 +1117,33 @@ typedef ur_result_t(UR_APICALL *ur_pfnEnqueueKernelLaunchCustomExp_t)( const size_t *, const size_t *, uint32_t, const ur_exp_launch_property_t *, uint32_t, const ur_event_handle_t *, ur_event_handle_t *); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urEnqueueUSMDeviceAllocExp +typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMDeviceAllocExp_t)( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_enqueue_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urEnqueueUSMSharedAllocExp +typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMSharedAllocExp_t)( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_enqueue_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urEnqueueUSMHostAllocExp +typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMHostAllocExp_t)( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_enqueue_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urEnqueueUSMFreeExp +typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMFreeExp_t)( + ur_queue_handle_t, ur_usm_pool_handle_t, void *, uint32_t, + const ur_event_handle_t *, ur_event_handle_t *); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urEnqueueCooperativeKernelLaunchExp typedef ur_result_t(UR_APICALL *ur_pfnEnqueueCooperativeKernelLaunchExp_t)( @@ -1142,6 +1169,10 @@ typedef ur_result_t(UR_APICALL *ur_pfnEnqueueNativeCommandExp_t)( /// @brief Table of EnqueueExp functions pointers typedef struct ur_enqueue_exp_dditable_t { ur_pfnEnqueueKernelLaunchCustomExp_t pfnKernelLaunchCustomExp; + ur_pfnEnqueueUSMDeviceAllocExp_t pfnUSMDeviceAllocExp; + ur_pfnEnqueueUSMSharedAllocExp_t pfnUSMSharedAllocExp; + ur_pfnEnqueueUSMHostAllocExp_t pfnUSMHostAllocExp; + ur_pfnEnqueueUSMFreeExp_t pfnUSMFreeExp; ur_pfnEnqueueCooperativeKernelLaunchExp_t pfnCooperativeKernelLaunchExp; ur_pfnEnqueueTimestampRecordingExp_t pfnTimestampRecordingExp; ur_pfnEnqueueNativeCommandExp_t pfnNativeCommandExp; diff --git a/include/ur_print.h b/include/ur_print.h index bcdd8172f8..eb5500cd44 100644 --- a/include/ur_print.h +++ b/include/ur_print.h @@ -1122,6 +1122,26 @@ urPrintExpDevice_2dBlockArrayCapabilityFlags( enum ur_exp_device_2d_block_array_capability_flag_t value, char *buffer, const size_t buff_size, size_t *out_size); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_exp_enqueue_usm_alloc_flag_t enum +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintExpEnqueueUsmAllocFlags( + enum ur_exp_enqueue_usm_alloc_flag_t value, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_exp_enqueue_usm_alloc_properties_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintExpEnqueueUsmAllocProperties( + const struct ur_exp_enqueue_usm_alloc_properties_t params, char *buffer, + const size_t buff_size, size_t *out_size); + /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_exp_image_copy_flag_t enum /// @returns @@ -2626,6 +2646,46 @@ urPrintEnqueueEventsWaitWithBarrierExtParams( const struct ur_enqueue_events_wait_with_barrier_ext_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_enqueue_usm_device_alloc_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintEnqueueUsmDeviceAllocExpParams( + const struct ur_enqueue_usm_device_alloc_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_enqueue_usm_shared_alloc_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintEnqueueUsmSharedAllocExpParams( + const struct ur_enqueue_usm_shared_alloc_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_enqueue_usm_host_alloc_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintEnqueueUsmHostAllocExpParams( + const struct ur_enqueue_usm_host_alloc_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_enqueue_usm_free_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintEnqueueUsmFreeExpParams( + const struct ur_enqueue_usm_free_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_enqueue_cooperative_kernel_launch_exp_params_t struct /// @returns diff --git a/include/ur_print.hpp b/include/ur_print.hpp index c9a4d3d246..6ad62c02d8 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -225,6 +225,10 @@ inline ur_result_t printFlag(std::ostream &os, uint32_t flag); +template <> +inline ur_result_t printFlag(std::ostream &os, + uint32_t flag); + template <> inline ur_result_t printFlag(std::ostream &os, uint32_t flag); @@ -502,6 +506,11 @@ inline std::ostream &operator<<(std::ostream &os, inline std::ostream & operator<<(std::ostream &os, enum ur_exp_device_2d_block_array_capability_flag_t value); +inline std::ostream &operator<<(std::ostream &os, + enum ur_exp_enqueue_usm_alloc_flag_t value); +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_exp_enqueue_usm_alloc_properties_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_image_copy_flag_t value); inline std::ostream & @@ -1186,6 +1195,18 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { case UR_FUNCTION_PHYSICAL_MEM_GET_INFO: os << "UR_FUNCTION_PHYSICAL_MEM_GET_INFO"; break; + case UR_FUNCTION_ENQUEUE_USM_DEVICE_ALLOC_EXP: + os << "UR_FUNCTION_ENQUEUE_USM_DEVICE_ALLOC_EXP"; + break; + case UR_FUNCTION_ENQUEUE_USM_SHARED_ALLOC_EXP: + os << "UR_FUNCTION_ENQUEUE_USM_SHARED_ALLOC_EXP"; + break; + case UR_FUNCTION_ENQUEUE_USM_HOST_ALLOC_EXP: + os << "UR_FUNCTION_ENQUEUE_USM_HOST_ALLOC_EXP"; + break; + case UR_FUNCTION_ENQUEUE_USM_FREE_EXP: + os << "UR_FUNCTION_ENQUEUE_USM_FREE_EXP"; + break; default: os << "unknown enumerator"; break; @@ -1346,6 +1367,9 @@ inline std::ostream &operator<<(std::ostream &os, case UR_STRUCTURE_TYPE_EXP_ENQUEUE_NATIVE_COMMAND_PROPERTIES: os << "UR_STRUCTURE_TYPE_EXP_ENQUEUE_NATIVE_COMMAND_PROPERTIES"; break; + case UR_STRUCTURE_TYPE_EXP_ENQUEUE_USM_ALLOC_PROPERTIES: + os << "UR_STRUCTURE_TYPE_EXP_ENQUEUE_USM_ALLOC_PROPERTIES"; + break; case UR_STRUCTURE_TYPE_EXP_ENQUEUE_EXT_PROPERTIES: os << "UR_STRUCTURE_TYPE_EXP_ENQUEUE_EXT_PROPERTIES"; break; @@ -1648,6 +1672,12 @@ inline ur_result_t printStruct(std::ostream &os, const void *ptr) { printPtr(os, pstruct); } break; + case UR_STRUCTURE_TYPE_EXP_ENQUEUE_USM_ALLOC_PROPERTIES: { + const ur_exp_enqueue_usm_alloc_properties_t *pstruct = + (const ur_exp_enqueue_usm_alloc_properties_t *)ptr; + printPtr(os, pstruct); + } break; + case UR_STRUCTURE_TYPE_EXP_ENQUEUE_EXT_PROPERTIES: { const ur_exp_enqueue_ext_properties_t *pstruct = (const ur_exp_enqueue_ext_properties_t *)ptr; @@ -2984,6 +3014,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { case UR_DEVICE_INFO_2D_BLOCK_ARRAY_CAPABILITIES_EXP: os << "UR_DEVICE_INFO_2D_BLOCK_ARRAY_CAPABILITIES_EXP"; break; + case UR_DEVICE_INFO_ENQUEUE_USM_ALLOCATIONS_EXP: + os << "UR_DEVICE_INFO_ENQUEUE_USM_ALLOCATIONS_EXP"; + break; default: os << "unknown enumerator"; break; @@ -4975,6 +5008,19 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, os << ")"; } break; + case UR_DEVICE_INFO_ENQUEUE_USM_ALLOCATIONS_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size + << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return UR_RESULT_ERROR_INVALID_SIZE; + } + os << (const void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; default: os << "unknown enumerator"; return UR_RESULT_ERROR_INVALID_ENUMERATION; @@ -9858,6 +9904,18 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_command_t value) { case UR_COMMAND_ENQUEUE_NATIVE_EXP: os << "UR_COMMAND_ENQUEUE_NATIVE_EXP"; break; + case UR_COMMAND_ENQUEUE_USM_DEVICE_ALLOC_EXP: + os << "UR_COMMAND_ENQUEUE_USM_DEVICE_ALLOC_EXP"; + break; + case UR_COMMAND_ENQUEUE_USM_SHARED_ALLOC_EXP: + os << "UR_COMMAND_ENQUEUE_USM_SHARED_ALLOC_EXP"; + break; + case UR_COMMAND_ENQUEUE_USM_HOST_ALLOC_EXP: + os << "UR_COMMAND_ENQUEUE_USM_HOST_ALLOC_EXP"; + break; + case UR_COMMAND_ENQUEUE_USM_FREE_EXP: + os << "UR_COMMAND_ENQUEUE_USM_FREE_EXP"; + break; default: os << "unknown enumerator"; break; @@ -10351,6 +10409,80 @@ printFlag(std::ostream &os, } } // namespace ur::details /////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_exp_enqueue_usm_alloc_flag_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, + enum ur_exp_enqueue_usm_alloc_flag_t value) { + switch (value) { + case UR_EXP_ENQUEUE_USM_ALLOC_FLAG_TBD: + os << "UR_EXP_ENQUEUE_USM_ALLOC_FLAG_TBD"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} + +namespace ur::details { +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_exp_enqueue_usm_alloc_flag_t flag +template <> +inline ur_result_t printFlag(std::ostream &os, + uint32_t flag) { + uint32_t val = flag; + bool first = true; + + if ((val & UR_EXP_ENQUEUE_USM_ALLOC_FLAG_TBD) == + (uint32_t)UR_EXP_ENQUEUE_USM_ALLOC_FLAG_TBD) { + val ^= (uint32_t)UR_EXP_ENQUEUE_USM_ALLOC_FLAG_TBD; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_EXP_ENQUEUE_USM_ALLOC_FLAG_TBD; + } + if (val != 0) { + std::bitset<32> bits(val); + if (!first) { + os << " | "; + } + os << "unknown bit flags " << bits; + } else if (first) { + os << "0"; + } + return UR_RESULT_SUCCESS; +} +} // namespace ur::details +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_exp_enqueue_usm_alloc_properties_t type +/// @returns +/// std::ostream & +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_exp_enqueue_usm_alloc_properties_t params) { + os << "(struct ur_exp_enqueue_usm_alloc_properties_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur::details::printStruct(os, (params.pNext)); + + os << ", "; + os << ".flags = "; + + ur::details::printFlag(os, (params.flags)); + + os << "}"; + return os; +} +/////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the ur_exp_image_copy_flag_t type /// @returns /// std::ostream & @@ -16135,6 +16267,243 @@ operator<<(std::ostream &os, [[maybe_unused]] const struct return os; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_enqueue_usm_device_alloc_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_enqueue_usm_device_alloc_exp_params_t + *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, *(params->phQueue)); + + os << ", "; + os << ".pPool = "; + + ur::details::printPtr(os, *(params->ppPool)); + + os << ", "; + os << ".size = "; + + os << *(params->psize); + + os << ", "; + os << ".pProperties = "; + + ur::details::printPtr(os, *(params->ppProperties)); + + os << ", "; + os << ".numEventsInWaitList = "; + + os << *(params->pnumEventsInWaitList); + + os << ", "; + os << ".phEventWaitList = "; + ur::details::printPtr( + os, reinterpret_cast(*(params->pphEventWaitList))); + if (*(params->pphEventWaitList) != NULL) { + os << " {"; + for (size_t i = 0; i < *params->pnumEventsInWaitList; ++i) { + if (i != 0) { + os << ", "; + } + + ur::details::printPtr(os, (*(params->pphEventWaitList))[i]); + } + os << "}"; + } + + os << ", "; + os << ".ppMem = "; + + ur::details::printPtr(os, *(params->pppMem)); + + os << ", "; + os << ".phEvent = "; + + ur::details::printPtr(os, *(params->pphEvent)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_enqueue_usm_shared_alloc_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_enqueue_usm_shared_alloc_exp_params_t + *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, *(params->phQueue)); + + os << ", "; + os << ".pPool = "; + + ur::details::printPtr(os, *(params->ppPool)); + + os << ", "; + os << ".size = "; + + os << *(params->psize); + + os << ", "; + os << ".pProperties = "; + + ur::details::printPtr(os, *(params->ppProperties)); + + os << ", "; + os << ".numEventsInWaitList = "; + + os << *(params->pnumEventsInWaitList); + + os << ", "; + os << ".phEventWaitList = "; + ur::details::printPtr( + os, reinterpret_cast(*(params->pphEventWaitList))); + if (*(params->pphEventWaitList) != NULL) { + os << " {"; + for (size_t i = 0; i < *params->pnumEventsInWaitList; ++i) { + if (i != 0) { + os << ", "; + } + + ur::details::printPtr(os, (*(params->pphEventWaitList))[i]); + } + os << "}"; + } + + os << ", "; + os << ".ppMem = "; + + ur::details::printPtr(os, *(params->pppMem)); + + os << ", "; + os << ".phEvent = "; + + ur::details::printPtr(os, *(params->pphEvent)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_enqueue_usm_host_alloc_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream & +operator<<(std::ostream &os, + [[maybe_unused]] const struct ur_enqueue_usm_host_alloc_exp_params_t + *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, *(params->phQueue)); + + os << ", "; + os << ".pPool = "; + + ur::details::printPtr(os, *(params->ppPool)); + + os << ", "; + os << ".size = "; + + os << *(params->psize); + + os << ", "; + os << ".pProperties = "; + + ur::details::printPtr(os, *(params->ppProperties)); + + os << ", "; + os << ".numEventsInWaitList = "; + + os << *(params->pnumEventsInWaitList); + + os << ", "; + os << ".phEventWaitList = "; + ur::details::printPtr( + os, reinterpret_cast(*(params->pphEventWaitList))); + if (*(params->pphEventWaitList) != NULL) { + os << " {"; + for (size_t i = 0; i < *params->pnumEventsInWaitList; ++i) { + if (i != 0) { + os << ", "; + } + + ur::details::printPtr(os, (*(params->pphEventWaitList))[i]); + } + os << "}"; + } + + os << ", "; + os << ".ppMem = "; + + ur::details::printPtr(os, *(params->pppMem)); + + os << ", "; + os << ".phEvent = "; + + ur::details::printPtr(os, *(params->pphEvent)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_enqueue_usm_free_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_enqueue_usm_free_exp_params_t *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, *(params->phQueue)); + + os << ", "; + os << ".pPool = "; + + ur::details::printPtr(os, *(params->ppPool)); + + os << ", "; + os << ".pMem = "; + + ur::details::printPtr(os, *(params->ppMem)); + + os << ", "; + os << ".numEventsInWaitList = "; + + os << *(params->pnumEventsInWaitList); + + os << ", "; + os << ".phEventWaitList = "; + ur::details::printPtr( + os, reinterpret_cast(*(params->pphEventWaitList))); + if (*(params->pphEventWaitList) != NULL) { + os << " {"; + for (size_t i = 0; i < *params->pnumEventsInWaitList; ++i) { + if (i != 0) { + os << ", "; + } + + ur::details::printPtr(os, (*(params->pphEventWaitList))[i]); + } + os << "}"; + } + + os << ", "; + os << ".phEvent = "; + + ur::details::printPtr(os, *(params->pphEvent)); + + return os; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the /// ur_enqueue_cooperative_kernel_launch_exp_params_t type @@ -19890,6 +20259,18 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, os << (const struct ur_enqueue_events_wait_with_barrier_ext_params_t *) params; } break; + case UR_FUNCTION_ENQUEUE_USM_DEVICE_ALLOC_EXP: { + os << (const struct ur_enqueue_usm_device_alloc_exp_params_t *)params; + } break; + case UR_FUNCTION_ENQUEUE_USM_SHARED_ALLOC_EXP: { + os << (const struct ur_enqueue_usm_shared_alloc_exp_params_t *)params; + } break; + case UR_FUNCTION_ENQUEUE_USM_HOST_ALLOC_EXP: { + os << (const struct ur_enqueue_usm_host_alloc_exp_params_t *)params; + } break; + case UR_FUNCTION_ENQUEUE_USM_FREE_EXP: { + os << (const struct ur_enqueue_usm_free_exp_params_t *)params; + } break; case UR_FUNCTION_ENQUEUE_COOPERATIVE_KERNEL_LAUNCH_EXP: { os << (const struct ur_enqueue_cooperative_kernel_launch_exp_params_t *) params; diff --git a/scripts/core/EXP-ASYNC-ALLOC.rst b/scripts/core/EXP-ASYNC-ALLOC.rst new file mode 100644 index 0000000000..8f337febcb --- /dev/null +++ b/scripts/core/EXP-ASYNC-ALLOC.rst @@ -0,0 +1,78 @@ +<% + OneApi=tags['$OneApi'] + x=tags['$x'] + X=x.upper() +%> + +.. _experimental-async-allocations: + +================================================================================ +Async Allocation Functions +================================================================================ + +.. warning:: + + Experimental features: + + * May be replaced, updated, or removed at any time. + * Do not require maintaining API/ABI stability of their own additions over + time. + * Do not require conformance testing of their own additions. + + +Motivation +-------------------------------------------------------------------------------- + +Asynchronous allocations can allow queues to allocate and free memory between +UR command enqueues without forcing synchronization points in the asynchronous +command DAG associated with a queue. This can allow applications to compose +memory allocation and command execution asynchronously, which can improve +performance. + +API +-------------------------------------------------------------------------------- + +Enums +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* ${x}_device_info_t + * ${X}_DEVICE_INFO_ENQUEUE_USM_ALLOCATIONS_EXP +* ${x}_command_t + * ${X}_COMMAND_ENQUEUE_USM_DEVICE_ALLOC_EXP + * ${X}_COMMAND_ENQUEUE_USM_SHARED_ALLOC_EXP + * ${X}_COMMAND_ENQUEUE_USM_HOST_ALLOC_EXP + * ${X}_COMMAND_ENQUEUE_USM_FREE_EXP +* ${x}_exp_enqueue_usm_alloc_flags_t + +Types +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +${x}_exp_enqueue_usm_alloc_properties_t + +Functions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* ${x}EnqueueUSMDeviceAllocExp +* ${x}EnqueueUSMSharedAllocExp +* ${x}EnqueueUSMHostAllocExp +* ${x}EnqueueUSMFreeExp + +Changelog +-------------------------------------------------------------------------------- + ++-----------+---------------------------+ +| Revision | Changes | ++===========+===========================+ +| 1.0 | Initial Draft | ++-----------+---------------------------+ + +Support +-------------------------------------------------------------------------------- + +Adapters which support this experimental feature *must* return true for the new +``${X}_DEVICE_INFO_ENQUEUE_USM_ALLOCATIONS_EXP`` device info query. + + +Contributors +-------------------------------------------------------------------------------- + +* Hugh Delaney `hugh.delaney@codeplay.com `_ diff --git a/scripts/core/exp-async-alloc.yml b/scripts/core/exp-async-alloc.yml new file mode 100644 index 0000000000..92ff962df9 --- /dev/null +++ b/scripts/core/exp-async-alloc.yml @@ -0,0 +1,216 @@ +# +# Copyright (C) 2024 Intel Corporation +# +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +# See YaML.md for syntax definition +# +--- #-------------------------------------------------------------------------- +type: header +desc: "Intel $OneApi Unified Runtime Experimental API for enqueuing asynchronous USM allocations" +ordinal: "99" + +--- #-------------------------------------------------------------------------- +type: enum +extend: true +typed_etors: true +desc: "Extension enums to $x_device_info_t to support USM allocation enqueuing." +name: $x_device_info_t +etors: + - name: ENQUEUE_USM_ALLOCATIONS_EXP + value: "0x2023" + desc: "[$x_bool_t] returns true if the device supports USM allocation enqueueing" + +--- #-------------------------------------------------------------------------- +type: enum +extend: true +desc: "Command Type experimental enumerations." +name: $x_command_t +etors: + - name: ENQUEUE_USM_DEVICE_ALLOC_EXP + value: "0x2005" + desc: Event created by $xEnqueueUSMDeviceAllocExp + - name: ENQUEUE_USM_SHARED_ALLOC_EXP + value: "0x2006" + desc: Event created by $xEnqueueUSMSharedAllocExp + - name: ENQUEUE_USM_HOST_ALLOC_EXP + value: "0x2007" + desc: Event created by $xEnqueueUSMHostAllocExp + - name: ENQUEUE_USM_FREE_EXP + value: "0x2008" + desc: Event created by $xEnqueueUSMFreeExp + +--- #-------------------------------------------------------------------------- +type: enum +desc: "Enqueue USM allocation flags" +name: $x_exp_enqueue_usm_alloc_flags_t +etors: + - name: TBD + desc: "reserved for future use." + +--- #-------------------------------------------------------------------------- +type: struct +desc: "Enqueue USM allocation properties" +name: $x_exp_enqueue_usm_alloc_properties_t +base: $x_base_properties_t +members: + - type: $x_exp_enqueue_usm_alloc_flags_t + name: flags + desc: "[in] enqueue USM allocation flags" + +--- #-------------------------------------------------------------------------- +type: enum +extend: true +desc: "Structure type experimental enumerations" +name: $x_structure_type_t +etors: + - name: EXP_ENQUEUE_USM_ALLOC_PROPERTIES + desc: $x_exp_enqueue_usm_alloc_properties_t + value: "0x3001" + +--- #-------------------------------------------------------------------------- +type: function +desc: "Enqueue an asynchronous USM device allocation" +class: $xEnqueue +name: USMDeviceAllocExp +params: + - type: $x_queue_handle_t + name: hQueue + desc: "[in] handle of the queue object" + - type: $x_usm_pool_handle_t + desc: "[in][optional] handle of the USM memory pool" + name: pPool + - type: const size_t + desc: "[in] minimum size in bytes of the USM memory object to be allocated" + name: size + - type: const $x_exp_enqueue_usm_alloc_properties_t* + name: pProperties + desc: "[in][optional] pointer to the enqueue asynchronous USM allocation properties" + - type: uint32_t + name: numEventsInWaitList + desc: "[in] size of the event wait list" + - type: const $x_event_handle_t* + name: phEventWaitList + desc: | + [in][optional][range(0, numEventsInWaitList)] pointer to a list of events that must be complete before the kernel execution. + If nullptr, the numEventsInWaitList must be 0, indicating no wait events. + - type: void** + name: ppMem + desc: "[out] pointer to USM memory object" + - type: $x_event_handle_t* + name: phEvent + desc: "[out][optional] return an event object that identifies the asynchronous USM device allocation" +returns: + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_INVALID_NULL_HANDLE + - $X_RESULT_ERROR_INVALID_NULL_POINTER + - $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +--- #-------------------------------------------------------------------------- +type: function +desc: "Enqueue an asynchronous USM shared allocation" +class: $xEnqueue +name: USMSharedAllocExp +params: + - type: $x_queue_handle_t + name: hQueue + desc: "[in] handle of the queue object" + - type: $x_usm_pool_handle_t + desc: "[in][optional] handle of the USM memory pool" + name: pPool + - type: const size_t + desc: "[in] minimum size in bytes of the USM memory object to be allocated" + name: size + - type: const $x_exp_enqueue_usm_alloc_properties_t* + name: pProperties + desc: "[in][optional] pointer to the enqueue asynchronous USM allocation properties" + - type: uint32_t + name: numEventsInWaitList + desc: "[in] size of the event wait list" + - type: const $x_event_handle_t* + name: phEventWaitList + desc: | + [in][optional][range(0, numEventsInWaitList)] pointer to a list of events that must be complete before the kernel execution. + If nullptr, the numEventsInWaitList must be 0, indicating no wait events. + - type: void** + name: ppMem + desc: "[out] pointer to USM memory object" + - type: $x_event_handle_t* + name: phEvent + desc: "[out][optional] return an event object that identifies the asynchronous USM shared allocation" +returns: + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_INVALID_NULL_HANDLE + - $X_RESULT_ERROR_INVALID_NULL_POINTER + - $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +--- #-------------------------------------------------------------------------- +type: function +desc: "Enqueue an asynchronous USM host allocation" +class: $xEnqueue +name: USMHostAllocExp +params: + - type: $x_queue_handle_t + name: hQueue + desc: "[in] handle of the queue object" + - type: $x_usm_pool_handle_t + desc: "[in][optional] handle of the USM memory pool" + name: pPool + - type: const size_t + desc: "[in] minimum size in bytes of the USM memory object to be allocated" + name: size + - type: const $x_exp_enqueue_usm_alloc_properties_t* + name: pProperties + desc: "[in][optional] pointer to the enqueue asynchronous USM allocation properties" + - type: uint32_t + name: numEventsInWaitList + desc: "[in] size of the event wait list" + - type: const $x_event_handle_t* + name: phEventWaitList + desc: | + [in][optional][range(0, numEventsInWaitList)] pointer to a list of events that must be complete before the kernel execution. + If nullptr, the numEventsInWaitList must be 0, indicating no wait events. + - type: void** + name: ppMem + desc: "[out] pointer to USM memory object" + - type: $x_event_handle_t* + name: phEvent + desc: "[out][optional] return an event object that identifies the asynchronous USM host allocation" +returns: + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY + - $X_RESULT_ERROR_INVALID_NULL_HANDLE + - $X_RESULT_ERROR_INVALID_NULL_POINTER + - $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +--- #-------------------------------------------------------------------------- +type: function +desc: "Enqueue an asynchronous USM deallocation" +class: $xEnqueue +name: USMFreeExp +params: + - type: $x_queue_handle_t + name: hQueue + desc: "[in] handle of the queue object" + - type: $x_usm_pool_handle_t + desc: "[in][optional] handle of the USM memory pool" + name: pPool + - type: void* + name: pMem + desc: "[in] pointer to USM memory object" + - type: uint32_t + name: numEventsInWaitList + desc: "[in] size of the event wait list" + - type: const $x_event_handle_t* + name: phEventWaitList + desc: | + [in][optional][range(0, numEventsInWaitList)] pointer to a list of events that must be complete before the kernel execution. + If nullptr, the numEventsInWaitList must be 0, indicating no wait events. + - type: $x_event_handle_t* + name: phEvent + desc: "[out][optional] return an event object that identifies the asynchronous USM deallocation" +returns: + - $X_RESULT_ERROR_OUT_OF_RESOURCES + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY + - $X_RESULT_ERROR_INVALID_NULL_HANDLE + - $X_RESULT_ERROR_INVALID_NULL_POINTER + - $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST diff --git a/scripts/core/registry.yml b/scripts/core/registry.yml index 379ef87b35..e39d8c7c3b 100644 --- a/scripts/core/registry.yml +++ b/scripts/core/registry.yml @@ -610,6 +610,18 @@ etors: - name: PHYSICAL_MEM_GET_INFO desc: Enumerator for $xPhysicalMemGetInfo value: '249' +- name: ENQUEUE_USM_DEVICE_ALLOC_EXP + desc: Enumerator for $xEnqueueUSMDeviceAllocExp + value: '250' +- name: ENQUEUE_USM_SHARED_ALLOC_EXP + desc: Enumerator for $xEnqueueUSMSharedAllocExp + value: '251' +- name: ENQUEUE_USM_HOST_ALLOC_EXP + desc: Enumerator for $xEnqueueUSMHostAllocExp + value: '252' +- name: ENQUEUE_USM_FREE_EXP + desc: Enumerator for $xEnqueueUSMFreeExp + value: '253' --- type: enum desc: Defines structure types diff --git a/source/adapters/cuda/common.cpp b/source/adapters/cuda/common.cpp index 89500d1a1c..8a524a1cf6 100644 --- a/source/adapters/cuda/common.cpp +++ b/source/adapters/cuda/common.cpp @@ -47,8 +47,7 @@ void checkErrorUR(CUresult Result, const char *Function, int Line, cuGetErrorName(Result, &ErrorName); cuGetErrorString(Result, &ErrorString); std::stringstream SS; - SS << "\nUR CUDA ERROR:" - << "\n\tValue: " << Result + SS << "\nUR CUDA ERROR:" << "\n\tValue: " << Result << "\n\tName: " << ErrorName << "\n\tDescription: " << ErrorString << "\n\tFunction: " << Function << "\n\tSource Location: " << File @@ -70,9 +69,9 @@ void checkErrorUR(ur_result_t Result, const char *Function, int Line, } std::stringstream SS; - SS << "\nUR ERROR:" - << "\n\tValue: " << Result << "\n\tFunction: " << Function - << "\n\tSource Location: " << File << ":" << Line << "\n"; + SS << "\nUR ERROR:" << "\n\tValue: " << Result + << "\n\tFunction: " << Function << "\n\tSource Location: " << File + << ":" << Line << "\n"; logger::error("{}", SS.str()); if (std::getenv("PI_CUDA_ABORT") != nullptr) { diff --git a/source/adapters/cuda/usm.cpp b/source/adapters/cuda/usm.cpp index 7f48309ca3..0b76efd652 100644 --- a/source/adapters/cuda/usm.cpp +++ b/source/adapters/cuda/usm.cpp @@ -513,3 +513,123 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMPoolGetInfo( } } } + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pool + const size_t size, ///< [in] minimum size in bytes of the USM memory object + ///< to be allocated + const ur_exp_enqueue_usm_alloc_properties_t + *pProperties, ///< [in][optional] pointer to the enqueue asynchronous + ///< USM allocation properties + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + void **ppMem, ///< [out] pointer to USM memory object + ur_event_handle_t + *phEvent ///< [out][optional] return an event object that identifies the + ///< asynchronous USM device allocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pool + const size_t size, ///< [in] minimum size in bytes of the USM memory object + ///< to be allocated + const ur_exp_enqueue_usm_alloc_properties_t + *pProperties, ///< [in][optional] pointer to the enqueue asynchronous + ///< USM allocation properties + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + void **ppMem, ///< [out] pointer to USM memory object + ur_event_handle_t + *phEvent ///< [out][optional] return an event object that identifies the + ///< asynchronous USM shared allocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pool + const size_t size, ///< [in] minimum size in bytes of the USM memory object + ///< to be allocated + const ur_exp_enqueue_usm_alloc_properties_t + *pProperties, ///< [in][optional] pointer to the enqueue asynchronous + ///< USM allocation properties + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + void **ppMem, ///< [out] pointer to USM memory object + ur_event_handle_t + *phEvent ///< [out][optional] return an event object that identifies the + ///< asynchronous USM host allocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMFreeExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pooliptor + void *pMem, ///< [in] pointer to USM memory object + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + ur_event_handle_t *phEvent ///< [out][optional] return an event object that + ///< identifies the asynchronous USM deallocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = pMem; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/source/adapters/hip/common.cpp b/source/adapters/hip/common.cpp index 23ef1d3301..b77a1edcef 100644 --- a/source/adapters/hip/common.cpp +++ b/source/adapters/hip/common.cpp @@ -76,8 +76,7 @@ void checkErrorUR(amd_comgr_status_t Result, const char *Function, int Line, break; } std::stringstream SS; - SS << "\nUR HIP ERROR:" - << "\n\tValue: " << Result + SS << "\nUR HIP ERROR:" << "\n\tValue: " << Result << "\n\tName: " << ErrorName << "\n\tDescription: " << ErrorString << "\n\tFunction: " << Function << "\n\tSource Location: " << File @@ -103,8 +102,7 @@ void checkErrorUR(hipError_t Result, const char *Function, int Line, const char *ErrorName = hipGetErrorName(Result); std::stringstream SS; - SS << "\nUR HIP ERROR:" - << "\n\tValue: " << Result + SS << "\nUR HIP ERROR:" << "\n\tValue: " << Result << "\n\tName: " << ErrorName << "\n\tDescription: " << ErrorString << "\n\tFunction: " << Function << "\n\tSource Location: " << File @@ -126,9 +124,9 @@ void checkErrorUR(ur_result_t Result, const char *Function, int Line, } std::stringstream SS; - SS << "\nUR HIP ERROR:" - << "\n\tValue: " << Result << "\n\tFunction: " << Function - << "\n\tSource Location: " << File << ":" << Line << "\n"; + SS << "\nUR HIP ERROR:" << "\n\tValue: " << Result + << "\n\tFunction: " << Function << "\n\tSource Location: " << File + << ":" << Line << "\n"; logger::error("{}", SS.str()); if (std::getenv("PI_HIP_ABORT") != nullptr || diff --git a/source/adapters/hip/usm.cpp b/source/adapters/hip/usm.cpp index 922098e4a1..fb689d2353 100644 --- a/source/adapters/hip/usm.cpp +++ b/source/adapters/hip/usm.cpp @@ -478,3 +478,123 @@ ur_result_t umfPoolMallocHelper(ur_usm_pool_handle_t hPool, void **ppMem, } return UR_RESULT_SUCCESS; } + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pool + const size_t size, ///< [in] minimum size in bytes of the USM memory object + ///< to be allocated + const ur_exp_enqueue_usm_alloc_properties_t + *pProperties, ///< [in][optional] pointer to the enqueue asynchronous + ///< USM allocation properties + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + void **ppMem, ///< [out] pointer to USM memory object + ur_event_handle_t + *phEvent ///< [out][optional] return an event object that identifies the + ///< asynchronous USM device allocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pool + const size_t size, ///< [in] minimum size in bytes of the USM memory object + ///< to be allocated + const ur_exp_enqueue_usm_alloc_properties_t + *pProperties, ///< [in][optional] pointer to the enqueue asynchronous + ///< USM allocation properties + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + void **ppMem, ///< [out] pointer to USM memory object + ur_event_handle_t + *phEvent ///< [out][optional] return an event object that identifies the + ///< asynchronous USM shared allocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pool + const size_t size, ///< [in] minimum size in bytes of the USM memory object + ///< to be allocated + const ur_exp_enqueue_usm_alloc_properties_t + *pProperties, ///< [in][optional] pointer to the enqueue asynchronous + ///< USM allocation properties + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + void **ppMem, ///< [out] pointer to USM memory object + ur_event_handle_t + *phEvent ///< [out][optional] return an event object that identifies the + ///< asynchronous USM host allocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMFreeExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pooliptor + void *pMem, ///< [in] pointer to USM memory object + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + ur_event_handle_t *phEvent ///< [out][optional] return an event object that + ///< identifies the asynchronous USM deallocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = pMem; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/source/adapters/level_zero/ur_interface_loader.cpp b/source/adapters/level_zero/ur_interface_loader.cpp index c938ff1f95..917b00cf90 100644 --- a/source/adapters/level_zero/ur_interface_loader.cpp +++ b/source/adapters/level_zero/ur_interface_loader.cpp @@ -216,6 +216,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetEnqueueExpProcAddrTable( pDdiTable->pfnKernelLaunchCustomExp = ur::level_zero::urEnqueueKernelLaunchCustomExp; + pDdiTable->pfnUSMDeviceAllocExp = ur::level_zero::urEnqueueUSMDeviceAllocExp; + pDdiTable->pfnUSMSharedAllocExp = ur::level_zero::urEnqueueUSMSharedAllocExp; + pDdiTable->pfnUSMHostAllocExp = ur::level_zero::urEnqueueUSMHostAllocExp; + pDdiTable->pfnUSMFreeExp = ur::level_zero::urEnqueueUSMFreeExp; pDdiTable->pfnCooperativeKernelLaunchExp = ur::level_zero::urEnqueueCooperativeKernelLaunchExp; pDdiTable->pfnTimestampRecordingExp = diff --git a/source/adapters/level_zero/ur_interface_loader.hpp b/source/adapters/level_zero/ur_interface_loader.hpp index 8620eeea81..3fd41caaed 100644 --- a/source/adapters/level_zero/ur_interface_loader.hpp +++ b/source/adapters/level_zero/ur_interface_loader.hpp @@ -466,6 +466,26 @@ ur_result_t urEnqueueWriteHostPipe(ur_queue_handle_t hQueue, uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent); +ur_result_t urEnqueueUSMDeviceAllocExp( + ur_queue_handle_t hQueue, ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent); +ur_result_t urEnqueueUSMSharedAllocExp( + ur_queue_handle_t hQueue, ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent); +ur_result_t urEnqueueUSMHostAllocExp( + ur_queue_handle_t hQueue, ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent); +ur_result_t urEnqueueUSMFreeExp(ur_queue_handle_t hQueue, + ur_usm_pool_handle_t pPool, void *pMem, + uint32_t numEventsInWaitList, + const ur_event_handle_t *phEventWaitList, + ur_event_handle_t *phEvent); ur_result_t urUSMPitchedAllocExp(ur_context_handle_t hContext, ur_device_handle_t hDevice, const ur_usm_desc_t *pUSMDesc, diff --git a/source/adapters/level_zero/usm.cpp b/source/adapters/level_zero/usm.cpp index 19480e83c5..e87f6b5e24 100644 --- a/source/adapters/level_zero/usm.cpp +++ b/source/adapters/level_zero/usm.cpp @@ -803,6 +803,126 @@ ur_result_t urUSMReleaseExp(ur_context_handle_t Context, void *HostPtr) { Context->getPlatform()->ZeDriverHandleExpTranslated, HostPtr); return UR_RESULT_SUCCESS; } + +ur_result_t urEnqueueUSMDeviceAllocExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pool + const size_t size, ///< [in] minimum size in bytes of the USM memory object + ///< to be allocated + const ur_exp_enqueue_usm_alloc_properties_t + *pProperties, ///< [in][optional] pointer to the enqueue asynchronous + ///< USM allocation properties + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + void **ppMem, ///< [out] pointer to USM memory object + ur_event_handle_t + *phEvent ///< [out][optional] return an event object that identifies the + ///< asynchronous USM device allocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urEnqueueUSMSharedAllocExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pool + const size_t size, ///< [in] minimum size in bytes of the USM memory object + ///< to be allocated + const ur_exp_enqueue_usm_alloc_properties_t + *pProperties, ///< [in][optional] pointer to the enqueue asynchronous + ///< USM allocation properties + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + void **ppMem, ///< [out] pointer to USM memory object + ur_event_handle_t + *phEvent ///< [out][optional] return an event object that identifies the + ///< asynchronous USM shared allocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urEnqueueUSMHostAllocExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pool + const size_t size, ///< [in] minimum size in bytes of the USM memory object + ///< to be allocated + const ur_exp_enqueue_usm_alloc_properties_t + *pProperties, ///< [in][optional] pointer to the enqueue asynchronous + ///< USM allocation properties + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + void **ppMem, ///< [out] pointer to USM memory object + ur_event_handle_t + *phEvent ///< [out][optional] return an event object that identifies the + ///< asynchronous USM host allocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urEnqueueUSMFreeExp( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t + pPool, ///< [in][optional] handle of the USM memory pooliptor + void *pMem, ///< [in] pointer to USM memory object + uint32_t numEventsInWaitList, ///< [in] size of the event wait list + const ur_event_handle_t + *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] + ///< pointer to a list of events that must be complete + ///< before the kernel execution. If nullptr, the + ///< numEventsInWaitList must be 0, indicating no wait + ///< events. + ur_event_handle_t *phEvent ///< [out][optional] return an event object that + ///< identifies the asynchronous USM deallocation +) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = pMem; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} } // namespace ur::level_zero static ur_result_t USMFreeImpl(ur_context_handle_t Context, void *Ptr) { diff --git a/source/adapters/level_zero/v2/queue_api.cpp b/source/adapters/level_zero/v2/queue_api.cpp index 28ff527413..3e9b5d0360 100644 --- a/source/adapters/level_zero/v2/queue_api.cpp +++ b/source/adapters/level_zero/v2/queue_api.cpp @@ -339,6 +339,49 @@ ur_result_t urEnqueueWriteHostPipe(ur_queue_handle_t hQueue, } catch (...) { return exceptionToResult(std::current_exception()); } +ur_result_t urEnqueueUSMDeviceAllocExp( + ur_queue_handle_t hQueue, ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) try { + return hQueue->enqueueUSMDeviceAllocExp(pPool, size, pProperties, + numEventsInWaitList, phEventWaitList, + ppMem, phEvent); +} catch (...) { + return exceptionToResult(std::current_exception()); +} +ur_result_t urEnqueueUSMSharedAllocExp( + ur_queue_handle_t hQueue, ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) try { + return hQueue->enqueueUSMSharedAllocExp(pPool, size, pProperties, + numEventsInWaitList, phEventWaitList, + ppMem, phEvent); +} catch (...) { + return exceptionToResult(std::current_exception()); +} +ur_result_t urEnqueueUSMHostAllocExp( + ur_queue_handle_t hQueue, ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) try { + return hQueue->enqueueUSMHostAllocExp(pPool, size, pProperties, + numEventsInWaitList, phEventWaitList, + ppMem, phEvent); +} catch (...) { + return exceptionToResult(std::current_exception()); +} +ur_result_t urEnqueueUSMFreeExp(ur_queue_handle_t hQueue, + ur_usm_pool_handle_t pPool, void *pMem, + uint32_t numEventsInWaitList, + const ur_event_handle_t *phEventWaitList, + ur_event_handle_t *phEvent) try { + return hQueue->enqueueUSMFreeExp(pPool, pMem, numEventsInWaitList, + phEventWaitList, phEvent); +} catch (...) { + return exceptionToResult(std::current_exception()); +} ur_result_t urBindlessImagesImageCopyExp( ur_queue_handle_t hQueue, const void *pSrc, void *pDst, const ur_image_desc_t *pSrcImageDesc, const ur_image_desc_t *pDstImageDesc, diff --git a/source/adapters/level_zero/v2/queue_api.hpp b/source/adapters/level_zero/v2/queue_api.hpp index 88d812bbba..69de4bc87e 100644 --- a/source/adapters/level_zero/v2/queue_api.hpp +++ b/source/adapters/level_zero/v2/queue_api.hpp @@ -130,6 +130,24 @@ struct ur_queue_handle_t_ { bool, void *, size_t, uint32_t, const ur_event_handle_t *, ur_event_handle_t *) = 0; + virtual ur_result_t + enqueueUSMDeviceAllocExp(ur_usm_pool_handle_t, const size_t, + const ur_exp_enqueue_usm_alloc_properties_t *, + uint32_t, const ur_event_handle_t *, void **, + ur_event_handle_t *) = 0; + virtual ur_result_t + enqueueUSMSharedAllocExp(ur_usm_pool_handle_t, const size_t, + const ur_exp_enqueue_usm_alloc_properties_t *, + uint32_t, const ur_event_handle_t *, void **, + ur_event_handle_t *) = 0; + virtual ur_result_t + enqueueUSMHostAllocExp(ur_usm_pool_handle_t, const size_t, + const ur_exp_enqueue_usm_alloc_properties_t *, + uint32_t, const ur_event_handle_t *, void **, + ur_event_handle_t *) = 0; + virtual ur_result_t enqueueUSMFreeExp(ur_usm_pool_handle_t, void *, uint32_t, + const ur_event_handle_t *, + ur_event_handle_t *) = 0; virtual ur_result_t bindlessImagesImageCopyExp( const void *, void *, const ur_image_desc_t *, const ur_image_desc_t *, const ur_image_format_t *, const ur_image_format_t *, diff --git a/source/adapters/level_zero/v2/queue_immediate_in_order.cpp b/source/adapters/level_zero/v2/queue_immediate_in_order.cpp index 8da52fe6b6..6e5ee7cb65 100644 --- a/source/adapters/level_zero/v2/queue_immediate_in_order.cpp +++ b/source/adapters/level_zero/v2/queue_immediate_in_order.cpp @@ -918,6 +918,62 @@ ur_result_t ur_queue_immediate_in_order_t::enqueueWriteHostPipe( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } +ur_result_t ur_queue_immediate_in_order_t::enqueueUSMDeviceAllocExp( + ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) { + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t ur_queue_immediate_in_order_t::enqueueUSMSharedAllocExp( + ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) { + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t ur_queue_immediate_in_order_t::enqueueUSMHostAllocExp( + ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) { + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t ur_queue_immediate_in_order_t::enqueueUSMFreeExp( + ur_usm_pool_handle_t pPool, void *pMem, uint32_t numEventsInWaitList, + const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent) { + std::ignore = pPool; + std::ignore = pMem; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = phEvent; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + ur_result_t ur_queue_immediate_in_order_t::bindlessImagesImageCopyExp( const void *pSrc, void *pDst, const ur_image_desc_t *pSrcImageDesc, const ur_image_desc_t *pDstImageDesc, diff --git a/source/adapters/level_zero/v2/queue_immediate_in_order.hpp b/source/adapters/level_zero/v2/queue_immediate_in_order.hpp index 6cf8b0c51c..babfffd3b8 100644 --- a/source/adapters/level_zero/v2/queue_immediate_in_order.hpp +++ b/source/adapters/level_zero/v2/queue_immediate_in_order.hpp @@ -231,6 +231,25 @@ struct ur_queue_immediate_in_order_t : _ur_object, public ur_queue_handle_t_ { uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent) override; + ur_result_t enqueueUSMDeviceAllocExp( + ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) override; + ur_result_t enqueueUSMSharedAllocExp( + ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) override; + ur_result_t enqueueUSMHostAllocExp( + ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) override; + ur_result_t enqueueUSMFreeExp(ur_usm_pool_handle_t pPool, void *pMem, + uint32_t numEventsInWaitList, + const ur_event_handle_t *phEventWaitList, + ur_event_handle_t *phEvent) override; ur_result_t bindlessImagesImageCopyExp( const void *pSrc, void *pDst, const ur_image_desc_t *pSrcImageDesc, const ur_image_desc_t *pDstImageDesc, diff --git a/source/adapters/mock/ur_mockddi.cpp b/source/adapters/mock/ur_mockddi.cpp index bb73c1c172..cd43f4d271 100644 --- a/source/adapters/mock/ur_mockddi.cpp +++ b/source/adapters/mock/ur_mockddi.cpp @@ -7279,6 +7279,268 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMDeviceAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM device allocation + ur_event_handle_t *phEvent) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_enqueue_usm_device_alloc_exp_params_t params = { + &hQueue, &pPool, &size, &pProperties, &numEventsInWaitList, + &phEventWaitList, &ppMem, &phEvent}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urEnqueueUSMDeviceAllocExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urEnqueueUSMDeviceAllocExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + // optional output handle + if (phEvent) { + *phEvent = mock::createDummyHandle(); + } + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urEnqueueUSMDeviceAllocExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMSharedAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM shared allocation + ur_event_handle_t *phEvent) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_enqueue_usm_shared_alloc_exp_params_t params = { + &hQueue, &pPool, &size, &pProperties, &numEventsInWaitList, + &phEventWaitList, &ppMem, &phEvent}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urEnqueueUSMSharedAllocExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urEnqueueUSMSharedAllocExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + // optional output handle + if (phEvent) { + *phEvent = mock::createDummyHandle(); + } + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urEnqueueUSMSharedAllocExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMHostAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM host allocation + ur_event_handle_t *phEvent) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_enqueue_usm_host_alloc_exp_params_t params = { + &hQueue, &pPool, &size, &pProperties, &numEventsInWaitList, + &phEventWaitList, &ppMem, &phEvent}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urEnqueueUSMHostAllocExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urEnqueueUSMHostAllocExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + // optional output handle + if (phEvent) { + *phEvent = mock::createDummyHandle(); + } + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urEnqueueUSMHostAllocExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMFreeExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMFreeExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] pointer to USM memory object + void *pMem, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out][optional] return an event object that identifies the + /// asynchronous USM deallocation + ur_event_handle_t *phEvent) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_enqueue_usm_free_exp_params_t params = { + &hQueue, &pPool, &pMem, &numEventsInWaitList, &phEventWaitList, &phEvent}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urEnqueueUSMFreeExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urEnqueueUSMFreeExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + // optional output handle + if (phEvent) { + *phEvent = mock::createDummyHandle(); + } + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urEnqueueUSMFreeExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urUSMPitchedAllocExp __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( @@ -11362,6 +11624,14 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueExpProcAddrTable( pDdiTable->pfnKernelLaunchCustomExp = driver::urEnqueueKernelLaunchCustomExp; + pDdiTable->pfnUSMDeviceAllocExp = driver::urEnqueueUSMDeviceAllocExp; + + pDdiTable->pfnUSMSharedAllocExp = driver::urEnqueueUSMSharedAllocExp; + + pDdiTable->pfnUSMHostAllocExp = driver::urEnqueueUSMHostAllocExp; + + pDdiTable->pfnUSMFreeExp = driver::urEnqueueUSMFreeExp; + pDdiTable->pfnCooperativeKernelLaunchExp = driver::urEnqueueCooperativeKernelLaunchExp; diff --git a/source/adapters/native_cpu/usm.cpp b/source/adapters/native_cpu/usm.cpp index 2fe0d551a8..2bea4c08a4 100644 --- a/source/adapters/native_cpu/usm.cpp +++ b/source/adapters/native_cpu/usm.cpp @@ -155,3 +155,64 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMReleaseExp(ur_context_handle_t Context, std::ignore = HostPtr; DIE_NO_IMPLEMENTATION; } + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( + ur_queue_handle_t hQueue, ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + DIE_NO_IMPLEMENTATION; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + ur_queue_handle_t hQueue, ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + DIE_NO_IMPLEMENTATION; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( + ur_queue_handle_t hQueue, ur_usm_pool_handle_t pPool, const size_t size, + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + void **ppMem, ur_event_handle_t *phEvent) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = size; + std::ignore = pProperties; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = ppMem; + std::ignore = phEvent; + DIE_NO_IMPLEMENTATION; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMFreeExp( + ur_queue_handle_t hQueue, ur_usm_pool_handle_t pPool, void *pMem, + uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, + ur_event_handle_t *phEvent) { + std::ignore = hQueue; + std::ignore = pPool; + std::ignore = pMem; + std::ignore = numEventsInWaitList; + std::ignore = phEventWaitList; + std::ignore = phEvent; + DIE_NO_IMPLEMENTATION; +} diff --git a/source/adapters/opencl/usm.cpp b/source/adapters/opencl/usm.cpp index 7961cb76ff..221b08a5d8 100644 --- a/source/adapters/opencl/usm.cpp +++ b/source/adapters/opencl/usm.cpp @@ -728,3 +728,48 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMPoolGetInfo( [[maybe_unused]] size_t *pPropSizeRet) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( + [[maybe_unused]] ur_queue_handle_t hQueue, + [[maybe_unused]] ur_usm_pool_handle_t pPool, + [[maybe_unused]] const size_t size, + [[maybe_unused]] const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + [[maybe_unused]] uint32_t numEventsInWaitList, + [[maybe_unused]] const ur_event_handle_t *phEventWaitList, + [[maybe_unused]] void **ppMem, + [[maybe_unused]] ur_event_handle_t *phEvent) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + [[maybe_unused]] ur_queue_handle_t hQueue, + [[maybe_unused]] ur_usm_pool_handle_t pPool, + [[maybe_unused]] const size_t size, + [[maybe_unused]] const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + [[maybe_unused]] uint32_t numEventsInWaitList, + [[maybe_unused]] const ur_event_handle_t *phEventWaitList, + [[maybe_unused]] void **ppMem, + [[maybe_unused]] ur_event_handle_t *phEvent) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( + [[maybe_unused]] ur_queue_handle_t hQueue, + [[maybe_unused]] ur_usm_pool_handle_t pPool, + [[maybe_unused]] const size_t size, + [[maybe_unused]] const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + [[maybe_unused]] uint32_t numEventsInWaitList, + [[maybe_unused]] const ur_event_handle_t *phEventWaitList, + [[maybe_unused]] void **ppMem, + [[maybe_unused]] ur_event_handle_t *phEvent) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMFreeExp( + [[maybe_unused]] ur_queue_handle_t hQueue, + [[maybe_unused]] ur_usm_pool_handle_t pPool, [[maybe_unused]] void *pMem, + [[maybe_unused]] uint32_t numEventsInWaitList, + [[maybe_unused]] const ur_event_handle_t *phEventWaitList, + [[maybe_unused]] ur_event_handle_t *phEvent) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/source/common/logger/ur_sinks.hpp b/source/common/logger/ur_sinks.hpp index 8f580bc04d..fe2af9dde0 100644 --- a/source/common/logger/ur_sinks.hpp +++ b/source/common/logger/ur_sinks.hpp @@ -28,8 +28,8 @@ class Sink { void log(logger::Level level, const char *fmt, Args &&...args) { std::ostringstream buffer; if (!skip_prefix && level != logger::Level::QUIET) { - buffer << "<" << logger_name << ">" - << "[" << level_to_str(level) << "]: "; + buffer << "<" << logger_name << ">" << "[" << level_to_str(level) + << "]: "; } format(buffer, fmt, std::forward(args)...); diff --git a/source/common/stype_map_helpers.def b/source/common/stype_map_helpers.def index ec2856e60d..3b3916a310 100644 --- a/source/common/stype_map_helpers.def +++ b/source/common/stype_map_helpers.def @@ -100,5 +100,7 @@ struct stype_map : stype_map_impl struct stype_map : stype_map_impl {}; template <> +struct stype_map : stype_map_impl {}; +template <> struct stype_map : stype_map_impl {}; diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index 561b12e983..80900acccc 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -6000,6 +6000,232 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMDeviceAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM device allocation + ur_event_handle_t *phEvent) { + auto pfnUSMDeviceAllocExp = + getContext()->urDdiTable.EnqueueExp.pfnUSMDeviceAllocExp; + + if (nullptr == pfnUSMDeviceAllocExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_enqueue_usm_device_alloc_exp_params_t params = { + &hQueue, &pPool, &size, &pProperties, &numEventsInWaitList, + &phEventWaitList, &ppMem, &phEvent}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_ENQUEUE_USM_DEVICE_ALLOC_EXP, + "urEnqueueUSMDeviceAllocExp", ¶ms); + + auto &logger = getContext()->logger; + logger.info(" ---> urEnqueueUSMDeviceAllocExp\n"); + + ur_result_t result = pfnUSMDeviceAllocExp(hQueue, pPool, size, pProperties, + numEventsInWaitList, + phEventWaitList, ppMem, phEvent); + + getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_DEVICE_ALLOC_EXP, + "urEnqueueUSMDeviceAllocExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= logger::Level::INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_ENQUEUE_USM_DEVICE_ALLOC_EXP, ¶ms); + logger.info(" <--- urEnqueueUSMDeviceAllocExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMSharedAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM shared allocation + ur_event_handle_t *phEvent) { + auto pfnUSMSharedAllocExp = + getContext()->urDdiTable.EnqueueExp.pfnUSMSharedAllocExp; + + if (nullptr == pfnUSMSharedAllocExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_enqueue_usm_shared_alloc_exp_params_t params = { + &hQueue, &pPool, &size, &pProperties, &numEventsInWaitList, + &phEventWaitList, &ppMem, &phEvent}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_ENQUEUE_USM_SHARED_ALLOC_EXP, + "urEnqueueUSMSharedAllocExp", ¶ms); + + auto &logger = getContext()->logger; + logger.info(" ---> urEnqueueUSMSharedAllocExp\n"); + + ur_result_t result = pfnUSMSharedAllocExp(hQueue, pPool, size, pProperties, + numEventsInWaitList, + phEventWaitList, ppMem, phEvent); + + getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_SHARED_ALLOC_EXP, + "urEnqueueUSMSharedAllocExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= logger::Level::INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_ENQUEUE_USM_SHARED_ALLOC_EXP, ¶ms); + logger.info(" <--- urEnqueueUSMSharedAllocExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMHostAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM host allocation + ur_event_handle_t *phEvent) { + auto pfnUSMHostAllocExp = + getContext()->urDdiTable.EnqueueExp.pfnUSMHostAllocExp; + + if (nullptr == pfnUSMHostAllocExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_enqueue_usm_host_alloc_exp_params_t params = { + &hQueue, &pPool, &size, &pProperties, &numEventsInWaitList, + &phEventWaitList, &ppMem, &phEvent}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_ENQUEUE_USM_HOST_ALLOC_EXP, + "urEnqueueUSMHostAllocExp", ¶ms); + + auto &logger = getContext()->logger; + logger.info(" ---> urEnqueueUSMHostAllocExp\n"); + + ur_result_t result = + pfnUSMHostAllocExp(hQueue, pPool, size, pProperties, numEventsInWaitList, + phEventWaitList, ppMem, phEvent); + + getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_HOST_ALLOC_EXP, + "urEnqueueUSMHostAllocExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= logger::Level::INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_ENQUEUE_USM_HOST_ALLOC_EXP, ¶ms); + logger.info(" <--- urEnqueueUSMHostAllocExp({}) -> {};\n", args_str.str(), + result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMFreeExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMFreeExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] pointer to USM memory object + void *pMem, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out][optional] return an event object that identifies the + /// asynchronous USM deallocation + ur_event_handle_t *phEvent) { + auto pfnUSMFreeExp = getContext()->urDdiTable.EnqueueExp.pfnUSMFreeExp; + + if (nullptr == pfnUSMFreeExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_enqueue_usm_free_exp_params_t params = { + &hQueue, &pPool, &pMem, &numEventsInWaitList, &phEventWaitList, &phEvent}; + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_ENQUEUE_USM_FREE_EXP, "urEnqueueUSMFreeExp", ¶ms); + + auto &logger = getContext()->logger; + logger.info(" ---> urEnqueueUSMFreeExp\n"); + + ur_result_t result = pfnUSMFreeExp(hQueue, pPool, pMem, numEventsInWaitList, + phEventWaitList, phEvent); + + getContext()->notify_end(UR_FUNCTION_ENQUEUE_USM_FREE_EXP, + "urEnqueueUSMFreeExp", ¶ms, &result, instance); + + if (logger.getLevel() <= logger::Level::INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams(args_str, UR_FUNCTION_ENQUEUE_USM_FREE_EXP, + ¶ms); + logger.info(" <--- urEnqueueUSMFreeExp({}) -> {};\n", args_str.str(), + result); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urUSMPitchedAllocExp __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( @@ -9664,6 +9890,20 @@ __urdlllocal ur_result_t UR_APICALL urGetEnqueueExpProcAddrTable( pDdiTable->pfnKernelLaunchCustomExp = ur_tracing_layer::urEnqueueKernelLaunchCustomExp; + dditable.pfnUSMDeviceAllocExp = pDdiTable->pfnUSMDeviceAllocExp; + pDdiTable->pfnUSMDeviceAllocExp = + ur_tracing_layer::urEnqueueUSMDeviceAllocExp; + + dditable.pfnUSMSharedAllocExp = pDdiTable->pfnUSMSharedAllocExp; + pDdiTable->pfnUSMSharedAllocExp = + ur_tracing_layer::urEnqueueUSMSharedAllocExp; + + dditable.pfnUSMHostAllocExp = pDdiTable->pfnUSMHostAllocExp; + pDdiTable->pfnUSMHostAllocExp = ur_tracing_layer::urEnqueueUSMHostAllocExp; + + dditable.pfnUSMFreeExp = pDdiTable->pfnUSMFreeExp; + pDdiTable->pfnUSMFreeExp = ur_tracing_layer::urEnqueueUSMFreeExp; + dditable.pfnCooperativeKernelLaunchExp = pDdiTable->pfnCooperativeKernelLaunchExp; pDdiTable->pfnCooperativeKernelLaunchExp = diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index dbfd282b8a..d7fd73e456 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -495,7 +495,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo( if (pPropValue == NULL && pPropSizeRet == NULL) return UR_RESULT_ERROR_INVALID_NULL_POINTER; - if (UR_DEVICE_INFO_2D_BLOCK_ARRAY_CAPABILITIES_EXP < propName) + if (UR_DEVICE_INFO_ENQUEUE_USM_ALLOCATIONS_EXP < propName) return UR_RESULT_ERROR_INVALID_ENUMERATION; if (propSize == 0 && pPropValue != NULL) @@ -6566,6 +6566,267 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMDeviceAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM device allocation + ur_event_handle_t *phEvent) { + auto pfnUSMDeviceAllocExp = + getContext()->urDdiTable.EnqueueExp.pfnUSMDeviceAllocExp; + + if (nullptr == pfnUSMDeviceAllocExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hQueue) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (NULL == ppMem) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL != pProperties && + UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & pProperties->flags) + return UR_RESULT_ERROR_INVALID_ENUMERATION; + + if (phEventWaitList != NULL && numEventsInWaitList > 0) { + for (uint32_t i = 0; i < numEventsInWaitList; ++i) { + if (phEventWaitList[i] == NULL) { + return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST; + } + } + } + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hQueue)) { + getContext()->refCountContext->logInvalidReference(hQueue); + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(pPool)) { + getContext()->refCountContext->logInvalidReference(pPool); + } + + ur_result_t result = pfnUSMDeviceAllocExp(hQueue, pPool, size, pProperties, + numEventsInWaitList, + phEventWaitList, ppMem, phEvent); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMSharedAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM shared allocation + ur_event_handle_t *phEvent) { + auto pfnUSMSharedAllocExp = + getContext()->urDdiTable.EnqueueExp.pfnUSMSharedAllocExp; + + if (nullptr == pfnUSMSharedAllocExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hQueue) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (NULL == ppMem) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL != pProperties && + UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & pProperties->flags) + return UR_RESULT_ERROR_INVALID_ENUMERATION; + + if (phEventWaitList != NULL && numEventsInWaitList > 0) { + for (uint32_t i = 0; i < numEventsInWaitList; ++i) { + if (phEventWaitList[i] == NULL) { + return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST; + } + } + } + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hQueue)) { + getContext()->refCountContext->logInvalidReference(hQueue); + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(pPool)) { + getContext()->refCountContext->logInvalidReference(pPool); + } + + ur_result_t result = pfnUSMSharedAllocExp(hQueue, pPool, size, pProperties, + numEventsInWaitList, + phEventWaitList, ppMem, phEvent); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMHostAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM host allocation + ur_event_handle_t *phEvent) { + auto pfnUSMHostAllocExp = + getContext()->urDdiTable.EnqueueExp.pfnUSMHostAllocExp; + + if (nullptr == pfnUSMHostAllocExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hQueue) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (NULL == ppMem) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL != pProperties && + UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & pProperties->flags) + return UR_RESULT_ERROR_INVALID_ENUMERATION; + + if (phEventWaitList != NULL && numEventsInWaitList > 0) { + for (uint32_t i = 0; i < numEventsInWaitList; ++i) { + if (phEventWaitList[i] == NULL) { + return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST; + } + } + } + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hQueue)) { + getContext()->refCountContext->logInvalidReference(hQueue); + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(pPool)) { + getContext()->refCountContext->logInvalidReference(pPool); + } + + ur_result_t result = + pfnUSMHostAllocExp(hQueue, pPool, size, pProperties, numEventsInWaitList, + phEventWaitList, ppMem, phEvent); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMFreeExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMFreeExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] pointer to USM memory object + void *pMem, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out][optional] return an event object that identifies the + /// asynchronous USM deallocation + ur_event_handle_t *phEvent) { + auto pfnUSMFreeExp = getContext()->urDdiTable.EnqueueExp.pfnUSMFreeExp; + + if (nullptr == pfnUSMFreeExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hQueue) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (NULL == pMem) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (phEventWaitList != NULL && numEventsInWaitList > 0) { + for (uint32_t i = 0; i < numEventsInWaitList; ++i) { + if (phEventWaitList[i] == NULL) { + return UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST; + } + } + } + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hQueue)) { + getContext()->refCountContext->logInvalidReference(hQueue); + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(pPool)) { + getContext()->refCountContext->logInvalidReference(pPool); + } + + ur_result_t result = pfnUSMFreeExp(hQueue, pPool, pMem, numEventsInWaitList, + phEventWaitList, phEvent); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urUSMPitchedAllocExp __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( @@ -10289,6 +10550,20 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueExpProcAddrTable( pDdiTable->pfnKernelLaunchCustomExp = ur_validation_layer::urEnqueueKernelLaunchCustomExp; + dditable.pfnUSMDeviceAllocExp = pDdiTable->pfnUSMDeviceAllocExp; + pDdiTable->pfnUSMDeviceAllocExp = + ur_validation_layer::urEnqueueUSMDeviceAllocExp; + + dditable.pfnUSMSharedAllocExp = pDdiTable->pfnUSMSharedAllocExp; + pDdiTable->pfnUSMSharedAllocExp = + ur_validation_layer::urEnqueueUSMSharedAllocExp; + + dditable.pfnUSMHostAllocExp = pDdiTable->pfnUSMHostAllocExp; + pDdiTable->pfnUSMHostAllocExp = ur_validation_layer::urEnqueueUSMHostAllocExp; + + dditable.pfnUSMFreeExp = pDdiTable->pfnUSMFreeExp; + pDdiTable->pfnUSMFreeExp = ur_validation_layer::urEnqueueUSMFreeExp; + dditable.pfnCooperativeKernelLaunchExp = pDdiTable->pfnCooperativeKernelLaunchExp; pDdiTable->pfnCooperativeKernelLaunchExp = diff --git a/source/loader/loader.def.in b/source/loader/loader.def.in index e7b6b5993d..cf017aaec0 100644 --- a/source/loader/loader.def.in +++ b/source/loader/loader.def.in @@ -88,11 +88,15 @@ EXPORTS urEnqueueReadHostPipe urEnqueueTimestampRecordingExp urEnqueueUSMAdvise + urEnqueueUSMDeviceAllocExp urEnqueueUSMFill urEnqueueUSMFill2D + urEnqueueUSMFreeExp + urEnqueueUSMHostAllocExp urEnqueueUSMMemcpy urEnqueueUSMMemcpy2D urEnqueueUSMPrefetch + urEnqueueUSMSharedAllocExp urEnqueueWriteHostPipe urEventCreateWithNativeHandle urEventGetInfo @@ -288,11 +292,15 @@ EXPORTS urPrintEnqueueReadHostPipeParams urPrintEnqueueTimestampRecordingExpParams urPrintEnqueueUsmAdviseParams + urPrintEnqueueUsmDeviceAllocExpParams urPrintEnqueueUsmFillParams urPrintEnqueueUsmFill_2dParams + urPrintEnqueueUsmFreeExpParams + urPrintEnqueueUsmHostAllocExpParams urPrintEnqueueUsmMemcpyParams urPrintEnqueueUsmMemcpy_2dParams urPrintEnqueueUsmPrefetchParams + urPrintEnqueueUsmSharedAllocExpParams urPrintEnqueueWriteHostPipeParams urPrintEventCreateWithNativeHandleParams urPrintEventGetInfoParams @@ -318,6 +326,8 @@ EXPORTS urPrintExpEnqueueExtProperties urPrintExpEnqueueNativeCommandFlags urPrintExpEnqueueNativeCommandProperties + urPrintExpEnqueueUsmAllocFlags + urPrintExpEnqueueUsmAllocProperties urPrintExpExternalMemDesc urPrintExpExternalMemType urPrintExpExternalSemaphoreDesc diff --git a/source/loader/loader.map.in b/source/loader/loader.map.in index e9017e01cf..c53a964980 100644 --- a/source/loader/loader.map.in +++ b/source/loader/loader.map.in @@ -88,11 +88,15 @@ urEnqueueReadHostPipe; urEnqueueTimestampRecordingExp; urEnqueueUSMAdvise; + urEnqueueUSMDeviceAllocExp; urEnqueueUSMFill; urEnqueueUSMFill2D; + urEnqueueUSMFreeExp; + urEnqueueUSMHostAllocExp; urEnqueueUSMMemcpy; urEnqueueUSMMemcpy2D; urEnqueueUSMPrefetch; + urEnqueueUSMSharedAllocExp; urEnqueueWriteHostPipe; urEventCreateWithNativeHandle; urEventGetInfo; @@ -288,11 +292,15 @@ urPrintEnqueueReadHostPipeParams; urPrintEnqueueTimestampRecordingExpParams; urPrintEnqueueUsmAdviseParams; + urPrintEnqueueUsmDeviceAllocExpParams; urPrintEnqueueUsmFillParams; urPrintEnqueueUsmFill_2dParams; + urPrintEnqueueUsmFreeExpParams; + urPrintEnqueueUsmHostAllocExpParams; urPrintEnqueueUsmMemcpyParams; urPrintEnqueueUsmMemcpy_2dParams; urPrintEnqueueUsmPrefetchParams; + urPrintEnqueueUsmSharedAllocExpParams; urPrintEnqueueWriteHostPipeParams; urPrintEventCreateWithNativeHandleParams; urPrintEventGetInfoParams; @@ -318,6 +326,8 @@ urPrintExpEnqueueExtProperties; urPrintExpEnqueueNativeCommandFlags; urPrintExpEnqueueNativeCommandProperties; + urPrintExpEnqueueUsmAllocFlags; + urPrintExpEnqueueUsmAllocProperties; urPrintExpExternalMemDesc; urPrintExpExternalMemType; urPrintExpExternalSemaphoreDesc; diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 450f5f9364..cae366552f 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -6162,6 +6162,276 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMDeviceAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM device allocation + ur_event_handle_t *phEvent) { + ur_result_t result = UR_RESULT_SUCCESS; + + [[maybe_unused]] auto context = getContext(); + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hQueue)->dditable; + auto pfnUSMDeviceAllocExp = dditable->ur.EnqueueExp.pfnUSMDeviceAllocExp; + if (nullptr == pfnUSMDeviceAllocExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to platform handle + hQueue = reinterpret_cast(hQueue)->handle; + + // convert loader handle to platform handle + pPool = (pPool) ? reinterpret_cast(pPool)->handle + : nullptr; + + // convert loader handles to platform handles + auto phEventWaitListLocal = + std::vector(numEventsInWaitList); + for (size_t i = 0; i < numEventsInWaitList; ++i) + phEventWaitListLocal[i] = + reinterpret_cast(phEventWaitList[i])->handle; + + // forward to device-platform + result = pfnUSMDeviceAllocExp(hQueue, pPool, size, pProperties, + numEventsInWaitList, + phEventWaitListLocal.data(), ppMem, phEvent); + + // In the event of ERROR_ADAPTER_SPECIFIC we should still attempt to wrap any + // output handles below. + if (UR_RESULT_SUCCESS != result && UR_RESULT_ERROR_ADAPTER_SPECIFIC != result) + return result; + try { + // convert platform handle to loader handle + if (nullptr != phEvent) + *phEvent = reinterpret_cast( + context->factories.ur_event_factory.getInstance(*phEvent, dditable)); + } catch (std::bad_alloc &) { + result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMSharedAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM shared allocation + ur_event_handle_t *phEvent) { + ur_result_t result = UR_RESULT_SUCCESS; + + [[maybe_unused]] auto context = getContext(); + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hQueue)->dditable; + auto pfnUSMSharedAllocExp = dditable->ur.EnqueueExp.pfnUSMSharedAllocExp; + if (nullptr == pfnUSMSharedAllocExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to platform handle + hQueue = reinterpret_cast(hQueue)->handle; + + // convert loader handle to platform handle + pPool = (pPool) ? reinterpret_cast(pPool)->handle + : nullptr; + + // convert loader handles to platform handles + auto phEventWaitListLocal = + std::vector(numEventsInWaitList); + for (size_t i = 0; i < numEventsInWaitList; ++i) + phEventWaitListLocal[i] = + reinterpret_cast(phEventWaitList[i])->handle; + + // forward to device-platform + result = pfnUSMSharedAllocExp(hQueue, pPool, size, pProperties, + numEventsInWaitList, + phEventWaitListLocal.data(), ppMem, phEvent); + + // In the event of ERROR_ADAPTER_SPECIFIC we should still attempt to wrap any + // output handles below. + if (UR_RESULT_SUCCESS != result && UR_RESULT_ERROR_ADAPTER_SPECIFIC != result) + return result; + try { + // convert platform handle to loader handle + if (nullptr != phEvent) + *phEvent = reinterpret_cast( + context->factories.ur_event_factory.getInstance(*phEvent, dditable)); + } catch (std::bad_alloc &) { + result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMHostAllocExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM host allocation + ur_event_handle_t *phEvent) { + ur_result_t result = UR_RESULT_SUCCESS; + + [[maybe_unused]] auto context = getContext(); + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hQueue)->dditable; + auto pfnUSMHostAllocExp = dditable->ur.EnqueueExp.pfnUSMHostAllocExp; + if (nullptr == pfnUSMHostAllocExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to platform handle + hQueue = reinterpret_cast(hQueue)->handle; + + // convert loader handle to platform handle + pPool = (pPool) ? reinterpret_cast(pPool)->handle + : nullptr; + + // convert loader handles to platform handles + auto phEventWaitListLocal = + std::vector(numEventsInWaitList); + for (size_t i = 0; i < numEventsInWaitList; ++i) + phEventWaitListLocal[i] = + reinterpret_cast(phEventWaitList[i])->handle; + + // forward to device-platform + result = + pfnUSMHostAllocExp(hQueue, pPool, size, pProperties, numEventsInWaitList, + phEventWaitListLocal.data(), ppMem, phEvent); + + // In the event of ERROR_ADAPTER_SPECIFIC we should still attempt to wrap any + // output handles below. + if (UR_RESULT_SUCCESS != result && UR_RESULT_ERROR_ADAPTER_SPECIFIC != result) + return result; + try { + // convert platform handle to loader handle + if (nullptr != phEvent) + *phEvent = reinterpret_cast( + context->factories.ur_event_factory.getInstance(*phEvent, dditable)); + } catch (std::bad_alloc &) { + result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMFreeExp +__urdlllocal ur_result_t UR_APICALL urEnqueueUSMFreeExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] pointer to USM memory object + void *pMem, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out][optional] return an event object that identifies the + /// asynchronous USM deallocation + ur_event_handle_t *phEvent) { + ur_result_t result = UR_RESULT_SUCCESS; + + [[maybe_unused]] auto context = getContext(); + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hQueue)->dditable; + auto pfnUSMFreeExp = dditable->ur.EnqueueExp.pfnUSMFreeExp; + if (nullptr == pfnUSMFreeExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to platform handle + hQueue = reinterpret_cast(hQueue)->handle; + + // convert loader handle to platform handle + pPool = (pPool) ? reinterpret_cast(pPool)->handle + : nullptr; + + // convert loader handles to platform handles + auto phEventWaitListLocal = + std::vector(numEventsInWaitList); + for (size_t i = 0; i < numEventsInWaitList; ++i) + phEventWaitListLocal[i] = + reinterpret_cast(phEventWaitList[i])->handle; + + // forward to device-platform + result = pfnUSMFreeExp(hQueue, pPool, pMem, numEventsInWaitList, + phEventWaitListLocal.data(), phEvent); + + // In the event of ERROR_ADAPTER_SPECIFIC we should still attempt to wrap any + // output handles below. + if (UR_RESULT_SUCCESS != result && UR_RESULT_ERROR_ADAPTER_SPECIFIC != result) + return result; + try { + // convert platform handle to loader handle + if (nullptr != phEvent) + *phEvent = reinterpret_cast( + context->factories.ur_event_factory.getInstance(*phEvent, dditable)); + } catch (std::bad_alloc &) { + result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urUSMPitchedAllocExp __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( @@ -9795,6 +10065,10 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueExpProcAddrTable( // return pointers to loader's DDIs pDdiTable->pfnKernelLaunchCustomExp = ur_loader::urEnqueueKernelLaunchCustomExp; + pDdiTable->pfnUSMDeviceAllocExp = ur_loader::urEnqueueUSMDeviceAllocExp; + pDdiTable->pfnUSMSharedAllocExp = ur_loader::urEnqueueUSMSharedAllocExp; + pDdiTable->pfnUSMHostAllocExp = ur_loader::urEnqueueUSMHostAllocExp; + pDdiTable->pfnUSMFreeExp = ur_loader::urEnqueueUSMFreeExp; pDdiTable->pfnCooperativeKernelLaunchExp = ur_loader::urEnqueueCooperativeKernelLaunchExp; pDdiTable->pfnTimestampRecordingExp = diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 031b4f3989..2080689465 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -868,7 +868,7 @@ ur_result_t UR_APICALL urDeviceGetSelected( /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION -/// + `::UR_DEVICE_INFO_2D_BLOCK_ARRAY_CAPABILITIES_EXP < propName` +/// + `::UR_DEVICE_INFO_ENQUEUE_USM_ALLOCATIONS_EXP < propName` /// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION /// + If `propName` is not supported by the adapter. /// - ::UR_RESULT_ERROR_INVALID_SIZE @@ -6694,6 +6694,203 @@ ur_result_t UR_APICALL urEnqueueWriteHostPipe( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM device allocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & +/// pProperties->flags` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM device allocation + ur_event_handle_t *phEvent) try { + auto pfnUSMDeviceAllocExp = + ur_lib::getContext()->urDdiTable.EnqueueExp.pfnUSMDeviceAllocExp; + if (nullptr == pfnUSMDeviceAllocExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnUSMDeviceAllocExp(hQueue, pPool, size, pProperties, + numEventsInWaitList, phEventWaitList, ppMem, + phEvent); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM shared allocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & +/// pProperties->flags` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM shared allocation + ur_event_handle_t *phEvent) try { + auto pfnUSMSharedAllocExp = + ur_lib::getContext()->urDdiTable.EnqueueExp.pfnUSMSharedAllocExp; + if (nullptr == pfnUSMSharedAllocExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnUSMSharedAllocExp(hQueue, pPool, size, pProperties, + numEventsInWaitList, phEventWaitList, ppMem, + phEvent); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM host allocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & +/// pProperties->flags` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM host allocation + ur_event_handle_t *phEvent) try { + auto pfnUSMHostAllocExp = + ur_lib::getContext()->urDdiTable.EnqueueExp.pfnUSMHostAllocExp; + if (nullptr == pfnUSMHostAllocExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnUSMHostAllocExp(hQueue, pPool, size, pProperties, + numEventsInWaitList, phEventWaitList, ppMem, + phEvent); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM deallocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +ur_result_t UR_APICALL urEnqueueUSMFreeExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] pointer to USM memory object + void *pMem, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out][optional] return an event object that identifies the + /// asynchronous USM deallocation + ur_event_handle_t *phEvent) try { + auto pfnUSMFreeExp = + ur_lib::getContext()->urDdiTable.EnqueueExp.pfnUSMFreeExp; + if (nullptr == pfnUSMFreeExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnUSMFreeExp(hQueue, pPool, pMem, numEventsInWaitList, + phEventWaitList, phEvent); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief USM allocate pitched memory /// diff --git a/source/loader/ur_print.cpp b/source/loader/ur_print.cpp index 824a6a161a..964d1b41bf 100644 --- a/source/loader/ur_print.cpp +++ b/source/loader/ur_print.cpp @@ -897,6 +897,23 @@ ur_result_t urPrintExpDevice_2dBlockArrayCapabilityFlags( return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t +urPrintExpEnqueueUsmAllocFlags(enum ur_exp_enqueue_usm_alloc_flag_t value, + char *buffer, const size_t buff_size, + size_t *out_size) { + std::stringstream ss; + ss << value; + return str_copy(&ss, buffer, buff_size, out_size); +} + +ur_result_t urPrintExpEnqueueUsmAllocProperties( + const struct ur_exp_enqueue_usm_alloc_properties_t params, char *buffer, + const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + ur_result_t urPrintExpImageCopyFlags(enum ur_exp_image_copy_flag_t value, char *buffer, const size_t buff_size, size_t *out_size) { @@ -1788,6 +1805,38 @@ ur_result_t urPrintEnqueueEventsWaitWithBarrierExtParams( return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t urPrintEnqueueUsmDeviceAllocExpParams( + const struct ur_enqueue_usm_device_alloc_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + +ur_result_t urPrintEnqueueUsmSharedAllocExpParams( + const struct ur_enqueue_usm_shared_alloc_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + +ur_result_t urPrintEnqueueUsmHostAllocExpParams( + const struct ur_enqueue_usm_host_alloc_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + +ur_result_t urPrintEnqueueUsmFreeExpParams( + const struct ur_enqueue_usm_free_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + ur_result_t urPrintEnqueueCooperativeKernelLaunchExpParams( const struct ur_enqueue_cooperative_kernel_launch_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size) { diff --git a/source/ur_api.cpp b/source/ur_api.cpp index b9d0c3c390..633d24dfa6 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -782,7 +782,7 @@ ur_result_t UR_APICALL urDeviceGetSelected( /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION -/// + `::UR_DEVICE_INFO_2D_BLOCK_ARRAY_CAPABILITIES_EXP < propName` +/// + `::UR_DEVICE_INFO_ENQUEUE_USM_ALLOCATIONS_EXP < propName` /// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION /// + If `propName` is not supported by the adapter. /// - ::UR_RESULT_ERROR_INVALID_SIZE @@ -5882,6 +5882,172 @@ ur_result_t UR_APICALL urEnqueueWriteHostPipe( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM device allocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & +/// pProperties->flags` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +ur_result_t UR_APICALL urEnqueueUSMDeviceAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM device allocation + ur_event_handle_t *phEvent) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM shared allocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & +/// pProperties->flags` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM shared allocation + ur_event_handle_t *phEvent) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM host allocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_USM_ALLOC_FLAGS_MASK & +/// pProperties->flags` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == ppMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +ur_result_t UR_APICALL urEnqueueUSMHostAllocExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] minimum size in bytes of the USM memory object to be allocated + const size_t size, + /// [in][optional] pointer to the enqueue asynchronous USM allocation + /// properties + const ur_exp_enqueue_usm_alloc_properties_t *pProperties, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out] pointer to USM memory object + void **ppMem, + /// [out][optional] return an event object that identifies the + /// asynchronous USM host allocation + ur_event_handle_t *phEvent) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an asynchronous USM deallocation +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_DEVICE_LOST +/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC +/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `NULL == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pMem` +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST +ur_result_t UR_APICALL urEnqueueUSMFreeExp( + /// [in] handle of the queue object + ur_queue_handle_t hQueue, + /// [in][optional] handle of the USM memory pool + ur_usm_pool_handle_t pPool, + /// [in] pointer to USM memory object + void *pMem, + /// [in] size of the event wait list + uint32_t numEventsInWaitList, + /// [in][optional][range(0, numEventsInWaitList)] pointer to a list of + /// events that must be complete before the kernel execution. + /// If nullptr, the numEventsInWaitList must be 0, indicating no wait + /// events. + const ur_event_handle_t *phEventWaitList, + /// [out][optional] return an event object that identifies the + /// asynchronous USM deallocation + ur_event_handle_t *phEvent) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief USM allocate pitched memory /// diff --git a/test/conformance/testing/include/uur/utils.h b/test/conformance/testing/include/uur/utils.h index bb0b79a404..50183af37a 100644 --- a/test/conformance/testing/include/uur/utils.h +++ b/test/conformance/testing/include/uur/utils.h @@ -489,10 +489,10 @@ getDriverVersion(ur_device_handle_t hDevice) { if (major < minMajor || (major == minMajor && minor < minMinor) || \ (major == minMajor && minor == minMinor && patch < minPatch)) { \ GTEST_SKIP() << "Skipping test because driver version is too old for " \ - << adapterName << ". " \ - << "Driver version: " << major << "." << minor << "." \ - << patch << " Minimum required version: " << minMajor \ - << "." << minMinor << "." << minPatch; \ + << adapterName << ". " << "Driver version: " << major \ + << "." << minor << "." << patch \ + << " Minimum required version: " << minMajor << "." \ + << minMinor << "." << minPatch; \ } \ } \ } while (0) diff --git a/tools/urinfo/urinfo.cpp b/tools/urinfo/urinfo.cpp index c86d166034..293ff2bce0 100644 --- a/tools/urinfo/urinfo.cpp +++ b/tools/urinfo/urinfo.cpp @@ -145,15 +145,15 @@ devices which are currently visible in the local execution environment. << "]"; } else { std::cout << "[adapter(" << adapterIndex << "," << adapter_backend - << "):" - << "platform(" << platformIndex << "):" - << "device(" << deviceIndex << "," << device_type << ")]"; + << "):" << "platform(" << platformIndex + << "):" << "device(" << deviceIndex << "," << device_type + << ")]"; } std::cout << " " << urinfo::getPlatformName(platform) << ", " << urinfo::getDeviceName(device) << " " - << urinfo::getDeviceVersion(device) << " " - << "[" << urinfo::getDeviceDriverVersion(device) << "]\n"; + << urinfo::getDeviceVersion(device) << " " << "[" + << urinfo::getDeviceDriverVersion(device) << "]\n"; adapter_device_id++; } @@ -163,16 +163,14 @@ devices which are currently visible in the local execution environment. void printDetail() { std::cout << "\n" - << "[loader]:" - << "\n"; + << "[loader]:" << "\n"; urinfo::printLoaderConfigInfos(loaderConfig); for (size_t adapterIndex = 0; adapterIndex < adapters.size(); adapterIndex++) { auto adapter = adapters[adapterIndex]; std::cout << "\n" - << "[adapter(" << adapterIndex << ")]:" - << "\n"; + << "[adapter(" << adapterIndex << ")]:" << "\n"; urinfo::printAdapterInfos(adapter); size_t numPlatforms = adapterPlatformsMap[adapter].size(); @@ -180,19 +178,17 @@ devices which are currently visible in the local execution environment. platformIndex++) { auto platform = adapterPlatformsMap[adapter][platformIndex]; std::cout << "\n" - << "[adapter(" << adapterIndex << ")," - << "platform(" << platformIndex << ")]:" - << "\n"; + << "[adapter(" << adapterIndex << ")," << "platform(" + << platformIndex << ")]:" << "\n"; urinfo::printPlatformInfos(platform); size_t numDevices = platformDevicesMap[platform].size(); for (size_t deviceI = 0; deviceI < numDevices; deviceI++) { auto device = platformDevicesMap[platform][deviceI]; std::cout << "\n" - << "[adapter(" << adapterIndex << ")," - << "platform(" << platformIndex << ")," - << "device(" << deviceI << ")]:" - << "\n"; + << "[adapter(" << adapterIndex << ")," << "platform(" + << platformIndex << ")," << "device(" << deviceI + << ")]:" << "\n"; urinfo::printDeviceInfos(device); } } diff --git a/tools/urinfo/urinfo.hpp b/tools/urinfo/urinfo.hpp index d01245138f..d7e4e63021 100644 --- a/tools/urinfo/urinfo.hpp +++ b/tools/urinfo/urinfo.hpp @@ -420,5 +420,8 @@ inline void printDeviceInfos(ur_device_handle_t hDevice, std::cout << prefix; printDeviceInfo( hDevice, UR_DEVICE_INFO_2D_BLOCK_ARRAY_CAPABILITIES_EXP); + std::cout << prefix; + printDeviceInfo(hDevice, + UR_DEVICE_INFO_ENQUEUE_USM_ALLOCATIONS_EXP); } } // namespace urinfo