diff --git a/include/ur_api.h b/include/ur_api.h index 3662f3bbc5..2038f6e1d0 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -234,6 +234,11 @@ typedef enum ur_function_t { UR_FUNCTION_TENSOR_MAP_ENCODE_IM_2_COL_EXP = 247, ///< Enumerator for ::urTensorMapEncodeIm2ColExp UR_FUNCTION_TENSOR_MAP_ENCODE_TILED_EXP = 248, ///< Enumerator for ::urTensorMapEncodeTiledExp UR_FUNCTION_PHYSICAL_MEM_GET_INFO = 249, ///< Enumerator for ::urPhysicalMemGetInfo + UR_FUNCTION_ENQUEUE_USM_DEVICE_ALLOC_EXP = 250, ///< Enumerator for ::urEnqueueUSMDeviceAllocExp + UR_FUNCTION_ENQUEUE_USM_SHARED_ALLOC_EXP = 251, ///< Enumerator for ::urEnqueueUSMSharedAllocExp + UR_FUNCTION_ENQUEUE_USM_HOST_ALLOC_EXP = 252, ///< Enumerator for ::urEnqueueUSMHostAllocExp + UR_FUNCTION_ENQUEUE_USM_FREE_EXP = 253, ///< Enumerator for ::urEnqueueUSMFreeExp + UR_FUNCTION_USM_POOL_CREATE_EXP = 254, ///< Enumerator for ::urUSMPoolCreateExp /// @cond UR_FUNCTION_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -292,6 +297,7 @@ typedef enum ur_structure_type_t { UR_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES = 0x2006, ///< ::ur_exp_sampler_cubemap_properties_t UR_STRUCTURE_TYPE_EXP_IMAGE_COPY_REGION = 0x2007, ///< ::ur_exp_image_copy_region_t UR_STRUCTURE_TYPE_EXP_ENQUEUE_NATIVE_COMMAND_PROPERTIES = 0x3000, ///< ::ur_exp_enqueue_native_command_properties_t + UR_STRUCTURE_TYPE_EXP_ENQUEUE_USM_ALLOC_PROPERTIES = 0x3001, ///< ::ur_exp_async_usm_alloc_properties_t UR_STRUCTURE_TYPE_EXP_ENQUEUE_EXT_PROPERTIES = 0x4000, ///< ::ur_exp_enqueue_ext_properties_t /// @cond UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff @@ -1714,6 +1720,8 @@ typedef enum ur_device_info_t { UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP = 0x2021, ///< [::ur_bool_t] returns true if the device supports low-power events. UR_DEVICE_INFO_2D_BLOCK_ARRAY_CAPABILITIES_EXP = 0x2022, ///< [::ur_exp_device_2d_block_array_capability_flags_t] return a bit-field ///< of Intel GPU 2D block array capabilities + UR_DEVICE_INFO_ASYNC_USM_ALLOCATIONS_EXP = 0x2024, ///< [::ur_bool_t] returns true if the device supports enqueueing of native + ///< work /// @cond UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -1739,7 +1747,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_ASYNC_USM_ALLOCATIONS_EXP < propName` /// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION /// + If `propName` is not supported by the adapter. /// - ::UR_RESULT_ERROR_INVALID_SIZE @@ -3365,15 +3373,16 @@ typedef enum ur_usm_device_mem_flag_t { /// @brief USM memory property flags typedef uint32_t ur_usm_pool_flags_t; typedef enum ur_usm_pool_flag_t { - UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK = UR_BIT(0), ///< All coarse-grain allocations (allocations from the driver) will be - ///< zero-initialized. + UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK = UR_BIT(0), ///< All coarse-grain allocations (allocations from the driver) will be + ///< zero-initialized. + UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP = UR_BIT(1), ///< Use the native memory pool API /// @cond UR_USM_POOL_FLAG_FORCE_UINT32 = 0x7fffffff /// @endcond } ur_usm_pool_flag_t; /// @brief Bit Mask for validating ur_usm_pool_flags_t -#define UR_USM_POOL_FLAGS_MASK 0xfffffffe +#define UR_USM_POOL_FLAGS_MASK 0xfffffffc /////////////////////////////////////////////////////////////////////////////// /// @brief USM allocation type @@ -5859,6 +5868,10 @@ typedef enum ur_command_t { UR_COMMAND_EXTERNAL_SEMAPHORE_SIGNAL_EXP = 0x2001, ///< Event created by ::urBindlessImagesSignalExternalSemaphoreExp UR_COMMAND_TIMESTAMP_RECORDING_EXP = 0x2002, ///< Event created by ::urEnqueueTimestampRecordingExp UR_COMMAND_ENQUEUE_NATIVE_EXP = 0x2004, ///< Event created by ::urEnqueueNativeCommandExp + UR_COMMAND_ENQUEUE_USM_DEVICE_ALLOC_EXP = 0x2008, ///< Event created by ::urEnqueueDeviceAllocExp + UR_COMMAND_ENQUEUE_USM_SHARED_ALLOC_EXP = 0x2010, ///< Event created by ::urEnqueueSharedAllocExp + UR_COMMAND_ENQUEUE_USM_HOST_ALLOC_EXP = 0x2011, ///< Event created by ::urEnqueueHostAllocExp + UR_COMMAND_ENQUEUE_USM_FREE_EXP = 0x2012, ///< Event created by ::urEnqueueFreeExp /// @cond UR_COMMAND_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -7507,6 +7520,187 @@ typedef enum ur_exp_device_2d_block_array_capability_flag_t { /// @brief Bit Mask for validating 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 asynchronous allocations +#if !defined(__GNUC__) +#pragma region async_alloc_(experimental) +#endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Async alloc properties +typedef uint32_t ur_exp_async_usm_alloc_flags_t; +typedef enum ur_exp_async_usm_alloc_flag_t { + UR_EXP_ASYNC_USM_ALLOC_FLAG_TBD = UR_BIT(0), ///< reserved for future use. + /// @cond + UR_EXP_ASYNC_USM_ALLOC_FLAG_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_exp_async_usm_alloc_flag_t; +/// @brief Bit Mask for validating ur_exp_async_usm_alloc_flags_t +#define UR_EXP_ASYNC_USM_ALLOC_FLAGS_MASK 0xfffffffe + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Async alloc properties +typedef struct ur_exp_async_usm_alloc_properties_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_ASYNC_USM_ALLOC_PROPERTIES + void *pNext; ///< [in,out][optional] pointer to extension-specific structure + ur_exp_async_usm_alloc_flags_t flags; ///< [in] async alloc flags + +} ur_exp_async_usm_alloc_properties_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an async 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t *pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an async 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t *pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an async 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t *pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an async 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_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + 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 async alloc +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create USM memory pool with desired properties. +/// +/// @details +/// - Create a memory pool associated with a single device. +/// - See also ::urUSMPoolCrearte and ::ur_usm_pool_limits_desc_t. +/// +/// @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 == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pPoolDesc` +/// + `NULL == ppPool` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_USM_POOL_FLAGS_MASK & pPoolDesc->flags` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If any device associated with `hContext` reports `false` for ::UR_DEVICE_INFO_USM_POOL_SUPPORT +UR_APIEXPORT ur_result_t UR_APICALL +urUSMPoolCreateExp( + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_usm_pool_desc_t *pPoolDesc, ///< [in] pointer to USM pool descriptor. Can be chained with + ///< ::ur_usm_pool_limits_desc_t + ur_usm_pool_handle_t *ppPool ///< [out] pointer to USM memory pool +); + #if !defined(__GNUC__) #pragma endregion #endif @@ -11857,6 +12051,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_async_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_async_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_async_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; @@ -11901,6 +12153,150 @@ typedef struct ur_enqueue_native_command_exp_params_t { ur_event_handle_t **pphEvent; } ur_enqueue_native_command_exp_params_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMHostAlloc +/// @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_usm_host_alloc_params_t { + ur_context_handle_t *phContext; + const ur_usm_desc_t **ppUSMDesc; + ur_usm_pool_handle_t *ppool; + size_t *psize; + void ***pppMem; +} ur_usm_host_alloc_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMDeviceAlloc +/// @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_usm_device_alloc_params_t { + ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; + const ur_usm_desc_t **ppUSMDesc; + ur_usm_pool_handle_t *ppool; + size_t *psize; + void ***pppMem; +} ur_usm_device_alloc_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMSharedAlloc +/// @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_usm_shared_alloc_params_t { + ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; + const ur_usm_desc_t **ppUSMDesc; + ur_usm_pool_handle_t *ppool; + size_t *psize; + void ***pppMem; +} ur_usm_shared_alloc_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMFree +/// @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_usm_free_params_t { + ur_context_handle_t *phContext; + void **ppMem; +} ur_usm_free_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMGetMemAllocInfo +/// @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_usm_get_mem_alloc_info_params_t { + ur_context_handle_t *phContext; + const void **ppMem; + ur_usm_alloc_info_t *ppropName; + size_t *ppropSize; + void **ppPropValue; + size_t **ppPropSizeRet; +} ur_usm_get_mem_alloc_info_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMPoolCreate +/// @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_usm_pool_create_params_t { + ur_context_handle_t *phContext; + ur_usm_pool_desc_t **ppPoolDesc; + ur_usm_pool_handle_t **pppPool; +} ur_usm_pool_create_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMPoolRetain +/// @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_usm_pool_retain_params_t { + ur_usm_pool_handle_t *ppPool; +} ur_usm_pool_retain_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMPoolRelease +/// @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_usm_pool_release_params_t { + ur_usm_pool_handle_t *ppPool; +} ur_usm_pool_release_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMPoolGetInfo +/// @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_usm_pool_get_info_params_t { + ur_usm_pool_handle_t *phPool; + ur_usm_pool_info_t *ppropName; + size_t *ppropSize; + void **ppPropValue; + size_t **ppPropSizeRet; +} ur_usm_pool_get_info_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMPoolCreateExp +/// @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_usm_pool_create_exp_params_t { + ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; + ur_usm_pool_desc_t **ppPoolDesc; + ur_usm_pool_handle_t **pppPool; +} ur_usm_pool_create_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMPitchedAllocExp +/// @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_usm_pitched_alloc_exp_params_t { + ur_context_handle_t *phContext; + ur_device_handle_t *phDevice; + const ur_usm_desc_t **ppUSMDesc; + ur_usm_pool_handle_t *ppool; + size_t *pwidthInBytes; + size_t *pheight; + size_t *pelementSizeBytes; + void ***pppMem; + size_t **ppResultPitch; +} ur_usm_pitched_alloc_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMImportExp +/// @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_usm_import_exp_params_t { + ur_context_handle_t *phContext; + void **ppMem; + size_t *psize; +} ur_usm_import_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urUSMReleaseExp +/// @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_usm_release_exp_params_t { + ur_context_handle_t *phContext; + void **ppMem; +} ur_usm_release_exp_params_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urBindlessImagesUnsampledImageHandleDestroyExp /// @details Each entry is a pointer to the parameter passed to the function; @@ -12122,139 +12518,6 @@ typedef struct ur_bindless_images_signal_external_semaphore_exp_params_t { ur_event_handle_t **pphEvent; } ur_bindless_images_signal_external_semaphore_exp_params_t; -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMHostAlloc -/// @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_usm_host_alloc_params_t { - ur_context_handle_t *phContext; - const ur_usm_desc_t **ppUSMDesc; - ur_usm_pool_handle_t *ppool; - size_t *psize; - void ***pppMem; -} ur_usm_host_alloc_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMDeviceAlloc -/// @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_usm_device_alloc_params_t { - ur_context_handle_t *phContext; - ur_device_handle_t *phDevice; - const ur_usm_desc_t **ppUSMDesc; - ur_usm_pool_handle_t *ppool; - size_t *psize; - void ***pppMem; -} ur_usm_device_alloc_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMSharedAlloc -/// @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_usm_shared_alloc_params_t { - ur_context_handle_t *phContext; - ur_device_handle_t *phDevice; - const ur_usm_desc_t **ppUSMDesc; - ur_usm_pool_handle_t *ppool; - size_t *psize; - void ***pppMem; -} ur_usm_shared_alloc_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMFree -/// @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_usm_free_params_t { - ur_context_handle_t *phContext; - void **ppMem; -} ur_usm_free_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMGetMemAllocInfo -/// @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_usm_get_mem_alloc_info_params_t { - ur_context_handle_t *phContext; - const void **ppMem; - ur_usm_alloc_info_t *ppropName; - size_t *ppropSize; - void **ppPropValue; - size_t **ppPropSizeRet; -} ur_usm_get_mem_alloc_info_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMPoolCreate -/// @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_usm_pool_create_params_t { - ur_context_handle_t *phContext; - ur_usm_pool_desc_t **ppPoolDesc; - ur_usm_pool_handle_t **pppPool; -} ur_usm_pool_create_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMPoolRetain -/// @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_usm_pool_retain_params_t { - ur_usm_pool_handle_t *ppPool; -} ur_usm_pool_retain_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMPoolRelease -/// @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_usm_pool_release_params_t { - ur_usm_pool_handle_t *ppPool; -} ur_usm_pool_release_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMPoolGetInfo -/// @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_usm_pool_get_info_params_t { - ur_usm_pool_handle_t *phPool; - ur_usm_pool_info_t *ppropName; - size_t *ppropSize; - void **ppPropValue; - size_t **ppPropSizeRet; -} ur_usm_pool_get_info_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMPitchedAllocExp -/// @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_usm_pitched_alloc_exp_params_t { - ur_context_handle_t *phContext; - ur_device_handle_t *phDevice; - const ur_usm_desc_t **ppUSMDesc; - ur_usm_pool_handle_t *ppool; - size_t *pwidthInBytes; - size_t *pheight; - size_t *pelementSizeBytes; - void ***pppMem; - size_t **ppResultPitch; -} ur_usm_pitched_alloc_exp_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMImportExp -/// @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_usm_import_exp_params_t { - ur_context_handle_t *phContext; - void **ppMem; - size_t *psize; -} ur_usm_import_exp_params_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urUSMReleaseExp -/// @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_usm_release_exp_params_t { - ur_context_handle_t *phContext; - void **ppMem; -} ur_usm_release_exp_params_t; - /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urCommandBufferCreateExp /// @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 b841fd6d7b..0531e124b9 100644 --- a/include/ur_api_funcs.def +++ b/include/ur_api_funcs.def @@ -129,9 +129,26 @@ _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) +_UR_API(urUSMHostAlloc) +_UR_API(urUSMDeviceAlloc) +_UR_API(urUSMSharedAlloc) +_UR_API(urUSMFree) +_UR_API(urUSMGetMemAllocInfo) +_UR_API(urUSMPoolCreate) +_UR_API(urUSMPoolRetain) +_UR_API(urUSMPoolRelease) +_UR_API(urUSMPoolGetInfo) +_UR_API(urUSMPoolCreateExp) +_UR_API(urUSMPitchedAllocExp) +_UR_API(urUSMImportExp) +_UR_API(urUSMReleaseExp) _UR_API(urBindlessImagesUnsampledImageHandleDestroyExp) _UR_API(urBindlessImagesSampledImageHandleDestroyExp) _UR_API(urBindlessImagesImageAllocateExp) @@ -150,18 +167,6 @@ _UR_API(urBindlessImagesImportExternalSemaphoreExp) _UR_API(urBindlessImagesReleaseExternalSemaphoreExp) _UR_API(urBindlessImagesWaitExternalSemaphoreExp) _UR_API(urBindlessImagesSignalExternalSemaphoreExp) -_UR_API(urUSMHostAlloc) -_UR_API(urUSMDeviceAlloc) -_UR_API(urUSMSharedAlloc) -_UR_API(urUSMFree) -_UR_API(urUSMGetMemAllocInfo) -_UR_API(urUSMPoolCreate) -_UR_API(urUSMPoolRetain) -_UR_API(urUSMPoolRelease) -_UR_API(urUSMPoolGetInfo) -_UR_API(urUSMPitchedAllocExp) -_UR_API(urUSMImportExp) -_UR_API(urUSMReleaseExp) _UR_API(urCommandBufferCreateExp) _UR_API(urCommandBufferRetainExp) _UR_API(urCommandBufferReleaseExp) diff --git a/include/ur_ddi.h b/include/ur_ddi.h index 0f8dfabc67..a664a443a3 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -1485,6 +1485,52 @@ typedef ur_result_t(UR_APICALL *ur_pfnEnqueueKernelLaunchCustomExp_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_async_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_async_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_async_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)( @@ -1524,6 +1570,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; @@ -1550,6 +1600,176 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetEnqueueExpProcAddrTable_t)( ur_api_version_t, ur_enqueue_exp_dditable_t *); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMHostAlloc +typedef ur_result_t(UR_APICALL *ur_pfnUSMHostAlloc_t)( + ur_context_handle_t, + const ur_usm_desc_t *, + ur_usm_pool_handle_t, + size_t, + void **); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMDeviceAlloc +typedef ur_result_t(UR_APICALL *ur_pfnUSMDeviceAlloc_t)( + ur_context_handle_t, + ur_device_handle_t, + const ur_usm_desc_t *, + ur_usm_pool_handle_t, + size_t, + void **); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMSharedAlloc +typedef ur_result_t(UR_APICALL *ur_pfnUSMSharedAlloc_t)( + ur_context_handle_t, + ur_device_handle_t, + const ur_usm_desc_t *, + ur_usm_pool_handle_t, + size_t, + void **); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMFree +typedef ur_result_t(UR_APICALL *ur_pfnUSMFree_t)( + ur_context_handle_t, + void *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMGetMemAllocInfo +typedef ur_result_t(UR_APICALL *ur_pfnUSMGetMemAllocInfo_t)( + ur_context_handle_t, + const void *, + ur_usm_alloc_info_t, + size_t, + void *, + size_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMPoolCreate +typedef ur_result_t(UR_APICALL *ur_pfnUSMPoolCreate_t)( + ur_context_handle_t, + ur_usm_pool_desc_t *, + ur_usm_pool_handle_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMPoolRetain +typedef ur_result_t(UR_APICALL *ur_pfnUSMPoolRetain_t)( + ur_usm_pool_handle_t); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMPoolRelease +typedef ur_result_t(UR_APICALL *ur_pfnUSMPoolRelease_t)( + ur_usm_pool_handle_t); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMPoolGetInfo +typedef ur_result_t(UR_APICALL *ur_pfnUSMPoolGetInfo_t)( + ur_usm_pool_handle_t, + ur_usm_pool_info_t, + size_t, + void *, + size_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of USM functions pointers +typedef struct ur_usm_dditable_t { + ur_pfnUSMHostAlloc_t pfnHostAlloc; + ur_pfnUSMDeviceAlloc_t pfnDeviceAlloc; + ur_pfnUSMSharedAlloc_t pfnSharedAlloc; + ur_pfnUSMFree_t pfnFree; + ur_pfnUSMGetMemAllocInfo_t pfnGetMemAllocInfo; + ur_pfnUSMPoolCreate_t pfnPoolCreate; + ur_pfnUSMPoolRetain_t pfnPoolRetain; + ur_pfnUSMPoolRelease_t pfnPoolRelease; + ur_pfnUSMPoolGetInfo_t pfnPoolGetInfo; +} ur_usm_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's USM table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +UR_DLLEXPORT ur_result_t UR_APICALL +urGetUSMProcAddrTable( + ur_api_version_t version, ///< [in] API version requested + ur_usm_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGetUSMProcAddrTable +typedef ur_result_t(UR_APICALL *ur_pfnGetUSMProcAddrTable_t)( + ur_api_version_t, + ur_usm_dditable_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMPoolCreateExp +typedef ur_result_t(UR_APICALL *ur_pfnUSMPoolCreateExp_t)( + ur_context_handle_t, + ur_device_handle_t, + ur_usm_pool_desc_t *, + ur_usm_pool_handle_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMPitchedAllocExp +typedef ur_result_t(UR_APICALL *ur_pfnUSMPitchedAllocExp_t)( + ur_context_handle_t, + ur_device_handle_t, + const ur_usm_desc_t *, + ur_usm_pool_handle_t, + size_t, + size_t, + size_t, + void **, + size_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMImportExp +typedef ur_result_t(UR_APICALL *ur_pfnUSMImportExp_t)( + ur_context_handle_t, + void *, + size_t); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urUSMReleaseExp +typedef ur_result_t(UR_APICALL *ur_pfnUSMReleaseExp_t)( + ur_context_handle_t, + void *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of USMExp functions pointers +typedef struct ur_usm_exp_dditable_t { + ur_pfnUSMPoolCreateExp_t pfnPoolCreateExp; + ur_pfnUSMPitchedAllocExp_t pfnPitchedAllocExp; + ur_pfnUSMImportExp_t pfnImportExp; + ur_pfnUSMReleaseExp_t pfnReleaseExp; +} ur_usm_exp_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's USMExp table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +UR_DLLEXPORT ur_result_t UR_APICALL +urGetUSMExpProcAddrTable( + ur_api_version_t version, ///< [in] API version requested + ur_usm_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers +); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGetUSMExpProcAddrTable +typedef ur_result_t(UR_APICALL *ur_pfnGetUSMExpProcAddrTable_t)( + ur_api_version_t, + ur_usm_exp_dditable_t *); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urBindlessImagesUnsampledImageHandleDestroyExp typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesUnsampledImageHandleDestroyExp_t)( @@ -1761,167 +1981,6 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetBindlessImagesExpProcAddrTable_t)( ur_api_version_t, ur_bindless_images_exp_dditable_t *); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMHostAlloc -typedef ur_result_t(UR_APICALL *ur_pfnUSMHostAlloc_t)( - ur_context_handle_t, - const ur_usm_desc_t *, - ur_usm_pool_handle_t, - size_t, - void **); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMDeviceAlloc -typedef ur_result_t(UR_APICALL *ur_pfnUSMDeviceAlloc_t)( - ur_context_handle_t, - ur_device_handle_t, - const ur_usm_desc_t *, - ur_usm_pool_handle_t, - size_t, - void **); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMSharedAlloc -typedef ur_result_t(UR_APICALL *ur_pfnUSMSharedAlloc_t)( - ur_context_handle_t, - ur_device_handle_t, - const ur_usm_desc_t *, - ur_usm_pool_handle_t, - size_t, - void **); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMFree -typedef ur_result_t(UR_APICALL *ur_pfnUSMFree_t)( - ur_context_handle_t, - void *); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMGetMemAllocInfo -typedef ur_result_t(UR_APICALL *ur_pfnUSMGetMemAllocInfo_t)( - ur_context_handle_t, - const void *, - ur_usm_alloc_info_t, - size_t, - void *, - size_t *); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMPoolCreate -typedef ur_result_t(UR_APICALL *ur_pfnUSMPoolCreate_t)( - ur_context_handle_t, - ur_usm_pool_desc_t *, - ur_usm_pool_handle_t *); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMPoolRetain -typedef ur_result_t(UR_APICALL *ur_pfnUSMPoolRetain_t)( - ur_usm_pool_handle_t); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMPoolRelease -typedef ur_result_t(UR_APICALL *ur_pfnUSMPoolRelease_t)( - ur_usm_pool_handle_t); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMPoolGetInfo -typedef ur_result_t(UR_APICALL *ur_pfnUSMPoolGetInfo_t)( - ur_usm_pool_handle_t, - ur_usm_pool_info_t, - size_t, - void *, - size_t *); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Table of USM functions pointers -typedef struct ur_usm_dditable_t { - ur_pfnUSMHostAlloc_t pfnHostAlloc; - ur_pfnUSMDeviceAlloc_t pfnDeviceAlloc; - ur_pfnUSMSharedAlloc_t pfnSharedAlloc; - ur_pfnUSMFree_t pfnFree; - ur_pfnUSMGetMemAllocInfo_t pfnGetMemAllocInfo; - ur_pfnUSMPoolCreate_t pfnPoolCreate; - ur_pfnUSMPoolRetain_t pfnPoolRetain; - ur_pfnUSMPoolRelease_t pfnPoolRelease; - ur_pfnUSMPoolGetInfo_t pfnPoolGetInfo; -} ur_usm_dditable_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Exported function for filling application's USM table -/// with current process' addresses -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION -UR_DLLEXPORT ur_result_t UR_APICALL -urGetUSMProcAddrTable( - ur_api_version_t version, ///< [in] API version requested - ur_usm_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers -); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urGetUSMProcAddrTable -typedef ur_result_t(UR_APICALL *ur_pfnGetUSMProcAddrTable_t)( - ur_api_version_t, - ur_usm_dditable_t *); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMPitchedAllocExp -typedef ur_result_t(UR_APICALL *ur_pfnUSMPitchedAllocExp_t)( - ur_context_handle_t, - ur_device_handle_t, - const ur_usm_desc_t *, - ur_usm_pool_handle_t, - size_t, - size_t, - size_t, - void **, - size_t *); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMImportExp -typedef ur_result_t(UR_APICALL *ur_pfnUSMImportExp_t)( - ur_context_handle_t, - void *, - size_t); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urUSMReleaseExp -typedef ur_result_t(UR_APICALL *ur_pfnUSMReleaseExp_t)( - ur_context_handle_t, - void *); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Table of USMExp functions pointers -typedef struct ur_usm_exp_dditable_t { - ur_pfnUSMPitchedAllocExp_t pfnPitchedAllocExp; - ur_pfnUSMImportExp_t pfnImportExp; - ur_pfnUSMReleaseExp_t pfnReleaseExp; -} ur_usm_exp_dditable_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Exported function for filling application's USMExp table -/// with current process' addresses -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION -UR_DLLEXPORT ur_result_t UR_APICALL -urGetUSMExpProcAddrTable( - ur_api_version_t version, ///< [in] API version requested - ur_usm_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers -); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urGetUSMExpProcAddrTable -typedef ur_result_t(UR_APICALL *ur_pfnGetUSMExpProcAddrTable_t)( - ur_api_version_t, - ur_usm_exp_dditable_t *); - /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urCommandBufferCreateExp typedef ur_result_t(UR_APICALL *ur_pfnCommandBufferCreateExp_t)( @@ -2588,9 +2647,9 @@ typedef struct ur_dditable_t { ur_global_dditable_t Global; ur_enqueue_dditable_t Enqueue; ur_enqueue_exp_dditable_t EnqueueExp; - ur_bindless_images_exp_dditable_t BindlessImagesExp; ur_usm_dditable_t USM; ur_usm_exp_dditable_t USMExp; + ur_bindless_images_exp_dditable_t BindlessImagesExp; ur_command_buffer_exp_dditable_t CommandBufferExp; ur_tensor_map_exp_dditable_t TensorMapExp; ur_usm_p2p_exp_dditable_t UsmP2PExp; diff --git a/include/ur_print.h b/include/ur_print.h index 9bec0bc7b5..7d21822023 100644 --- a/include/ur_print.h +++ b/include/ur_print.h @@ -890,6 +890,22 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmMigrationFlags(enum ur_usm_migrati /// - `buff_size < out_size` UR_APIEXPORT ur_result_t UR_APICALL 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_async_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 urPrintExpAsyncUsmAllocFlags(enum ur_exp_async_usm_alloc_flag_t value, char *buffer, const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_exp_async_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 urPrintExpAsyncUsmAllocProperties(const struct ur_exp_async_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 @@ -2122,6 +2138,38 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintEnqueueKernelLaunchCustomExpParams(co /// - `buff_size < out_size` UR_APIEXPORT ur_result_t UR_APICALL 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 @@ -2147,244 +2195,252 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintEnqueueTimestampRecordingExpParams(co UR_APIEXPORT ur_result_t UR_APICALL urPrintEnqueueNativeCommandExpParams(const struct ur_enqueue_native_command_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_unsampled_image_handle_destroy_exp_params_t struct +/// @brief Print ur_usm_host_alloc_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesUnsampledImageHandleDestroyExpParams(const struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmHostAllocParams(const struct ur_usm_host_alloc_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_sampled_image_handle_destroy_exp_params_t struct +/// @brief Print ur_usm_device_alloc_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesSampledImageHandleDestroyExpParams(const struct ur_bindless_images_sampled_image_handle_destroy_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmDeviceAllocParams(const struct ur_usm_device_alloc_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_image_allocate_exp_params_t struct +/// @brief Print ur_usm_shared_alloc_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImageAllocateExpParams(const struct ur_bindless_images_image_allocate_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmSharedAllocParams(const struct ur_usm_shared_alloc_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_image_free_exp_params_t struct +/// @brief Print ur_usm_free_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImageFreeExpParams(const struct ur_bindless_images_image_free_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmFreeParams(const struct ur_usm_free_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_unsampled_image_create_exp_params_t struct +/// @brief Print ur_usm_get_mem_alloc_info_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesUnsampledImageCreateExpParams(const struct ur_bindless_images_unsampled_image_create_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmGetMemAllocInfoParams(const struct ur_usm_get_mem_alloc_info_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_sampled_image_create_exp_params_t struct +/// @brief Print ur_usm_pool_create_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesSampledImageCreateExpParams(const struct ur_bindless_images_sampled_image_create_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmPoolCreateParams(const struct ur_usm_pool_create_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_image_copy_exp_params_t struct +/// @brief Print ur_usm_pool_retain_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImageCopyExpParams(const struct ur_bindless_images_image_copy_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmPoolRetainParams(const struct ur_usm_pool_retain_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_image_get_info_exp_params_t struct +/// @brief Print ur_usm_pool_release_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImageGetInfoExpParams(const struct ur_bindless_images_image_get_info_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmPoolReleaseParams(const struct ur_usm_pool_release_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_mipmap_get_level_exp_params_t struct +/// @brief Print ur_usm_pool_get_info_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesMipmapGetLevelExpParams(const struct ur_bindless_images_mipmap_get_level_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmPoolGetInfoParams(const struct ur_usm_pool_get_info_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_mipmap_free_exp_params_t struct +/// @brief Print ur_usm_pool_create_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesMipmapFreeExpParams(const struct ur_bindless_images_mipmap_free_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmPoolCreateExpParams(const struct ur_usm_pool_create_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_import_external_memory_exp_params_t struct +/// @brief Print ur_usm_pitched_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 urPrintBindlessImagesImportExternalMemoryExpParams(const struct ur_bindless_images_import_external_memory_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmPitchedAllocExpParams(const struct ur_usm_pitched_alloc_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_map_external_array_exp_params_t struct +/// @brief Print ur_usm_import_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesMapExternalArrayExpParams(const struct ur_bindless_images_map_external_array_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmImportExpParams(const struct ur_usm_import_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_map_external_linear_memory_exp_params_t struct +/// @brief Print ur_usm_release_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesMapExternalLinearMemoryExpParams(const struct ur_bindless_images_map_external_linear_memory_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmReleaseExpParams(const struct ur_usm_release_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_release_external_memory_exp_params_t struct +/// @brief Print ur_bindless_images_unsampled_image_handle_destroy_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesReleaseExternalMemoryExpParams(const struct ur_bindless_images_release_external_memory_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesUnsampledImageHandleDestroyExpParams(const struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_import_external_semaphore_exp_params_t struct +/// @brief Print ur_bindless_images_sampled_image_handle_destroy_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImportExternalSemaphoreExpParams(const struct ur_bindless_images_import_external_semaphore_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesSampledImageHandleDestroyExpParams(const struct ur_bindless_images_sampled_image_handle_destroy_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_release_external_semaphore_exp_params_t struct +/// @brief Print ur_bindless_images_image_allocate_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesReleaseExternalSemaphoreExpParams(const struct ur_bindless_images_release_external_semaphore_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImageAllocateExpParams(const struct ur_bindless_images_image_allocate_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_wait_external_semaphore_exp_params_t struct +/// @brief Print ur_bindless_images_image_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 urPrintBindlessImagesWaitExternalSemaphoreExpParams(const struct ur_bindless_images_wait_external_semaphore_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImageFreeExpParams(const struct ur_bindless_images_image_free_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_bindless_images_signal_external_semaphore_exp_params_t struct +/// @brief Print ur_bindless_images_unsampled_image_create_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesSignalExternalSemaphoreExpParams(const struct ur_bindless_images_signal_external_semaphore_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesUnsampledImageCreateExpParams(const struct ur_bindless_images_unsampled_image_create_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_host_alloc_params_t struct +/// @brief Print ur_bindless_images_sampled_image_create_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmHostAllocParams(const struct ur_usm_host_alloc_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesSampledImageCreateExpParams(const struct ur_bindless_images_sampled_image_create_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_device_alloc_params_t struct +/// @brief Print ur_bindless_images_image_copy_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmDeviceAllocParams(const struct ur_usm_device_alloc_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImageCopyExpParams(const struct ur_bindless_images_image_copy_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_shared_alloc_params_t struct +/// @brief Print ur_bindless_images_image_get_info_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmSharedAllocParams(const struct ur_usm_shared_alloc_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImageGetInfoExpParams(const struct ur_bindless_images_image_get_info_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_free_params_t struct +/// @brief Print ur_bindless_images_mipmap_get_level_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmFreeParams(const struct ur_usm_free_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesMipmapGetLevelExpParams(const struct ur_bindless_images_mipmap_get_level_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_get_mem_alloc_info_params_t struct +/// @brief Print ur_bindless_images_mipmap_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 urPrintUsmGetMemAllocInfoParams(const struct ur_usm_get_mem_alloc_info_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesMipmapFreeExpParams(const struct ur_bindless_images_mipmap_free_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_pool_create_params_t struct +/// @brief Print ur_bindless_images_import_external_memory_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmPoolCreateParams(const struct ur_usm_pool_create_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImportExternalMemoryExpParams(const struct ur_bindless_images_import_external_memory_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_pool_retain_params_t struct +/// @brief Print ur_bindless_images_map_external_array_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmPoolRetainParams(const struct ur_usm_pool_retain_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesMapExternalArrayExpParams(const struct ur_bindless_images_map_external_array_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_pool_release_params_t struct +/// @brief Print ur_bindless_images_map_external_linear_memory_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmPoolReleaseParams(const struct ur_usm_pool_release_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesMapExternalLinearMemoryExpParams(const struct ur_bindless_images_map_external_linear_memory_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_pool_get_info_params_t struct +/// @brief Print ur_bindless_images_release_external_memory_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmPoolGetInfoParams(const struct ur_usm_pool_get_info_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesReleaseExternalMemoryExpParams(const struct ur_bindless_images_release_external_memory_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_pitched_alloc_exp_params_t struct +/// @brief Print ur_bindless_images_import_external_semaphore_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmPitchedAllocExpParams(const struct ur_usm_pitched_alloc_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesImportExternalSemaphoreExpParams(const struct ur_bindless_images_import_external_semaphore_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_import_exp_params_t struct +/// @brief Print ur_bindless_images_release_external_semaphore_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmImportExpParams(const struct ur_usm_import_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesReleaseExternalSemaphoreExpParams(const struct ur_bindless_images_release_external_semaphore_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_usm_release_exp_params_t struct +/// @brief Print ur_bindless_images_wait_external_semaphore_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmReleaseExpParams(const struct ur_usm_release_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesWaitExternalSemaphoreExpParams(const struct ur_bindless_images_wait_external_semaphore_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_bindless_images_signal_external_semaphore_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintBindlessImagesSignalExternalSemaphoreExpParams(const struct ur_bindless_images_signal_external_semaphore_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_command_buffer_create_exp_params_t struct diff --git a/include/ur_print.hpp b/include/ur_print.hpp index fec36d090a..776bf1a920 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -202,6 +202,9 @@ inline ur_result_t printFlag(std::ostream &os, uint32_t template <> 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); @@ -353,6 +356,8 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_execution_info_t value inline std::ostream &operator<<(std::ostream &os, enum ur_map_flag_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_usm_migration_flag_t value); 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_async_usm_alloc_flag_t value); +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_async_usm_alloc_properties_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_image_copy_flag_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_sampler_cubemap_filter_mode_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_external_mem_type_t value); @@ -1001,6 +1006,21 @@ 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; + case UR_FUNCTION_USM_POOL_CREATE_EXP: + os << "UR_FUNCTION_USM_POOL_CREATE_EXP"; + break; default: os << "unknown enumerator"; break; @@ -1160,6 +1180,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_structure_type_t value 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; @@ -1425,6 +1448,11 @@ 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_async_usm_alloc_properties_t *pstruct = (const ur_exp_async_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; printPtr(os, pstruct); @@ -2722,6 +2750,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_ASYNC_USM_ALLOCATIONS_EXP: + os << "UR_DEVICE_INFO_ASYNC_USM_ALLOCATIONS_EXP"; + break; default: os << "unknown enumerator"; break; @@ -4542,6 +4573,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info os << ")"; } break; + case UR_DEVICE_INFO_ASYNC_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; @@ -6612,6 +6655,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_usm_pool_flag_t value) case UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK: os << "UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK"; break; + case UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP: + os << "UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP"; + break; default: os << "unknown enumerator"; break; @@ -6636,6 +6682,16 @@ inline ur_result_t printFlag(std::ostream &os, uint32_t flag } os << UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK; } + + if ((val & UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP) == (uint32_t)UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP) { + val ^= (uint32_t)UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP; + } if (val != 0) { std::bitset<32> bits(val); if (!first) { @@ -9221,6 +9277,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; @@ -9690,6 +9758,77 @@ inline ur_result_t printFlag(std } } // namespace ur::details /////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_exp_async_usm_alloc_flag_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, enum ur_exp_async_usm_alloc_flag_t value) { + switch (value) { + case UR_EXP_ASYNC_USM_ALLOC_FLAG_TBD: + os << "UR_EXP_ASYNC_USM_ALLOC_FLAG_TBD"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} + +namespace ur::details { +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_exp_async_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_ASYNC_USM_ALLOC_FLAG_TBD) == (uint32_t)UR_EXP_ASYNC_USM_ALLOC_FLAG_TBD) { + val ^= (uint32_t)UR_EXP_ASYNC_USM_ALLOC_FLAG_TBD; + if (!first) { + os << " | "; + } else { + first = false; + } + os << UR_EXP_ASYNC_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_async_usm_alloc_properties_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_async_usm_alloc_properties_t params) { + os << "(struct ur_exp_async_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 & @@ -15921,10 +16060,10 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_enqueue_cooperative_kernel_launch_exp_params_t type +/// @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_cooperative_kernel_launch_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_enqueue_usm_device_alloc_exp_params_t *params) { os << ".hQueue = "; @@ -15932,33 +16071,21 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phQueue)); os << ", "; - os << ".hKernel = "; - - ur::details::printPtr(os, - *(params->phKernel)); - - os << ", "; - os << ".workDim = "; - - os << *(params->pworkDim); - - os << ", "; - os << ".pGlobalWorkOffset = "; + os << ".pPool = "; ur::details::printPtr(os, - *(params->ppGlobalWorkOffset)); + *(params->ppPool)); os << ", "; - os << ".pGlobalWorkSize = "; + os << ".size = "; - ur::details::printPtr(os, - *(params->ppGlobalWorkSize)); + os << *(params->psize); os << ", "; - os << ".pLocalWorkSize = "; + os << ".pProperties = "; ur::details::printPtr(os, - *(params->ppLocalWorkSize)); + *(params->ppProperties)); os << ", "; os << ".numEventsInWaitList = "; @@ -15981,6 +16108,12 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct os << "}"; } + os << ", "; + os << ".ppMem = "; + + ur::details::printPtr(os, + *(params->pppMem)); + os << ", "; os << ".phEvent = "; @@ -15991,10 +16124,10 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_enqueue_timestamp_recording_exp_params_t type +/// @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_timestamp_recording_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_enqueue_usm_shared_alloc_exp_params_t *params) { os << ".hQueue = "; @@ -16002,9 +16135,21 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phQueue)); os << ", "; - os << ".blocking = "; + os << ".pPool = "; - os << *(params->pblocking); + ur::details::printPtr(os, + *(params->ppPool)); + + os << ", "; + os << ".size = "; + + os << *(params->psize); + + os << ", "; + os << ".pProperties = "; + + ur::details::printPtr(os, + *(params->ppProperties)); os << ", "; os << ".numEventsInWaitList = "; @@ -16027,6 +16172,12 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct os << "}"; } + os << ", "; + os << ".ppMem = "; + + ur::details::printPtr(os, + *(params->pppMem)); + os << ", "; os << ".phEvent = "; @@ -16037,10 +16188,10 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_enqueue_native_command_exp_params_t type +/// @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_native_command_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_enqueue_usm_host_alloc_exp_params_t *params) { os << ".hQueue = "; @@ -16048,37 +16199,15 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phQueue)); os << ", "; - os << ".pfnNativeEnqueue = "; - - os << reinterpret_cast( - *(params->ppfnNativeEnqueue)); - - os << ", "; - os << ".data = "; + os << ".pPool = "; ur::details::printPtr(os, - *(params->pdata)); - - os << ", "; - os << ".numMemsInMemList = "; - - os << *(params->pnumMemsInMemList); + *(params->ppPool)); os << ", "; - os << ".phMemList = "; - ur::details::printPtr(os, reinterpret_cast(*(params->pphMemList))); - if (*(params->pphMemList) != NULL) { - os << " {"; - for (size_t i = 0; i < *params->pnumMemsInMemList; ++i) { - if (i != 0) { - os << ", "; - } + os << ".size = "; - ur::details::printPtr(os, - (*(params->pphMemList))[i]); - } - os << "}"; - } + os << *(params->psize); os << ", "; os << ".pProperties = "; @@ -16107,6 +16236,12 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct os << "}"; } + os << ", "; + os << ".ppMem = "; + + ur::details::printPtr(os, + *(params->pppMem)); + os << ", "; os << ".phEvent = "; @@ -16117,100 +16252,296 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_unsampled_image_handle_destroy_exp_params_t type +/// @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_bindless_images_unsampled_image_handle_destroy_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_enqueue_usm_free_exp_params_t *params) { - os << ".hContext = "; + os << ".hQueue = "; ur::details::printPtr(os, - *(params->phContext)); + *(params->phQueue)); os << ", "; - os << ".hDevice = "; + os << ".pPool = "; ur::details::printPtr(os, - *(params->phDevice)); + *(params->ppPool)); os << ", "; - os << ".hImage = "; - - ur::details::printPtr(os, reinterpret_cast( - *(params->phImage))); - - return os; -} + os << ".pMem = "; -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_sampled_image_handle_destroy_exp_params_t type -/// @returns -/// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_sampled_image_handle_destroy_exp_params_t *params) { + ur::details::printPtr(os, + *(params->ppMem)); - os << ".hContext = "; + os << ", "; + os << ".numEventsInWaitList = "; - ur::details::printPtr(os, - *(params->phContext)); + os << *(params->pnumEventsInWaitList); os << ", "; - os << ".hDevice = "; + 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->phDevice)); + ur::details::printPtr(os, + (*(params->pphEventWaitList))[i]); + } + os << "}"; + } os << ", "; - os << ".hImage = "; + os << ".phEvent = "; - ur::details::printPtr(os, reinterpret_cast( - *(params->phImage))); + ur::details::printPtr(os, + *(params->pphEvent)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_image_allocate_exp_params_t type +/// @brief Print operator for the ur_enqueue_cooperative_kernel_launch_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_image_allocate_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_enqueue_cooperative_kernel_launch_exp_params_t *params) { - os << ".hContext = "; + os << ".hQueue = "; ur::details::printPtr(os, - *(params->phContext)); + *(params->phQueue)); os << ", "; - os << ".hDevice = "; + os << ".hKernel = "; ur::details::printPtr(os, - *(params->phDevice)); + *(params->phKernel)); os << ", "; - os << ".pImageFormat = "; + os << ".workDim = "; - ur::details::printPtr(os, - *(params->ppImageFormat)); + os << *(params->pworkDim); os << ", "; - os << ".pImageDesc = "; + os << ".pGlobalWorkOffset = "; ur::details::printPtr(os, - *(params->ppImageDesc)); + *(params->ppGlobalWorkOffset)); os << ", "; - os << ".phImageMem = "; + os << ".pGlobalWorkSize = "; ur::details::printPtr(os, - *(params->pphImageMem)); + *(params->ppGlobalWorkSize)); + + os << ", "; + os << ".pLocalWorkSize = "; + + ur::details::printPtr(os, + *(params->ppLocalWorkSize)); + + 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_bindless_images_image_free_exp_params_t type +/// @brief Print operator for the ur_enqueue_timestamp_recording_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_image_free_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_enqueue_timestamp_recording_exp_params_t *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, + *(params->phQueue)); + + os << ", "; + os << ".blocking = "; + + os << *(params->pblocking); + + 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_native_command_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_enqueue_native_command_exp_params_t *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, + *(params->phQueue)); + + os << ", "; + os << ".pfnNativeEnqueue = "; + + os << reinterpret_cast( + *(params->ppfnNativeEnqueue)); + + os << ", "; + os << ".data = "; + + ur::details::printPtr(os, + *(params->pdata)); + + os << ", "; + os << ".numMemsInMemList = "; + + os << *(params->pnumMemsInMemList); + + os << ", "; + os << ".phMemList = "; + ur::details::printPtr(os, reinterpret_cast(*(params->pphMemList))); + if (*(params->pphMemList) != NULL) { + os << " {"; + for (size_t i = 0; i < *params->pnumMemsInMemList; ++i) { + if (i != 0) { + os << ", "; + } + + ur::details::printPtr(os, + (*(params->pphMemList))[i]); + } + os << "}"; + } + + 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 << ".phEvent = "; + + ur::details::printPtr(os, + *(params->pphEvent)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_usm_host_alloc_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_host_alloc_params_t *params) { + + os << ".hContext = "; + + ur::details::printPtr(os, + *(params->phContext)); + + os << ", "; + os << ".pUSMDesc = "; + + ur::details::printPtr(os, + *(params->ppUSMDesc)); + + os << ", "; + os << ".pool = "; + + ur::details::printPtr(os, + *(params->ppool)); + + os << ", "; + os << ".size = "; + + os << *(params->psize); + + os << ", "; + os << ".ppMem = "; + + ur::details::printPtr(os, + *(params->pppMem)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_usm_device_alloc_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_device_alloc_params_t *params) { os << ".hContext = "; @@ -16224,19 +16555,36 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phDevice)); os << ", "; - os << ".hImageMem = "; + os << ".pUSMDesc = "; - ur::details::printPtr(os, reinterpret_cast( - *(params->phImageMem))); + ur::details::printPtr(os, + *(params->ppUSMDesc)); + + os << ", "; + os << ".pool = "; + + ur::details::printPtr(os, + *(params->ppool)); + + os << ", "; + os << ".size = "; + + os << *(params->psize); + + os << ", "; + os << ".ppMem = "; + + ur::details::printPtr(os, + *(params->pppMem)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_unsampled_image_create_exp_params_t type +/// @brief Print operator for the ur_usm_shared_alloc_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_unsampled_image_create_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_shared_alloc_params_t *params) { os << ".hContext = "; @@ -16250,37 +16598,184 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phDevice)); os << ", "; - os << ".hImageMem = "; + os << ".pUSMDesc = "; - ur::details::printPtr(os, reinterpret_cast( - *(params->phImageMem))); + ur::details::printPtr(os, + *(params->ppUSMDesc)); + + os << ", "; + os << ".pool = "; + + ur::details::printPtr(os, + *(params->ppool)); + + os << ", "; + os << ".size = "; + + os << *(params->psize); + + os << ", "; + os << ".ppMem = "; + + ur::details::printPtr(os, + *(params->pppMem)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_usm_free_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_free_params_t *params) { + + os << ".hContext = "; + + ur::details::printPtr(os, + *(params->phContext)); + + os << ", "; + os << ".pMem = "; + + ur::details::printPtr(os, + *(params->ppMem)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_usm_get_mem_alloc_info_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_get_mem_alloc_info_params_t *params) { + + os << ".hContext = "; + + ur::details::printPtr(os, + *(params->phContext)); + + os << ", "; + os << ".pMem = "; + + ur::details::printPtr(os, + *(params->ppMem)); + + os << ", "; + os << ".propName = "; + + os << *(params->ppropName); + + os << ", "; + os << ".propSize = "; + + os << *(params->ppropSize); + + os << ", "; + os << ".pPropValue = "; + ur::details::printTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); + + os << ", "; + os << ".pPropSizeRet = "; + + ur::details::printPtr(os, + *(params->ppPropSizeRet)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_usm_pool_create_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_create_params_t *params) { + + os << ".hContext = "; + + ur::details::printPtr(os, + *(params->phContext)); + + os << ", "; + os << ".pPoolDesc = "; + + ur::details::printPtr(os, + *(params->ppPoolDesc)); + + os << ", "; + os << ".ppPool = "; + + ur::details::printPtr(os, + *(params->pppPool)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_usm_pool_retain_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_retain_params_t *params) { + + os << ".pPool = "; + + ur::details::printPtr(os, + *(params->ppPool)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_usm_pool_release_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_release_params_t *params) { + + os << ".pPool = "; + + ur::details::printPtr(os, + *(params->ppPool)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_usm_pool_get_info_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_get_info_params_t *params) { + + os << ".hPool = "; + + ur::details::printPtr(os, + *(params->phPool)); os << ", "; - os << ".pImageFormat = "; + os << ".propName = "; - ur::details::printPtr(os, - *(params->ppImageFormat)); + os << *(params->ppropName); os << ", "; - os << ".pImageDesc = "; + os << ".propSize = "; - ur::details::printPtr(os, - *(params->ppImageDesc)); + os << *(params->ppropSize); os << ", "; - os << ".phImage = "; + os << ".pPropValue = "; + ur::details::printTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); + + os << ", "; + os << ".pPropSizeRet = "; ur::details::printPtr(os, - *(params->pphImage)); + *(params->ppPropSizeRet)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_sampled_image_create_exp_params_t type +/// @brief Print operator for the ur_usm_pool_create_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_sampled_image_create_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_create_exp_params_t *params) { os << ".hContext = "; @@ -16294,132 +16789,84 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phDevice)); os << ", "; - os << ".hImageMem = "; - - ur::details::printPtr(os, reinterpret_cast( - *(params->phImageMem))); - - os << ", "; - os << ".pImageFormat = "; - - ur::details::printPtr(os, - *(params->ppImageFormat)); - - os << ", "; - os << ".pImageDesc = "; - - ur::details::printPtr(os, - *(params->ppImageDesc)); - - os << ", "; - os << ".hSampler = "; + os << ".pPoolDesc = "; ur::details::printPtr(os, - *(params->phSampler)); + *(params->ppPoolDesc)); os << ", "; - os << ".phImage = "; + os << ".ppPool = "; ur::details::printPtr(os, - *(params->pphImage)); + *(params->pppPool)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_image_copy_exp_params_t type +/// @brief Print operator for the ur_usm_pitched_alloc_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_image_copy_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pitched_alloc_exp_params_t *params) { - os << ".hQueue = "; + os << ".hContext = "; ur::details::printPtr(os, - *(params->phQueue)); + *(params->phContext)); os << ", "; - os << ".pSrc = "; + os << ".hDevice = "; ur::details::printPtr(os, - *(params->ppSrc)); + *(params->phDevice)); os << ", "; - os << ".pDst = "; + os << ".pUSMDesc = "; ur::details::printPtr(os, - *(params->ppDst)); + *(params->ppUSMDesc)); os << ", "; - os << ".pSrcImageDesc = "; + os << ".pool = "; ur::details::printPtr(os, - *(params->ppSrcImageDesc)); + *(params->ppool)); os << ", "; - os << ".pDstImageDesc = "; + os << ".widthInBytes = "; - ur::details::printPtr(os, - *(params->ppDstImageDesc)); + os << *(params->pwidthInBytes); os << ", "; - os << ".pSrcImageFormat = "; + os << ".height = "; - ur::details::printPtr(os, - *(params->ppSrcImageFormat)); + os << *(params->pheight); os << ", "; - os << ".pDstImageFormat = "; + os << ".elementSizeBytes = "; - ur::details::printPtr(os, - *(params->ppDstImageFormat)); + os << *(params->pelementSizeBytes); os << ", "; - os << ".pCopyRegion = "; + os << ".ppMem = "; ur::details::printPtr(os, - *(params->ppCopyRegion)); - - os << ", "; - os << ".imageCopyFlags = "; - - ur::details::printFlag(os, - *(params->pimageCopyFlags)); - - 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 << "}"; - } + *(params->pppMem)); os << ", "; - os << ".phEvent = "; + os << ".pResultPitch = "; ur::details::printPtr(os, - *(params->pphEvent)); + *(params->ppResultPitch)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_image_get_info_exp_params_t type +/// @brief Print operator for the ur_usm_import_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_image_get_info_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_import_exp_params_t *params) { os << ".hContext = "; @@ -16427,36 +16874,24 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phContext)); os << ", "; - os << ".hImageMem = "; - - ur::details::printPtr(os, reinterpret_cast( - *(params->phImageMem))); - - os << ", "; - os << ".propName = "; - - os << *(params->ppropName); - - os << ", "; - os << ".pPropValue = "; + os << ".pMem = "; ur::details::printPtr(os, - *(params->ppPropValue)); + *(params->ppMem)); os << ", "; - os << ".pPropSizeRet = "; + os << ".size = "; - ur::details::printPtr(os, - *(params->ppPropSizeRet)); + os << *(params->psize); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_mipmap_get_level_exp_params_t type +/// @brief Print operator for the ur_usm_release_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_mipmap_get_level_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_release_exp_params_t *params) { os << ".hContext = "; @@ -16464,36 +16899,19 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phContext)); os << ", "; - os << ".hDevice = "; - - ur::details::printPtr(os, - *(params->phDevice)); - - os << ", "; - os << ".hImageMem = "; - - ur::details::printPtr(os, reinterpret_cast( - *(params->phImageMem))); - - os << ", "; - os << ".mipmapLevel = "; - - os << *(params->pmipmapLevel); - - os << ", "; - os << ".phImageMem = "; + os << ".pMem = "; ur::details::printPtr(os, - *(params->pphImageMem)); + *(params->ppMem)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_mipmap_free_exp_params_t type +/// @brief Print operator for the ur_bindless_images_unsampled_image_handle_destroy_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_mipmap_free_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t *params) { os << ".hContext = "; @@ -16507,19 +16925,19 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phDevice)); os << ", "; - os << ".hMem = "; + os << ".hImage = "; ur::details::printPtr(os, reinterpret_cast( - *(params->phMem))); + *(params->phImage))); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_import_external_memory_exp_params_t type +/// @brief Print operator for the ur_bindless_images_sampled_image_handle_destroy_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_import_external_memory_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_sampled_image_handle_destroy_exp_params_t *params) { os << ".hContext = "; @@ -16533,35 +16951,19 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phDevice)); os << ", "; - os << ".size = "; - - os << *(params->psize); - - os << ", "; - os << ".memHandleType = "; - - os << *(params->pmemHandleType); - - os << ", "; - os << ".pExternalMemDesc = "; - - ur::details::printPtr(os, - *(params->ppExternalMemDesc)); - - os << ", "; - os << ".phExternalMem = "; + os << ".hImage = "; - ur::details::printPtr(os, - *(params->pphExternalMem)); + ur::details::printPtr(os, reinterpret_cast( + *(params->phImage))); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_map_external_array_exp_params_t type +/// @brief Print operator for the ur_bindless_images_image_allocate_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_map_external_array_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_image_allocate_exp_params_t *params) { os << ".hContext = "; @@ -16586,12 +16988,6 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur::details::printPtr(os, *(params->ppImageDesc)); - os << ", "; - os << ".hExternalMem = "; - - ur::details::printPtr(os, - *(params->phExternalMem)); - os << ", "; os << ".phImageMem = "; @@ -16602,10 +16998,10 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_map_external_linear_memory_exp_params_t type +/// @brief Print operator for the ur_bindless_images_image_free_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_map_external_linear_memory_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_image_free_exp_params_t *params) { os << ".hContext = "; @@ -16619,35 +17015,19 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phDevice)); os << ", "; - os << ".offset = "; - - os << *(params->poffset); - - os << ", "; - os << ".size = "; - - os << *(params->psize); - - os << ", "; - os << ".hExternalMem = "; - - ur::details::printPtr(os, - *(params->phExternalMem)); - - os << ", "; - os << ".ppRetMem = "; + os << ".hImageMem = "; - ur::details::printPtr(os, - *(params->pppRetMem)); + ur::details::printPtr(os, reinterpret_cast( + *(params->phImageMem))); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_release_external_memory_exp_params_t type +/// @brief Print operator for the ur_bindless_images_unsampled_image_create_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_release_external_memory_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_unsampled_image_create_exp_params_t *params) { os << ".hContext = "; @@ -16661,19 +17041,37 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phDevice)); os << ", "; - os << ".hExternalMem = "; + os << ".hImageMem = "; + + ur::details::printPtr(os, reinterpret_cast( + *(params->phImageMem))); + + os << ", "; + os << ".pImageFormat = "; + + ur::details::printPtr(os, + *(params->ppImageFormat)); + + os << ", "; + os << ".pImageDesc = "; + + ur::details::printPtr(os, + *(params->ppImageDesc)); + + os << ", "; + os << ".phImage = "; ur::details::printPtr(os, - *(params->phExternalMem)); + *(params->pphImage)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_import_external_semaphore_exp_params_t type +/// @brief Print operator for the ur_bindless_images_sampled_image_create_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_import_external_semaphore_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_sampled_image_create_exp_params_t *params) { os << ".hContext = "; @@ -16687,56 +17085,43 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phDevice)); os << ", "; - os << ".semHandleType = "; + os << ".hImageMem = "; - os << *(params->psemHandleType); + ur::details::printPtr(os, reinterpret_cast( + *(params->phImageMem))); os << ", "; - os << ".pExternalSemaphoreDesc = "; + os << ".pImageFormat = "; ur::details::printPtr(os, - *(params->ppExternalSemaphoreDesc)); + *(params->ppImageFormat)); os << ", "; - os << ".phExternalSemaphore = "; - - ur::details::printPtr(os, - *(params->pphExternalSemaphore)); - - return os; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_release_external_semaphore_exp_params_t type -/// @returns -/// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_release_external_semaphore_exp_params_t *params) { - - os << ".hContext = "; + os << ".pImageDesc = "; ur::details::printPtr(os, - *(params->phContext)); + *(params->ppImageDesc)); os << ", "; - os << ".hDevice = "; + os << ".hSampler = "; ur::details::printPtr(os, - *(params->phDevice)); + *(params->phSampler)); os << ", "; - os << ".hExternalSemaphore = "; + os << ".phImage = "; ur::details::printPtr(os, - *(params->phExternalSemaphore)); + *(params->pphImage)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_wait_external_semaphore_exp_params_t type +/// @brief Print operator for the ur_bindless_images_image_copy_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_wait_external_semaphore_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_image_copy_exp_params_t *params) { os << ".hQueue = "; @@ -16744,77 +17129,52 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phQueue)); os << ", "; - os << ".hSemaphore = "; + os << ".pSrc = "; ur::details::printPtr(os, - *(params->phSemaphore)); - - os << ", "; - os << ".hasWaitValue = "; - - os << *(params->phasWaitValue); - - os << ", "; - os << ".waitValue = "; - - os << *(params->pwaitValue); + *(params->ppSrc)); os << ", "; - os << ".numEventsInWaitList = "; + os << ".pDst = "; - os << *(params->pnumEventsInWaitList); + ur::details::printPtr(os, + *(params->ppDst)); 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 << ", "; - } + os << ".pSrcImageDesc = "; - ur::details::printPtr(os, - (*(params->pphEventWaitList))[i]); - } - os << "}"; - } + ur::details::printPtr(os, + *(params->ppSrcImageDesc)); os << ", "; - os << ".phEvent = "; + os << ".pDstImageDesc = "; ur::details::printPtr(os, - *(params->pphEvent)); - - return os; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_bindless_images_signal_external_semaphore_exp_params_t type -/// @returns -/// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_signal_external_semaphore_exp_params_t *params) { + *(params->ppDstImageDesc)); - os << ".hQueue = "; + os << ", "; + os << ".pSrcImageFormat = "; ur::details::printPtr(os, - *(params->phQueue)); + *(params->ppSrcImageFormat)); os << ", "; - os << ".hSemaphore = "; + os << ".pDstImageFormat = "; ur::details::printPtr(os, - *(params->phSemaphore)); + *(params->ppDstImageFormat)); os << ", "; - os << ".hasSignalValue = "; + os << ".pCopyRegion = "; - os << *(params->phasSignalValue); + ur::details::printPtr(os, + *(params->ppCopyRegion)); os << ", "; - os << ".signalValue = "; + os << ".imageCopyFlags = "; - os << *(params->psignalValue); + ur::details::printFlag(os, + *(params->pimageCopyFlags)); os << ", "; os << ".numEventsInWaitList = "; @@ -16847,10 +17207,10 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_host_alloc_params_t type +/// @brief Print operator for the ur_bindless_images_image_get_info_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_host_alloc_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_image_get_info_exp_params_t *params) { os << ".hContext = "; @@ -16858,36 +17218,36 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phContext)); os << ", "; - os << ".pUSMDesc = "; + os << ".hImageMem = "; - ur::details::printPtr(os, - *(params->ppUSMDesc)); + ur::details::printPtr(os, reinterpret_cast( + *(params->phImageMem))); os << ", "; - os << ".pool = "; + os << ".propName = "; - ur::details::printPtr(os, - *(params->ppool)); + os << *(params->ppropName); os << ", "; - os << ".size = "; + os << ".pPropValue = "; - os << *(params->psize); + ur::details::printPtr(os, + *(params->ppPropValue)); os << ", "; - os << ".ppMem = "; + os << ".pPropSizeRet = "; ur::details::printPtr(os, - *(params->pppMem)); + *(params->ppPropSizeRet)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_device_alloc_params_t type +/// @brief Print operator for the ur_bindless_images_mipmap_get_level_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_device_alloc_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_mipmap_get_level_exp_params_t *params) { os << ".hContext = "; @@ -16901,36 +17261,30 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phDevice)); os << ", "; - os << ".pUSMDesc = "; - - ur::details::printPtr(os, - *(params->ppUSMDesc)); - - os << ", "; - os << ".pool = "; + os << ".hImageMem = "; - ur::details::printPtr(os, - *(params->ppool)); + ur::details::printPtr(os, reinterpret_cast( + *(params->phImageMem))); os << ", "; - os << ".size = "; + os << ".mipmapLevel = "; - os << *(params->psize); + os << *(params->pmipmapLevel); os << ", "; - os << ".ppMem = "; + os << ".phImageMem = "; ur::details::printPtr(os, - *(params->pppMem)); + *(params->pphImageMem)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_shared_alloc_params_t type +/// @brief Print operator for the ur_bindless_images_mipmap_free_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_shared_alloc_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_mipmap_free_exp_params_t *params) { os << ".hContext = "; @@ -16944,16 +17298,30 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phDevice)); os << ", "; - os << ".pUSMDesc = "; + os << ".hMem = "; + + ur::details::printPtr(os, reinterpret_cast( + *(params->phMem))); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_bindless_images_import_external_memory_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_import_external_memory_exp_params_t *params) { + + os << ".hContext = "; ur::details::printPtr(os, - *(params->ppUSMDesc)); + *(params->phContext)); os << ", "; - os << ".pool = "; + os << ".hDevice = "; ur::details::printPtr(os, - *(params->ppool)); + *(params->phDevice)); os << ", "; os << ".size = "; @@ -16961,39 +17329,30 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct os << *(params->psize); os << ", "; - os << ".ppMem = "; - - ur::details::printPtr(os, - *(params->pppMem)); - - return os; -} + os << ".memHandleType = "; -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_free_params_t type -/// @returns -/// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_free_params_t *params) { + os << *(params->pmemHandleType); - os << ".hContext = "; + os << ", "; + os << ".pExternalMemDesc = "; ur::details::printPtr(os, - *(params->phContext)); + *(params->ppExternalMemDesc)); os << ", "; - os << ".pMem = "; + os << ".phExternalMem = "; ur::details::printPtr(os, - *(params->ppMem)); + *(params->pphExternalMem)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_get_mem_alloc_info_params_t type +/// @brief Print operator for the ur_bindless_images_map_external_array_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_get_mem_alloc_info_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_map_external_array_exp_params_t *params) { os << ".hContext = "; @@ -17001,127 +17360,148 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phContext)); os << ", "; - os << ".pMem = "; + os << ".hDevice = "; ur::details::printPtr(os, - *(params->ppMem)); + *(params->phDevice)); os << ", "; - os << ".propName = "; + os << ".pImageFormat = "; - os << *(params->ppropName); + ur::details::printPtr(os, + *(params->ppImageFormat)); os << ", "; - os << ".propSize = "; + os << ".pImageDesc = "; - os << *(params->ppropSize); + ur::details::printPtr(os, + *(params->ppImageDesc)); os << ", "; - os << ".pPropValue = "; - ur::details::printTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); + os << ".hExternalMem = "; + + ur::details::printPtr(os, + *(params->phExternalMem)); os << ", "; - os << ".pPropSizeRet = "; + os << ".phImageMem = "; ur::details::printPtr(os, - *(params->ppPropSizeRet)); + *(params->pphImageMem)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_pool_create_params_t type +/// @brief Print operator for the ur_bindless_images_map_external_linear_memory_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_create_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_map_external_linear_memory_exp_params_t *params) { + + os << ".hContext = "; + + ur::details::printPtr(os, + *(params->phContext)); + + os << ", "; + os << ".hDevice = "; + + ur::details::printPtr(os, + *(params->phDevice)); + + os << ", "; + os << ".offset = "; - os << ".hContext = "; + os << *(params->poffset); - ur::details::printPtr(os, - *(params->phContext)); + os << ", "; + os << ".size = "; + + os << *(params->psize); os << ", "; - os << ".pPoolDesc = "; + os << ".hExternalMem = "; ur::details::printPtr(os, - *(params->ppPoolDesc)); + *(params->phExternalMem)); os << ", "; - os << ".ppPool = "; + os << ".ppRetMem = "; ur::details::printPtr(os, - *(params->pppPool)); + *(params->pppRetMem)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_pool_retain_params_t type +/// @brief Print operator for the ur_bindless_images_release_external_memory_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_retain_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_release_external_memory_exp_params_t *params) { - os << ".pPool = "; + os << ".hContext = "; ur::details::printPtr(os, - *(params->ppPool)); + *(params->phContext)); - return os; -} + os << ", "; + os << ".hDevice = "; -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_pool_release_params_t type -/// @returns -/// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_release_params_t *params) { + ur::details::printPtr(os, + *(params->phDevice)); - os << ".pPool = "; + os << ", "; + os << ".hExternalMem = "; ur::details::printPtr(os, - *(params->ppPool)); + *(params->phExternalMem)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_pool_get_info_params_t type +/// @brief Print operator for the ur_bindless_images_import_external_semaphore_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_get_info_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_import_external_semaphore_exp_params_t *params) { - os << ".hPool = "; + os << ".hContext = "; ur::details::printPtr(os, - *(params->phPool)); + *(params->phContext)); os << ", "; - os << ".propName = "; + os << ".hDevice = "; - os << *(params->ppropName); + ur::details::printPtr(os, + *(params->phDevice)); os << ", "; - os << ".propSize = "; + os << ".semHandleType = "; - os << *(params->ppropSize); + os << *(params->psemHandleType); os << ", "; - os << ".pPropValue = "; - ur::details::printTagged(os, *(params->ppPropValue), *(params->ppropName), *(params->ppropSize)); + os << ".pExternalSemaphoreDesc = "; + + ur::details::printPtr(os, + *(params->ppExternalSemaphoreDesc)); os << ", "; - os << ".pPropSizeRet = "; + os << ".phExternalSemaphore = "; ur::details::printPtr(os, - *(params->ppPropSizeRet)); + *(params->pphExternalSemaphore)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_pitched_alloc_exp_params_t type +/// @brief Print operator for the ur_bindless_images_release_external_semaphore_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pitched_alloc_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_release_external_semaphore_exp_params_t *params) { os << ".hContext = "; @@ -17135,88 +17515,124 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct *(params->phDevice)); os << ", "; - os << ".pUSMDesc = "; + os << ".hExternalSemaphore = "; ur::details::printPtr(os, - *(params->ppUSMDesc)); + *(params->phExternalSemaphore)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_bindless_images_wait_external_semaphore_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_wait_external_semaphore_exp_params_t *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, + *(params->phQueue)); os << ", "; - os << ".pool = "; + os << ".hSemaphore = "; ur::details::printPtr(os, - *(params->ppool)); + *(params->phSemaphore)); os << ", "; - os << ".widthInBytes = "; + os << ".hasWaitValue = "; - os << *(params->pwidthInBytes); + os << *(params->phasWaitValue); os << ", "; - os << ".height = "; + os << ".waitValue = "; - os << *(params->pheight); + os << *(params->pwaitValue); os << ", "; - os << ".elementSizeBytes = "; + os << ".numEventsInWaitList = "; - os << *(params->pelementSizeBytes); + os << *(params->pnumEventsInWaitList); os << ", "; - os << ".ppMem = "; + 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->pppMem)); + ur::details::printPtr(os, + (*(params->pphEventWaitList))[i]); + } + os << "}"; + } os << ", "; - os << ".pResultPitch = "; + os << ".phEvent = "; ur::details::printPtr(os, - *(params->ppResultPitch)); + *(params->pphEvent)); return os; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_import_exp_params_t type +/// @brief Print operator for the ur_bindless_images_signal_external_semaphore_exp_params_t type /// @returns /// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_import_exp_params_t *params) { +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_bindless_images_signal_external_semaphore_exp_params_t *params) { - os << ".hContext = "; + os << ".hQueue = "; ur::details::printPtr(os, - *(params->phContext)); + *(params->phQueue)); os << ", "; - os << ".pMem = "; + os << ".hSemaphore = "; ur::details::printPtr(os, - *(params->ppMem)); + *(params->phSemaphore)); os << ", "; - os << ".size = "; + os << ".hasSignalValue = "; - os << *(params->psize); + os << *(params->phasSignalValue); - return os; -} + os << ", "; + os << ".signalValue = "; -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_usm_release_exp_params_t type -/// @returns -/// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_release_exp_params_t *params) { + os << *(params->psignalValue); - os << ".hContext = "; + os << ", "; + os << ".numEventsInWaitList = "; - ur::details::printPtr(os, - *(params->phContext)); + os << *(params->pnumEventsInWaitList); os << ", "; - os << ".pMem = "; + 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->ppMem)); + *(params->pphEvent)); return os; } @@ -19899,6 +20315,18 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, ur_function_ case UR_FUNCTION_ENQUEUE_EVENTS_WAIT_WITH_BARRIER_EXT: { 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; } break; @@ -19908,6 +20336,45 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, ur_function_ case UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP: { os << (const struct ur_enqueue_native_command_exp_params_t *)params; } break; + case UR_FUNCTION_USM_HOST_ALLOC: { + os << (const struct ur_usm_host_alloc_params_t *)params; + } break; + case UR_FUNCTION_USM_DEVICE_ALLOC: { + os << (const struct ur_usm_device_alloc_params_t *)params; + } break; + case UR_FUNCTION_USM_SHARED_ALLOC: { + os << (const struct ur_usm_shared_alloc_params_t *)params; + } break; + case UR_FUNCTION_USM_FREE: { + os << (const struct ur_usm_free_params_t *)params; + } break; + case UR_FUNCTION_USM_GET_MEM_ALLOC_INFO: { + os << (const struct ur_usm_get_mem_alloc_info_params_t *)params; + } break; + case UR_FUNCTION_USM_POOL_CREATE: { + os << (const struct ur_usm_pool_create_params_t *)params; + } break; + case UR_FUNCTION_USM_POOL_RETAIN: { + os << (const struct ur_usm_pool_retain_params_t *)params; + } break; + case UR_FUNCTION_USM_POOL_RELEASE: { + os << (const struct ur_usm_pool_release_params_t *)params; + } break; + case UR_FUNCTION_USM_POOL_GET_INFO: { + os << (const struct ur_usm_pool_get_info_params_t *)params; + } break; + case UR_FUNCTION_USM_POOL_CREATE_EXP: { + os << (const struct ur_usm_pool_create_exp_params_t *)params; + } break; + case UR_FUNCTION_USM_PITCHED_ALLOC_EXP: { + os << (const struct ur_usm_pitched_alloc_exp_params_t *)params; + } break; + case UR_FUNCTION_USM_IMPORT_EXP: { + os << (const struct ur_usm_import_exp_params_t *)params; + } break; + case UR_FUNCTION_USM_RELEASE_EXP: { + os << (const struct ur_usm_release_exp_params_t *)params; + } break; case UR_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP: { os << (const struct ur_bindless_images_unsampled_image_handle_destroy_exp_params_t *)params; } break; @@ -19962,42 +20429,6 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, ur_function_ case UR_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP: { os << (const struct ur_bindless_images_signal_external_semaphore_exp_params_t *)params; } break; - case UR_FUNCTION_USM_HOST_ALLOC: { - os << (const struct ur_usm_host_alloc_params_t *)params; - } break; - case UR_FUNCTION_USM_DEVICE_ALLOC: { - os << (const struct ur_usm_device_alloc_params_t *)params; - } break; - case UR_FUNCTION_USM_SHARED_ALLOC: { - os << (const struct ur_usm_shared_alloc_params_t *)params; - } break; - case UR_FUNCTION_USM_FREE: { - os << (const struct ur_usm_free_params_t *)params; - } break; - case UR_FUNCTION_USM_GET_MEM_ALLOC_INFO: { - os << (const struct ur_usm_get_mem_alloc_info_params_t *)params; - } break; - case UR_FUNCTION_USM_POOL_CREATE: { - os << (const struct ur_usm_pool_create_params_t *)params; - } break; - case UR_FUNCTION_USM_POOL_RETAIN: { - os << (const struct ur_usm_pool_retain_params_t *)params; - } break; - case UR_FUNCTION_USM_POOL_RELEASE: { - os << (const struct ur_usm_pool_release_params_t *)params; - } break; - case UR_FUNCTION_USM_POOL_GET_INFO: { - os << (const struct ur_usm_pool_get_info_params_t *)params; - } break; - case UR_FUNCTION_USM_PITCHED_ALLOC_EXP: { - os << (const struct ur_usm_pitched_alloc_exp_params_t *)params; - } break; - case UR_FUNCTION_USM_IMPORT_EXP: { - os << (const struct ur_usm_import_exp_params_t *)params; - } break; - case UR_FUNCTION_USM_RELEASE_EXP: { - os << (const struct ur_usm_release_exp_params_t *)params; - } break; case UR_FUNCTION_COMMAND_BUFFER_CREATE_EXP: { os << (const struct ur_command_buffer_create_exp_params_t *)params; } break; diff --git a/scripts/core/EXP-ASYNC-ALLOC.rst b/scripts/core/EXP-ASYNC-ALLOC.rst new file mode 100644 index 0000000000..bc71c3f0a9 --- /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 +performancet. + +API +-------------------------------------------------------------------------------- + +Enums +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* ${x}_device_info_t + * ${X}_DEVICE_INFO_ASYNC_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_async_usm_alloc_flags_t + +Types +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +${x}_exp_async_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_ASYNC_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..39c129580f --- /dev/null +++ b/scripts/core/exp-async-alloc.yml @@ -0,0 +1,254 @@ +# +# 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 asynchronous allocations" +ordinal: "99" + +--- #-------------------------------------------------------------------------- +type: enum +extend: true +typed_etors: true +desc: "Extension enums to $x_device_info_t to support async allocations." +name: $x_device_info_t +etors: + - name: ASYNC_USM_ALLOCATIONS_EXP + value: "0x2024" + desc: "[$x_bool_t] returns true if the device supports enqueueing of native work" + +--- #-------------------------------------------------------------------------- +type: enum +extend: true +name: $x_usm_pool_flags_t +desc: "USM memory property flag for creating a native USM pool" +etors: + - name: USE_NATIVE_MEMORY_POOL_EXP + value: "$X_BIT(1)" + desc: "Use the native memory pool API" + +--- #-------------------------------------------------------------------------- +type: enum +extend: true +desc: "Command Type experimental enumerations." +name: $x_command_t +etors: + - name: ENQUEUE_USM_DEVICE_ALLOC_EXP + value: "0x2008" + desc: Event created by $xEnqueueDeviceAllocExp + - name: ENQUEUE_USM_SHARED_ALLOC_EXP + value: "0x2010" + desc: Event created by $xEnqueueSharedAllocExp + - name: ENQUEUE_USM_HOST_ALLOC_EXP + value: "0x2011" + desc: Event created by $xEnqueueHostAllocExp + - name: ENQUEUE_USM_FREE_EXP + value: "0x2012" + desc: Event created by $xEnqueueFreeExp + +--- #-------------------------------------------------------------------------- +type: enum +desc: "Async alloc properties" +name: $x_exp_async_usm_alloc_flags_t +etors: + - name: TBD + desc: "reserved for future use." + +--- #-------------------------------------------------------------------------- +type: struct +desc: "Async alloc properties" +name: $x_exp_async_usm_alloc_properties_t +base: $x_base_properties_t +members: + - type: $x_exp_async_usm_alloc_flags_t + name: flags + desc: "[in] async alloc 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_async_usm_alloc_properties_t + value: "0x3001" + +--- #-------------------------------------------------------------------------- +type: function +desc: "Enqueue an async 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] USM pool descriptor" + 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_async_usm_alloc_properties_t* + name: pProperties + desc: "[in][optional] pointer to the enqueue async alloc 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 async alloc" +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 async 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] USM pool descriptor" + 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_async_usm_alloc_properties_t* + name: pProperties + desc: "[in][optional] pointer to the enqueue async alloc 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 async alloc" +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 async 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] USM pool descriptor" + 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_async_usm_alloc_properties_t* + name: pProperties + desc: "[in][optional] pointer to the enqueue async alloc 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 async alloc" +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 async host allocation" +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] USM pool descriptor" + 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 async alloc" +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: "Create USM memory pool with desired properties." +class: $xUSM +name: PoolCreateExp +ordinal: "0" +details: + - "Create a memory pool associated with a single device." + - "See also $xUSMPoolCrearte and $x_usm_pool_limits_desc_t." +params: + - type: $x_context_handle_t + name: hContext + desc: "[in] handle of the context object" + - type: $x_device_handle_t + name: hDevice + desc: "[in] handle of the device object" + - type: $x_usm_pool_desc_t* + name: pPoolDesc + desc: "[in] pointer to USM pool descriptor. Can be chained with $x_usm_pool_limits_desc_t" + - type: $x_usm_pool_handle_t* + name: ppPool + desc: "[out] pointer to USM memory pool" +returns: + - $X_RESULT_ERROR_INVALID_NULL_HANDLE + - $X_RESULT_ERROR_INVALID_VALUE + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If any device associated with `hContext` reports `false` for $X_DEVICE_INFO_USM_POOL_SUPPORT" diff --git a/scripts/core/registry.yml b/scripts/core/registry.yml index 2ae34fb0b4..ad4ec2a51b 100644 --- a/scripts/core/registry.yml +++ b/scripts/core/registry.yml @@ -616,6 +616,21 @@ 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' +- name: USM_POOL_CREATE_EXP + desc: Enumerator for $xUSMPoolCreateExp + value: '254' --- type: enum desc: Defines structure types diff --git a/source/adapters/cuda/CMakeLists.txt b/source/adapters/cuda/CMakeLists.txt index 3d0418fd07..9c235710cd 100644 --- a/source/adapters/cuda/CMakeLists.txt +++ b/source/adapters/cuda/CMakeLists.txt @@ -10,6 +10,7 @@ add_ur_adapter(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/ur_interface_loader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/adapter.hpp ${CMAKE_CURRENT_SOURCE_DIR}/adapter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/async_alloc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.hpp ${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/common.hpp diff --git a/source/adapters/cuda/async_alloc.cpp b/source/adapters/cuda/async_alloc.cpp new file mode 100644 index 0000000000..ea02bdcf0c --- /dev/null +++ b/source/adapters/cuda/async_alloc.cpp @@ -0,0 +1,147 @@ +//===--------- async_alloc.cpp - CUDA Adapter -----------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include + +#include "context.hpp" +#include "enqueue.hpp" +#include "event.hpp" +#include "queue.hpp" +#include "usm.hpp" + +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_async_usm_alloc_properties_t *, uint32_t numEventsInWaitList, + const ur_event_handle_t *phEventWaitList, void **ppMem, + ur_event_handle_t *phEvent) try { + std::unique_ptr RetImplEvent{nullptr}; + + ScopedContext Active(hQueue->getDevice()); + uint32_t StreamToken; + ur_stream_guard_ Guard; + CUstream CuStream = hQueue->getNextComputeStream( + numEventsInWaitList, phEventWaitList, Guard, &StreamToken); + + UR_CHECK_ERROR(enqueueEventsWait(hQueue, CuStream, numEventsInWaitList, + phEventWaitList)); + + if (phEvent) { + RetImplEvent = + std::unique_ptr(ur_event_handle_t_::makeNative( + UR_COMMAND_KERNEL_LAUNCH, hQueue, CuStream, StreamToken)); + UR_CHECK_ERROR(RetImplEvent->start()); + } + + if (pPool) { + assert(pPool->usesCudaPool()); + UR_CHECK_ERROR( + cuMemAllocFromPoolAsync(reinterpret_cast(ppMem), size, + pPool->getCudaPool(), CuStream)); + } else { + UR_CHECK_ERROR(cuMemAllocAsync(reinterpret_cast(ppMem), size, + CuStream)); + } + + if (phEvent) { + UR_CHECK_ERROR(RetImplEvent->record()); + *phEvent = RetImplEvent.release(); + } + + return UR_RESULT_SUCCESS; +} catch (ur_result_t Err) { + return Err; +} + +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_async_usm_alloc_properties_t *, uint32_t numEventsInWaitList, + const ur_event_handle_t *phEventWaitList, void **ppMem, + ur_event_handle_t *phEvent) try { + std::unique_ptr RetImplEvent{nullptr}; + + ScopedContext Active(hQueue->getDevice()); + uint32_t StreamToken; + ur_stream_guard_ Guard; + CUstream CuStream = hQueue->getNextComputeStream( + numEventsInWaitList, phEventWaitList, Guard, &StreamToken); + + UR_CHECK_ERROR(enqueueEventsWait(hQueue, CuStream, numEventsInWaitList, + phEventWaitList)); + + if (phEvent) { + RetImplEvent = + std::unique_ptr(ur_event_handle_t_::makeNative( + UR_COMMAND_KERNEL_LAUNCH, hQueue, CuStream, StreamToken)); + UR_CHECK_ERROR(RetImplEvent->start()); + } + + if (pPool) { + assert(pPool->usesCudaPool()); + assert(pPool->usesCudaHostPool() && "Memory pool does not use" + " host mem pooling"); + UR_CHECK_ERROR( + cuMemAllocFromPoolAsync(reinterpret_cast(ppMem), size, + pPool->getCudaPool(), CuStream)); + } else { + // Can only use host async allocations if pool is created in advance + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + if (phEvent) { + UR_CHECK_ERROR(RetImplEvent->record()); + *phEvent = RetImplEvent.release(); + } + + return UR_RESULT_SUCCESS; +} catch (ur_result_t Err) { + return Err; +} + +// CUDA doesn't support memory pools with CUDA managed mem +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMSharedAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMFreeExp( + ur_queue_handle_t hQueue, [[maybe_unused]] ur_usm_pool_handle_t pPool, + void *pMem, uint32_t numEventsInWaitList, + const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent) try { + std::unique_ptr RetImplEvent{nullptr}; + + ScopedContext Active(hQueue->getDevice()); + uint32_t StreamToken; + ur_stream_guard_ Guard; + CUstream CuStream = hQueue->getNextComputeStream( + numEventsInWaitList, phEventWaitList, Guard, &StreamToken); + + UR_CHECK_ERROR(enqueueEventsWait(hQueue, CuStream, numEventsInWaitList, + phEventWaitList)); + + if (phEvent) { + RetImplEvent = + std::unique_ptr(ur_event_handle_t_::makeNative( + UR_COMMAND_KERNEL_LAUNCH, hQueue, CuStream, StreamToken)); + UR_CHECK_ERROR(RetImplEvent->start()); + } + + UR_CHECK_ERROR(cuMemFreeAsync(reinterpret_cast(pMem), CuStream)); + + if (phEvent) { + UR_CHECK_ERROR(RetImplEvent->record()); + *phEvent = RetImplEvent.release(); + } + + return UR_RESULT_SUCCESS; +} catch (ur_result_t Err) { + return Err; +} diff --git a/source/adapters/cuda/ur_interface_loader.cpp b/source/adapters/cuda/ur_interface_loader.cpp index ad0d775be0..3f791e07e7 100644 --- a/source/adapters/cuda/ur_interface_loader.cpp +++ b/source/adapters/cuda/ur_interface_loader.cpp @@ -242,6 +242,7 @@ urGetUSMProcAddrTable(ur_api_version_t version, ur_usm_dditable_t *pDdiTable) { pDdiTable->pfnGetMemAllocInfo = urUSMGetMemAllocInfo; pDdiTable->pfnHostAlloc = urUSMHostAlloc; pDdiTable->pfnPoolCreate = urUSMPoolCreate; + pDdiTable->pfnPoolCreate = urUSMPoolCreate; pDdiTable->pfnPoolRetain = urUSMPoolRetain; pDdiTable->pfnPoolRelease = urUSMPoolRelease; pDdiTable->pfnPoolGetInfo = urUSMPoolGetInfo; @@ -364,6 +365,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMExpProcAddrTable( return result; } pDdiTable->pfnPitchedAllocExp = urUSMPitchedAllocExp; + pDdiTable->pfnPoolCreateExp = urUSMPoolCreateExp; return UR_RESULT_SUCCESS; } @@ -418,6 +420,10 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEnqueueExpProcAddrTable( pDdiTable->pfnTimestampRecordingExp = urEnqueueTimestampRecordingExp; pDdiTable->pfnKernelLaunchCustomExp = urEnqueueKernelLaunchCustomExp; pDdiTable->pfnNativeCommandExp = urEnqueueNativeCommandExp; + pDdiTable->pfnUSMDeviceAllocExp = urEnqueueUSMDeviceAllocExp; + pDdiTable->pfnUSMSharedAllocExp = urEnqueueUSMSharedAllocExp; + pDdiTable->pfnUSMHostAllocExp = urEnqueueUSMHostAllocExp; + pDdiTable->pfnUSMFreeExp = urEnqueueUSMFreeExp; return UR_RESULT_SUCCESS; } diff --git a/source/adapters/cuda/usm.cpp b/source/adapters/cuda/usm.cpp index 863d90cd79..a41aacadc5 100644 --- a/source/adapters/cuda/usm.cpp +++ b/source/adapters/cuda/usm.cpp @@ -379,6 +379,7 @@ ur_result_t USMHostMemoryProvider::allocateImpl(void **ResultPtr, size_t Size, ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context, ur_usm_pool_desc_t *PoolDesc) : Context{Context} { + CUmemPoolProps MemPoolProps{}; // Used if native mem pools are used const void *pNext = PoolDesc->pNext; while (pNext != nullptr) { const ur_base_desc_t *BaseDesc = static_cast(pNext); @@ -386,9 +387,13 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context, case UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC: { const ur_usm_pool_limits_desc_t *Limits = reinterpret_cast(BaseDesc); - for (auto &config : DisjointPoolConfigs.Configs) { - config.MaxPoolableSize = Limits->maxPoolableSize; - config.SlabMinSize = Limits->minDriverAllocSize; + if (PoolDesc->flags & UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP) { + MemPoolProps.maxSize = Limits->maxPoolableSize; + } else { + for (auto &config : DisjointPoolConfigs.Configs) { + config.MaxPoolableSize = Limits->maxPoolableSize; + config.SlabMinSize = Limits->minDriverAllocSize; + } } break; } @@ -399,6 +404,14 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context, pNext = BaseDesc->pNext; } + if (PoolDesc->flags & UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP) { + MemPoolProps.allocType = CU_MEM_ALLOCATION_TYPE_PINNED; + MemPoolProps.location.type = CU_MEM_LOCATION_TYPE_HOST; // Alternatives are: + UR_CHECK_ERROR(cuMemPoolCreate(&CUmemPool, &MemPoolProps)); + CUHostMemPool = true; + return; + } + auto MemProvider = umf::memoryProviderMakeUnique(Context, nullptr) .second; @@ -433,6 +446,48 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context, } } +ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context, + ur_device_handle_t Device, + ur_usm_pool_desc_t *PoolDesc) + : Context{Context}, Device{Device} { + if (!(PoolDesc->flags & UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP)) + throw; + + CUmemPoolProps MemPoolProps{}; + + const void *pNext = PoolDesc->pNext; + while (pNext != nullptr) { + const ur_base_desc_t *BaseDesc = static_cast(pNext); + switch (BaseDesc->stype) { + case UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC: { + const ur_usm_pool_limits_desc_t *Limits = + reinterpret_cast(BaseDesc); + MemPoolProps.maxSize = Limits->maxPoolableSize; + std::ignore = Limits->minDriverAllocSize; // FIXME: We don't do anything + // with this. Can we/do we need + // to do something with this? + break; + } + default: { + throw UsmAllocationException(UR_RESULT_ERROR_INVALID_ARGUMENT); + } + } + pNext = BaseDesc->pNext; + } + + // TODO: what flags should be used here. Moreover what flags should have + // UR counterparts? + MemPoolProps.allocType = CU_MEM_ALLOCATION_TYPE_PINNED; + MemPoolProps.location.id = + Device + ->getIndex(); // Clarification of what id means here: + // https://forums.developer.nvidia.com/t/incomplete-description-in-cumemlocation-v1-struct-reference/318701 + MemPoolProps.location.type = + CU_MEM_LOCATION_TYPE_DEVICE; // Alternatives are: + // HOST, HOST_NUMA and HOST_NUMA_CURRENT + UR_CHECK_ERROR(cuMemPoolCreate(&CUmemPool, &MemPoolProps)); +} + bool ur_usm_pool_handle_t_::hasUMFPool(umf_memory_pool_t *umf_pool) { return DeviceMemPool.get() == umf_pool || SharedMemPool.get() == umf_pool || HostMemPool.get() == umf_pool; @@ -445,28 +500,54 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMPoolCreate( ///< ::ur_usm_pool_limits_desc_t ur_usm_pool_handle_t *Pool ///< [out] pointer to USM memory pool ) { - // Without pool tracking we can't free pool allocations. -#ifdef UMF_ENABLE_POOL_TRACKING if (PoolDesc->flags & UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } + // Host mem pool using CUDA entrypoint + if (PoolDesc->flags & UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP || + // Without pool tracking we can't free pool allocations. +#ifdef UMF_ENABLE_POOL_TRACKING + // UMF mem pool + true +#else + false +#endif + ) { + try { + *Pool = reinterpret_cast( + new ur_usm_pool_handle_t_(Context, PoolDesc)); + } catch (const UsmAllocationException &Ex) { + return Ex.getError(); + } catch (umf_result_t e) { + return umf::umf2urResult(e); + } catch (...) { + return UR_RESULT_ERROR_UNKNOWN; + } + return UR_RESULT_SUCCESS; + } + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urUSMPoolCreateExp( + ur_context_handle_t Context, ///< [in] handle of the context object + ur_device_handle_t Device, ///< [in] handle of the device object + ur_usm_pool_desc_t *PoolDesc, ///< [in] pointer to USM pool descriptor. + ///< Can be chained with + ///< ::ur_usm_pool_limits_desc_t + ur_usm_pool_handle_t *Pool ///< [out] pointer to USM memory pool +) { + // This entry point only supports native mem pools + if (!(PoolDesc->flags & UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP)) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; try { *Pool = reinterpret_cast( - new ur_usm_pool_handle_t_(Context, PoolDesc)); - } catch (const UsmAllocationException &Ex) { - return Ex.getError(); - } catch (umf_result_t e) { - return umf::umf2urResult(e); + new ur_usm_pool_handle_t_(Context, Device, PoolDesc)); + } catch (ur_result_t err) { + return err; } catch (...) { return UR_RESULT_ERROR_UNKNOWN; } return UR_RESULT_SUCCESS; -#else - std::ignore = Context; - std::ignore = PoolDesc; - std::ignore = Pool; - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -#endif } UR_APIEXPORT ur_result_t UR_APICALL urUSMPoolRetain( diff --git a/source/adapters/cuda/usm.hpp b/source/adapters/cuda/usm.hpp index 7c6a2ea666..2b97dc9d7f 100644 --- a/source/adapters/cuda/usm.hpp +++ b/source/adapters/cuda/usm.hpp @@ -15,10 +15,13 @@ usm::DisjointPoolAllConfigs InitializeDisjointPoolConfig(); +// A ur_usm_pool_handle_t can represent different types of memory pools. It may +// sit on top of a UMF pool or a CUmemoryPool, but not both. struct ur_usm_pool_handle_t_ { std::atomic_uint32_t RefCount = 1; ur_context_handle_t Context = nullptr; + ur_device_handle_t Device = nullptr; usm::DisjointPoolAllConfigs DisjointPoolConfigs = usm::DisjointPoolAllConfigs(); @@ -27,9 +30,16 @@ struct ur_usm_pool_handle_t_ { umf::pool_unique_handle_t SharedMemPool; umf::pool_unique_handle_t HostMemPool; + CUmemoryPool CUmemPool{0}; + bool CUHostMemPool = false; + ur_usm_pool_handle_t_(ur_context_handle_t Context, ur_usm_pool_desc_t *PoolDesc); + // TODO: do we need the context param? + ur_usm_pool_handle_t_(ur_context_handle_t Context, ur_device_handle_t Device, + ur_usm_pool_desc_t *PoolDesc); + uint32_t incrementReferenceCount() noexcept { return ++RefCount; } uint32_t decrementReferenceCount() noexcept { return --RefCount; } @@ -37,6 +47,11 @@ struct ur_usm_pool_handle_t_ { uint32_t getReferenceCount() const noexcept { return RefCount; } bool hasUMFPool(umf_memory_pool_t *umf_pool); + + // To be used if ur_usm_pool_handle_t represents a CUmemoryPool + bool usesCudaPool() const { return CUmemPool != CUmemoryPool{0}; }; + bool usesCudaHostPool() const { return CUHostMemPool; }; + CUmemoryPool getCudaPool() { return CUmemPool; }; }; // Exception type to pass allocation errors diff --git a/source/adapters/hip/CMakeLists.txt b/source/adapters/hip/CMakeLists.txt index 36222907c6..eb096995e3 100644 --- a/source/adapters/hip/CMakeLists.txt +++ b/source/adapters/hip/CMakeLists.txt @@ -59,6 +59,7 @@ add_ur_adapter(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/ur_interface_loader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/adapter.hpp ${CMAKE_CURRENT_SOURCE_DIR}/adapter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/async_alloc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.hpp ${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/common.hpp diff --git a/source/adapters/hip/async_alloc.cpp b/source/adapters/hip/async_alloc.cpp new file mode 100644 index 0000000000..bf7bcb10bd --- /dev/null +++ b/source/adapters/hip/async_alloc.cpp @@ -0,0 +1,40 @@ +//===--------- async_alloc.cpp - CUDA Adapter -----------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include + +UR_APIEXPORT ur_result_t urEnqueueUSMDeviceAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMSharedAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMHostAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMFreeExp(ur_queue_handle_t, + ur_usm_pool_handle_t, void *, + uint32_t, + const ur_event_handle_t *, + ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/source/adapters/level_zero/CMakeLists.txt b/source/adapters/level_zero/CMakeLists.txt index 39031a700d..4c866aac8c 100644 --- a/source/adapters/level_zero/CMakeLists.txt +++ b/source/adapters/level_zero/CMakeLists.txt @@ -13,6 +13,7 @@ if(UR_BUILD_ADAPTER_L0) ${CMAKE_CURRENT_SOURCE_DIR}/ur_interface_loader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/adapter.hpp ${CMAKE_CURRENT_SOURCE_DIR}/adapter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/async_alloc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.hpp ${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/common.hpp diff --git a/source/adapters/level_zero/async_alloc.cpp b/source/adapters/level_zero/async_alloc.cpp new file mode 100644 index 0000000000..bf7bcb10bd --- /dev/null +++ b/source/adapters/level_zero/async_alloc.cpp @@ -0,0 +1,40 @@ +//===--------- async_alloc.cpp - CUDA Adapter -----------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include + +UR_APIEXPORT ur_result_t urEnqueueUSMDeviceAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMSharedAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMHostAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMFreeExp(ur_queue_handle_t, + ur_usm_pool_handle_t, void *, + uint32_t, + const ur_event_handle_t *, + ur_event_handle_t *) { + 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 1419c8a606..77157e2c38 100644 --- a/source/adapters/level_zero/ur_interface_loader.cpp +++ b/source/adapters/level_zero/ur_interface_loader.cpp @@ -215,6 +215,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 = @@ -464,6 +468,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetUSMExpProcAddrTable( return result; } + pDdiTable->pfnPoolCreateExp = ur::level_zero::urUSMPoolCreateExp; pDdiTable->pfnPitchedAllocExp = ur::level_zero::urUSMPitchedAllocExp; pDdiTable->pfnImportExp = ur::level_zero::urUSMImportExp; pDdiTable->pfnReleaseExp = ur::level_zero::urUSMReleaseExp; diff --git a/source/adapters/level_zero/ur_interface_loader.hpp b/source/adapters/level_zero/ur_interface_loader.hpp index 5bd7c904f1..e6d120ec08 100644 --- a/source/adapters/level_zero/ur_interface_loader.hpp +++ b/source/adapters/level_zero/ur_interface_loader.hpp @@ -465,6 +465,30 @@ 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_async_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_async_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_async_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 urUSMPoolCreateExp(ur_context_handle_t hContext, + ur_device_handle_t hDevice, + ur_usm_pool_desc_t *pPoolDesc, + ur_usm_pool_handle_t *ppPool); 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/v2/queue_api.cpp b/source/adapters/level_zero/v2/queue_api.cpp index e4659b5f2c..1886fba04e 100644 --- a/source/adapters/level_zero/v2/queue_api.cpp +++ b/source/adapters/level_zero/v2/queue_api.cpp @@ -335,6 +335,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_async_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_async_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_async_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 c59f084fc4..9431ea8da2 100644 --- a/source/adapters/level_zero/v2/queue_api.hpp +++ b/source/adapters/level_zero/v2/queue_api.hpp @@ -125,6 +125,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_async_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_async_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_async_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/mock/ur_mockddi.cpp b/source/adapters/mock/ur_mockddi.cpp index b60be1d561..35735c768b 100644 --- a/source/adapters/mock/ur_mockddi.cpp +++ b/source/adapters/mock/ur_mockddi.cpp @@ -7160,6 +7160,297 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMDeviceAllocExp +__urdlllocal 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] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc + ) 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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc + ) 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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc + ) 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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + 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 async alloc + ) 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 urUSMPoolCreateExp +__urdlllocal ur_result_t UR_APICALL urUSMPoolCreateExp( + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_usm_pool_desc_t * + pPoolDesc, ///< [in] pointer to USM pool descriptor. Can be chained with + ///< ::ur_usm_pool_limits_desc_t + ur_usm_pool_handle_t *ppPool ///< [out] pointer to USM memory pool + ) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_usm_pool_create_exp_params_t params = {&hContext, &hDevice, &pPoolDesc, + &ppPool}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urUSMPoolCreateExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urUSMPoolCreateExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + *ppPool = mock::createDummyHandle(); + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urUSMPoolCreateExp")); + 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( @@ -11332,6 +11623,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; @@ -11891,6 +12190,8 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMExpProcAddrTable( ur_result_t result = UR_RESULT_SUCCESS; + pDdiTable->pfnPoolCreateExp = driver::urUSMPoolCreateExp; + pDdiTable->pfnPitchedAllocExp = driver::urUSMPitchedAllocExp; pDdiTable->pfnImportExp = driver::urUSMImportExp; diff --git a/source/adapters/native_cpu/CMakeLists.txt b/source/adapters/native_cpu/CMakeLists.txt index 69f7fff6bd..b05f91cb55 100644 --- a/source/adapters/native_cpu/CMakeLists.txt +++ b/source/adapters/native_cpu/CMakeLists.txt @@ -10,6 +10,7 @@ set(TARGET_NAME ur_adapter_native_cpu) add_ur_adapter(${TARGET_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/adapter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/async_alloc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/common.cpp ${CMAKE_CURRENT_SOURCE_DIR}/common.hpp diff --git a/source/adapters/native_cpu/async_alloc.cpp b/source/adapters/native_cpu/async_alloc.cpp new file mode 100644 index 0000000000..bf7bcb10bd --- /dev/null +++ b/source/adapters/native_cpu/async_alloc.cpp @@ -0,0 +1,40 @@ +//===--------- async_alloc.cpp - CUDA Adapter -----------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include + +UR_APIEXPORT ur_result_t urEnqueueUSMDeviceAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMSharedAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMHostAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMFreeExp(ur_queue_handle_t, + ur_usm_pool_handle_t, void *, + uint32_t, + const ur_event_handle_t *, + ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/source/adapters/opencl/CMakeLists.txt b/source/adapters/opencl/CMakeLists.txt index e091012bab..0190024052 100644 --- a/source/adapters/opencl/CMakeLists.txt +++ b/source/adapters/opencl/CMakeLists.txt @@ -16,6 +16,7 @@ add_ur_adapter(${TARGET_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/ur_interface_loader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/adapter.hpp ${CMAKE_CURRENT_SOURCE_DIR}/adapter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/async_alloc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.hpp ${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/common.hpp diff --git a/source/adapters/opencl/async_alloc.cpp b/source/adapters/opencl/async_alloc.cpp new file mode 100644 index 0000000000..bf7bcb10bd --- /dev/null +++ b/source/adapters/opencl/async_alloc.cpp @@ -0,0 +1,40 @@ +//===--------- async_alloc.cpp - CUDA Adapter -----------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include + +UR_APIEXPORT ur_result_t urEnqueueUSMDeviceAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMSharedAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMHostAllocExp( + ur_queue_handle_t, ur_usm_pool_handle_t, const size_t, + const ur_exp_async_usm_alloc_properties_t *, uint32_t, + const ur_event_handle_t *, void **, ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t urEnqueueUSMFreeExp(ur_queue_handle_t, + ur_usm_pool_handle_t, void *, + uint32_t, + const ur_event_handle_t *, + ur_event_handle_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/source/common/stype_map_helpers.def b/source/common/stype_map_helpers.def index ec2856e60d..2099d58f66 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 55f8d00bea..47fc03763b 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -6082,6 +6082,254 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMDeviceAllocExp +__urdlllocal 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] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + 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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + 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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + 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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + 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 async alloc +) { + 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 urUSMPoolCreateExp +__urdlllocal ur_result_t UR_APICALL urUSMPoolCreateExp( + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_usm_pool_desc_t * + pPoolDesc, ///< [in] pointer to USM pool descriptor. Can be chained with + ///< ::ur_usm_pool_limits_desc_t + ur_usm_pool_handle_t *ppPool ///< [out] pointer to USM memory pool +) { + auto pfnPoolCreateExp = getContext()->urDdiTable.USMExp.pfnPoolCreateExp; + + if (nullptr == pfnPoolCreateExp) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ur_usm_pool_create_exp_params_t params = {&hContext, &hDevice, &pPoolDesc, + &ppPool}; + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_USM_POOL_CREATE_EXP, "urUSMPoolCreateExp", ¶ms); + + auto &logger = getContext()->logger; + logger.info(" ---> urUSMPoolCreateExp\n"); + + ur_result_t result = pfnPoolCreateExp(hContext, hDevice, pPoolDesc, ppPool); + + getContext()->notify_end(UR_FUNCTION_USM_POOL_CREATE_EXP, + "urUSMPoolCreateExp", ¶ms, &result, instance); + + if (logger.getLevel() <= logger::Level::INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_USM_POOL_CREATE_EXP, ¶ms); + logger.info(" <--- urUSMPoolCreateExp({}) -> {};\n", args_str.str(), + result); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urUSMPitchedAllocExp __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( @@ -9925,6 +10173,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 = @@ -10613,6 +10875,9 @@ __urdlllocal ur_result_t UR_APICALL urGetUSMExpProcAddrTable( ur_result_t result = UR_RESULT_SUCCESS; + dditable.pfnPoolCreateExp = pDdiTable->pfnPoolCreateExp; + pDdiTable->pfnPoolCreateExp = ur_tracing_layer::urUSMPoolCreateExp; + dditable.pfnPitchedAllocExp = pDdiTable->pfnPitchedAllocExp; pDdiTable->pfnPitchedAllocExp = ur_tracing_layer::urUSMPitchedAllocExp; diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 6e48f79edc..d130f3ecb2 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -518,7 +518,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_DEVICE_INFO_2D_BLOCK_ARRAY_CAPABILITIES_EXP < propName) { + if (UR_DEVICE_INFO_ASYNC_USM_ALLOCATIONS_EXP < propName) { return UR_RESULT_ERROR_INVALID_ENUMERATION; } @@ -6927,6 +6927,312 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMDeviceAllocExp +__urdlllocal 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] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + 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 async alloc +) { + 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 urUSMPoolCreateExp +__urdlllocal ur_result_t UR_APICALL urUSMPoolCreateExp( + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_usm_pool_desc_t * + pPoolDesc, ///< [in] pointer to USM pool descriptor. Can be chained with + ///< ::ur_usm_pool_limits_desc_t + ur_usm_pool_handle_t *ppPool ///< [out] pointer to USM memory pool +) { + auto pfnPoolCreateExp = getContext()->urDdiTable.USMExp.pfnPoolCreateExp; + + if (nullptr == pfnPoolCreateExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hContext) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (NULL == hDevice) { + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (NULL == pPoolDesc) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (NULL == ppPool) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (UR_USM_POOL_FLAGS_MASK & pPoolDesc->flags) { + return UR_RESULT_ERROR_INVALID_ENUMERATION; + } + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hContext)) { + getContext()->refCountContext->logInvalidReference(hContext); + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hDevice)) { + getContext()->refCountContext->logInvalidReference(hDevice); + } + + ur_result_t result = pfnPoolCreateExp(hContext, hDevice, pPoolDesc, ppPool); + + if (getContext()->enableLeakChecking && result == UR_RESULT_SUCCESS) { + getContext()->refCountContext->createRefCount(*ppPool); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urUSMPitchedAllocExp __urdlllocal ur_result_t UR_APICALL urUSMPitchedAllocExp( @@ -11046,6 +11352,21 @@ 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 = @@ -11754,6 +12075,9 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMExpProcAddrTable( ur_result_t result = UR_RESULT_SUCCESS; + dditable.pfnPoolCreateExp = pDdiTable->pfnPoolCreateExp; + pDdiTable->pfnPoolCreateExp = ur_validation_layer::urUSMPoolCreateExp; + dditable.pfnPitchedAllocExp = pDdiTable->pfnPitchedAllocExp; pDdiTable->pfnPitchedAllocExp = ur_validation_layer::urUSMPitchedAllocExp; diff --git a/source/loader/loader.def.in b/source/loader/loader.def.in index a3a18a4170..9322d27bea 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 @@ -289,11 +293,15 @@ EXPORTS urPrintEnqueueReadHostPipeParams urPrintEnqueueTimestampRecordingExpParams urPrintEnqueueUsmAdviseParams + urPrintEnqueueUsmDeviceAllocExpParams urPrintEnqueueUsmFillParams urPrintEnqueueUsmFill_2dParams + urPrintEnqueueUsmFreeExpParams + urPrintEnqueueUsmHostAllocExpParams urPrintEnqueueUsmMemcpyParams urPrintEnqueueUsmMemcpy_2dParams urPrintEnqueueUsmPrefetchParams + urPrintEnqueueUsmSharedAllocExpParams urPrintEnqueueWriteHostPipeParams urPrintEventCreateWithNativeHandleParams urPrintEventGetInfoParams @@ -307,6 +315,8 @@ EXPORTS urPrintEventStatus urPrintEventWaitParams urPrintExecutionInfo + urPrintExpAsyncUsmAllocFlags + urPrintExpAsyncUsmAllocProperties urPrintExpCommandBufferCommandInfo urPrintExpCommandBufferDesc urPrintExpCommandBufferInfo @@ -494,6 +504,7 @@ EXPORTS urPrintUsmP2pEnablePeerAccessExpParams urPrintUsmP2pPeerAccessGetInfoExpParams urPrintUsmPitchedAllocExpParams + urPrintUsmPoolCreateExpParams urPrintUsmPoolCreateParams urPrintUsmPoolDesc urPrintUsmPoolFlags @@ -555,6 +566,7 @@ EXPORTS urUSMImportExp urUSMPitchedAllocExp urUSMPoolCreate + urUSMPoolCreateExp urUSMPoolGetInfo urUSMPoolRelease urUSMPoolRetain diff --git a/source/loader/loader.map.in b/source/loader/loader.map.in index 00a6de8c10..8b45b2875d 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; @@ -289,11 +293,15 @@ urPrintEnqueueReadHostPipeParams; urPrintEnqueueTimestampRecordingExpParams; urPrintEnqueueUsmAdviseParams; + urPrintEnqueueUsmDeviceAllocExpParams; urPrintEnqueueUsmFillParams; urPrintEnqueueUsmFill_2dParams; + urPrintEnqueueUsmFreeExpParams; + urPrintEnqueueUsmHostAllocExpParams; urPrintEnqueueUsmMemcpyParams; urPrintEnqueueUsmMemcpy_2dParams; urPrintEnqueueUsmPrefetchParams; + urPrintEnqueueUsmSharedAllocExpParams; urPrintEnqueueWriteHostPipeParams; urPrintEventCreateWithNativeHandleParams; urPrintEventGetInfoParams; @@ -307,6 +315,8 @@ urPrintEventStatus; urPrintEventWaitParams; urPrintExecutionInfo; + urPrintExpAsyncUsmAllocFlags; + urPrintExpAsyncUsmAllocProperties; urPrintExpCommandBufferCommandInfo; urPrintExpCommandBufferDesc; urPrintExpCommandBufferInfo; @@ -494,6 +504,7 @@ urPrintUsmP2pEnablePeerAccessExpParams; urPrintUsmP2pPeerAccessGetInfoExpParams; urPrintUsmPitchedAllocExpParams; + urPrintUsmPoolCreateExpParams; urPrintUsmPoolCreateParams; urPrintUsmPoolDesc; urPrintUsmPoolFlags; @@ -555,6 +566,7 @@ urUSMImportExp; urUSMPitchedAllocExp; urUSMPoolCreate; + urUSMPoolCreateExp; urUSMPoolGetInfo; urUSMPoolRelease; urUSMPoolRetain; diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index c74b9d6caf..828ade2859 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -6211,6 +6211,319 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueWriteHostPipe( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urEnqueueUSMDeviceAllocExp +__urdlllocal 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] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + 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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + 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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + 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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + 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 async alloc +) { + 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 urUSMPoolCreateExp +__urdlllocal ur_result_t UR_APICALL urUSMPoolCreateExp( + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_usm_pool_desc_t * + pPoolDesc, ///< [in] pointer to USM pool descriptor. Can be chained with + ///< ::ur_usm_pool_limits_desc_t + ur_usm_pool_handle_t *ppPool ///< [out] pointer to USM memory pool +) { + ur_result_t result = UR_RESULT_SUCCESS; + + [[maybe_unused]] auto context = getContext(); + + // extract platform's function pointer table + auto dditable = reinterpret_cast(hContext)->dditable; + auto pfnPoolCreateExp = dditable->ur.USMExp.pfnPoolCreateExp; + if (nullptr == pfnPoolCreateExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + // convert loader handle to platform handle + hContext = reinterpret_cast(hContext)->handle; + + // convert loader handle to platform handle + hDevice = reinterpret_cast(hDevice)->handle; + + // forward to device-platform + result = pfnPoolCreateExp(hContext, hDevice, pPoolDesc, ppPool); + + if (UR_RESULT_SUCCESS != result) { + return result; + } + + try { + // convert platform handle to loader handle + *ppPool = reinterpret_cast( + context->factories.ur_usm_pool_factory.getInstance(*ppPool, + 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( @@ -10098,6 +10411,12 @@ 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 = @@ -10959,6 +11278,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetUSMExpProcAddrTable( if (ur_loader::getContext()->platforms.size() != 1 || ur_loader::getContext()->forceIntercept) { // return pointers to loader's DDIs + pDdiTable->pfnPoolCreateExp = ur_loader::urUSMPoolCreateExp; pDdiTable->pfnPitchedAllocExp = ur_loader::urUSMPitchedAllocExp; pDdiTable->pfnImportExp = ur_loader::urUSMImportExp; pDdiTable->pfnReleaseExp = ur_loader::urUSMReleaseExp; diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index e257366a7f..df582af577 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -870,7 +870,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_ASYNC_USM_ALLOCATIONS_EXP < propName` /// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION /// + If `propName` is not supported by the adapter. /// - ::UR_RESULT_ERROR_INVALID_SIZE @@ -6598,6 +6598,224 @@ ur_result_t UR_APICALL urEnqueueWriteHostPipe( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an async 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc + ) 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 async 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc + ) 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 async 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc + ) 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 async 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_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + 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 async alloc + ) 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 Create USM memory pool with desired properties. +/// +/// @details +/// - Create a memory pool associated with a single device. +/// - See also ::urUSMPoolCrearte and ::ur_usm_pool_limits_desc_t. +/// +/// @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 == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pPoolDesc` +/// + `NULL == ppPool` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_USM_POOL_FLAGS_MASK & pPoolDesc->flags` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If any device associated with `hContext` reports `false` for ::UR_DEVICE_INFO_USM_POOL_SUPPORT +ur_result_t UR_APICALL urUSMPoolCreateExp( + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_usm_pool_desc_t * + pPoolDesc, ///< [in] pointer to USM pool descriptor. Can be chained with + ///< ::ur_usm_pool_limits_desc_t + ur_usm_pool_handle_t *ppPool ///< [out] pointer to USM memory pool + ) try { + auto pfnPoolCreateExp = + ur_lib::getContext()->urDdiTable.USMExp.pfnPoolCreateExp; + if (nullptr == pfnPoolCreateExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + return pfnPoolCreateExp(hContext, hDevice, pPoolDesc, ppPool); +} 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 02fd10f5f8..c1b9ce05b6 100644 --- a/source/loader/ur_print.cpp +++ b/source/loader/ur_print.cpp @@ -895,6 +895,23 @@ ur_result_t urPrintExpDevice_2dBlockArrayCapabilityFlags( return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t +urPrintExpAsyncUsmAllocFlags(enum ur_exp_async_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 urPrintExpAsyncUsmAllocProperties( + const struct ur_exp_async_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) { @@ -1829,6 +1846,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) { @@ -2662,6 +2711,14 @@ urPrintUsmPoolGetInfoParams(const struct ur_usm_pool_get_info_params_t *params, return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t urPrintUsmPoolCreateExpParams( + const struct ur_usm_pool_create_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 urPrintUsmPitchedAllocExpParams( const struct ur_usm_pitched_alloc_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 90b061dbc5..9894e2f7ce 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -771,7 +771,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_ASYNC_USM_ALLOCATIONS_EXP < propName` /// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION /// + If `propName` is not supported by the adapter. /// - ::UR_RESULT_ERROR_INVALID_SIZE @@ -5639,6 +5639,182 @@ ur_result_t UR_APICALL urEnqueueWriteHostPipe( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an async 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an async 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an async 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_ASYNC_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + const size_t + size, ///< [in] minimum size in bytes of the USM memory object to be allocated + const ur_exp_async_usm_alloc_properties_t * + pProperties, ///< [in][optional] pointer to the enqueue async alloc 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 async alloc +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Enqueue an async 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_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( + ur_queue_handle_t hQueue, ///< [in] handle of the queue object + ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor + 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 async alloc +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create USM memory pool with desired properties. +/// +/// @details +/// - Create a memory pool associated with a single device. +/// - See also ::urUSMPoolCrearte and ::ur_usm_pool_limits_desc_t. +/// +/// @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 == hContext` +/// + `NULL == hDevice` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == pPoolDesc` +/// + `NULL == ppPool` +/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION +/// + `::UR_USM_POOL_FLAGS_MASK & pPoolDesc->flags` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If any device associated with `hContext` reports `false` for ::UR_DEVICE_INFO_USM_POOL_SUPPORT +ur_result_t UR_APICALL urUSMPoolCreateExp( + ur_context_handle_t hContext, ///< [in] handle of the context object + ur_device_handle_t hDevice, ///< [in] handle of the device object + ur_usm_pool_desc_t * + pPoolDesc, ///< [in] pointer to USM pool descriptor. Can be chained with + ///< ::ur_usm_pool_limits_desc_t + ur_usm_pool_handle_t *ppPool ///< [out] pointer to USM memory pool +) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief USM allocate pitched memory /// diff --git a/test/conformance/CMakeLists.txt b/test/conformance/CMakeLists.txt index e71a829964..b9b12d855c 100644 --- a/test/conformance/CMakeLists.txt +++ b/test/conformance/CMakeLists.txt @@ -123,6 +123,7 @@ set(TEST_SUBDIRECTORIES_DPCXX "program" "enqueue" "integration" + "exp_async_alloc" "exp_command_buffer" "exp_enqueue_native" "exp_usm_p2p" diff --git a/test/conformance/exp_async_alloc/CMakeLists.txt b/test/conformance/exp_async_alloc/CMakeLists.txt new file mode 100644 index 0000000000..50195644a6 --- /dev/null +++ b/test/conformance/exp_async_alloc/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (C) 2025 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 + +add_conformance_test_with_kernels_environment( + exp_async_alloc + async_alloc.cpp +) diff --git a/test/conformance/exp_async_alloc/async_alloc.cpp b/test/conformance/exp_async_alloc/async_alloc.cpp new file mode 100644 index 0000000000..a9fd695400 --- /dev/null +++ b/test/conformance/exp_async_alloc/async_alloc.cpp @@ -0,0 +1,75 @@ +// 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 + +#include +#include + +using T = uint32_t; + +struct urAsyncAllocTest : uur::urQueueTest { + void SetUp() { + UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTest::SetUp()); + + host_vec = std::vector(global_size, 0); + ASSERT_EQ(host_vec.size(), global_size); + } + void TearDown() { + UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTest::TearDown()); + if (pool) { + UUR_RETURN_ON_FATAL_FAILURE(urUSMPoolRelease(pool)); + } + } + static constexpr T val = 42; + static constexpr uint32_t global_size = 1e7; + std::vector host_vec; + void *dev_ptr = nullptr; + static constexpr size_t allocation_size = sizeof(val) * global_size; + static constexpr size_t pool_size = 400; + static constexpr ur_usm_pool_limits_desc_t limits_desc{ + UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC, nullptr, pool_size, 1}; + ur_usm_pool_handle_t pool{0}; +}; + +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urAsyncAllocTest); + +#define SUCCESS_TEST(ALLOC_TYPE) \ + TEST_P(urAsyncAllocTest, SuccessNoPool##ALLOC_TYPE) { \ + ur_event_handle_t alloc_ev; \ + ASSERT_SUCCESS(urEnqueueUSM##ALLOC_TYPE##AllocExp( \ + queue, nullptr, 1, nullptr, 0, nullptr, &dev_ptr, &alloc_ev)); \ + ASSERT_SUCCESS(urEnqueueUSMFreeExp(queue, nullptr, dev_ptr, 1, \ + &alloc_ev, nullptr)); \ + } + +SUCCESS_TEST(Device) +SUCCESS_TEST(Shared) +SUCCESS_TEST(Host) + +TEST_P(urAsyncAllocTest, SuccessWithPoolDevice) { + ur_event_handle_t alloc_ev; + ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, &limits_desc, + UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP}; + // Use device specific mem pool creation + ASSERT_SUCCESS(urUSMPoolCreateExp(context, device, &pool_desc, &pool)); + + ASSERT_SUCCESS(urEnqueueUSMDeviceAllocExp(queue, pool, 1, nullptr, 0, + nullptr, &dev_ptr, &alloc_ev)); + ASSERT_SUCCESS( + urEnqueueUSMFreeExp(queue, pool, dev_ptr, 1, &alloc_ev, nullptr)); +} + +#define SUCCESS_TEST_POOL(ALLOC_TYPE) \ + TEST_P(urAsyncAllocTest, SuccessWithPool##) { \ + ur_event_handle_t alloc_ev; \ + limits_desc->next = TTOD; \ + ur_usm_pool_desc_t pool_desc{ \ + UR_STRUCTURE_TYPE_USM_POOL_DESC, &limits_desc, \ + UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP}; \ + ASSERT_SUCCESS(urUSMPoolCreate(context, &pool_desc, &pool)); \ + ASSERT_SUCCESS(urEnqueueUSMDeviceAllocExp( \ + queue, pool, 1, nullptr, 0, nullptr, &dev_ptr, &alloc_ev)); \ + ASSERT_SUCCESS( \ + urEnqueueUSMFreeExp(queue, pool, dev_ptr, 1, &alloc_ev, nullptr)); \ + } diff --git a/tools/urinfo/urinfo.hpp b/tools/urinfo/urinfo.hpp index 813ca34da1..015666e96e 100644 --- a/tools/urinfo/urinfo.hpp +++ b/tools/urinfo/urinfo.hpp @@ -425,5 +425,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_ASYNC_USM_ALLOCATIONS_EXP); } } // namespace urinfo