Skip to content

Commit 28ed14a

Browse files
Hugh Delaneykswiecicki
authored andcommitted
Add initial spec for async alloc entry points
First basic work in progress spec.
1 parent d8cc532 commit 28ed14a

23 files changed

+2468
-4
lines changed

include/ur_api.h

Lines changed: 218 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ typedef enum ur_function_t {
230230
UR_FUNCTION_COMMAND_BUFFER_UPDATE_SIGNAL_EVENT_EXP = 243, ///< Enumerator for ::urCommandBufferUpdateSignalEventExp
231231
UR_FUNCTION_COMMAND_BUFFER_UPDATE_WAIT_EVENTS_EXP = 244, ///< Enumerator for ::urCommandBufferUpdateWaitEventsExp
232232
UR_FUNCTION_BINDLESS_IMAGES_MAP_EXTERNAL_LINEAR_MEMORY_EXP = 245, ///< Enumerator for ::urBindlessImagesMapExternalLinearMemoryExp
233+
UR_FUNCTION_ENQUEUE_USM_DEVICE_ALLOC_EXP = 246, ///< Enumerator for ::urEnqueueUSMDeviceAllocExp
234+
UR_FUNCTION_ENQUEUE_USM_SHARED_ALLOC_EXP = 247, ///< Enumerator for ::urEnqueueUSMSharedAllocExp
235+
UR_FUNCTION_ENQUEUE_USM_HOST_ALLOC_EXP = 248, ///< Enumerator for ::urEnqueueUSMHostAllocExp
236+
UR_FUNCTION_ENQUEUE_USM_FREE_EXP = 249, ///< Enumerator for ::urEnqueueUSMFreeExp
233237
/// @cond
234238
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
235239
/// @endcond
@@ -288,6 +292,7 @@ typedef enum ur_structure_type_t {
288292
UR_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES = 0x2006, ///< ::ur_exp_sampler_cubemap_properties_t
289293
UR_STRUCTURE_TYPE_EXP_IMAGE_COPY_REGION = 0x2007, ///< ::ur_exp_image_copy_region_t
290294
UR_STRUCTURE_TYPE_EXP_ENQUEUE_NATIVE_COMMAND_PROPERTIES = 0x3000, ///< ::ur_exp_enqueue_native_command_properties_t
295+
UR_STRUCTURE_TYPE_EXP_ENQUEUE_USM_ALLOC_PROPERTIES = 0x3001, ///< ::ur_exp_async_usm_alloc_properties_t
291296
/// @cond
292297
UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff
293298
/// @endcond
@@ -1697,6 +1702,8 @@ typedef enum ur_device_info_t {
16971702
///< backed 2D sampled image data.
16981703
UR_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT_EXP = 0x2020, ///< [::ur_bool_t] returns true if the device supports enqueueing of native
16991704
///< work
1705+
UR_DEVICE_INFO_ASYNC_USM_ALLOCATIONS_EXP = 0x2021, ///< [::ur_bool_t] returns true if the device supports enqueueing of native
1706+
///< work
17001707
/// @cond
17011708
UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff
17021709
/// @endcond
@@ -1722,7 +1729,7 @@ typedef enum ur_device_info_t {
17221729
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
17231730
/// + `NULL == hDevice`
17241731
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
1725-
/// + `::UR_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT_EXP < propName`
1732+
/// + `::UR_DEVICE_INFO_ASYNC_USM_ALLOCATIONS_EXP < propName`
17261733
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
17271734
/// + If `propName` is not supported by the adapter.
17281735
/// - ::UR_RESULT_ERROR_INVALID_SIZE
@@ -5776,6 +5783,10 @@ typedef enum ur_command_t {
57765783
UR_COMMAND_EXTERNAL_SEMAPHORE_SIGNAL_EXP = 0x2001, ///< Event created by ::urBindlessImagesSignalExternalSemaphoreExp
57775784
UR_COMMAND_TIMESTAMP_RECORDING_EXP = 0x2002, ///< Event created by ::urEnqueueTimestampRecordingExp
57785785
UR_COMMAND_ENQUEUE_NATIVE_EXP = 0x2004, ///< Event created by ::urEnqueueNativeCommandExp
5786+
UR_COMMAND_ENQUEUE_USM_DEVICE_ALLOC_EXP = 0x2008, ///< Event created by ::urEnqueueDeviceAllocExp
5787+
UR_COMMAND_ENQUEUE_USM_SHARED_ALLOC_EXP = 0x2010, ///< Event created by ::urEnqueueSharedAllocExp
5788+
UR_COMMAND_ENQUEUE_USM_HOST_ALLOC_EXP = 0x2011, ///< Event created by ::urEnqueueHostAllocExp
5789+
UR_COMMAND_ENQUEUE_USM_FREE_EXP = 0x2012, ///< Event created by ::urEnqueueFreeExp
57795790
/// @cond
57805791
UR_COMMAND_FORCE_UINT32 = 0x7fffffff
57815792
/// @endcond
@@ -7403,6 +7414,154 @@ urEnqueueWriteHostPipe(
74037414
///< an element of the phEventWaitList array.
74047415
);
74057416

7417+
#if !defined(__GNUC__)
7418+
#pragma endregion
7419+
#endif
7420+
// Intel 'oneAPI' Unified Runtime Experimental API for asynchronous allocations
7421+
#if !defined(__GNUC__)
7422+
#pragma region async_alloc_(experimental)
7423+
#endif
7424+
///////////////////////////////////////////////////////////////////////////////
7425+
/// @brief Async alloc properties
7426+
typedef uint32_t ur_exp_async_usm_alloc_flags_t;
7427+
typedef enum ur_exp_async_usm_alloc_flag_t {
7428+
UR_EXP_ASYNC_USM_ALLOC_FLAG_TBD = UR_BIT(0), ///< reserved for future use.
7429+
/// @cond
7430+
UR_EXP_ASYNC_USM_ALLOC_FLAG_FORCE_UINT32 = 0x7fffffff
7431+
/// @endcond
7432+
7433+
} ur_exp_async_usm_alloc_flag_t;
7434+
/// @brief Bit Mask for validating ur_exp_async_usm_alloc_flags_t
7435+
#define UR_EXP_ASYNC_USM_ALLOC_FLAGS_MASK 0xfffffffe
7436+
7437+
///////////////////////////////////////////////////////////////////////////////
7438+
/// @brief Async alloc properties
7439+
typedef struct ur_exp_async_usm_alloc_properties_t {
7440+
ur_structure_type_t stype; ///< [in] type of this structure, must be
7441+
///< ::UR_STRUCTURE_TYPE_EXP_ASYNC_USM_ALLOC_PROPERTIES
7442+
void *pNext; ///< [in,out][optional] pointer to extension-specific structure
7443+
ur_exp_async_usm_alloc_flags_t flags; ///< [in] async alloc flags
7444+
7445+
} ur_exp_async_usm_alloc_properties_t;
7446+
7447+
///////////////////////////////////////////////////////////////////////////////
7448+
/// @brief Enqueue an async device allocation
7449+
///
7450+
/// @returns
7451+
/// - ::UR_RESULT_SUCCESS
7452+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
7453+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
7454+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
7455+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
7456+
/// + `NULL == hQueue`
7457+
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
7458+
/// + `NULL != pProperties && ::UR_EXP_ASYNC_USM_ALLOC_FLAGS_MASK & pProperties->flags`
7459+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
7460+
/// + `NULL == ppMem`
7461+
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
7462+
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
7463+
UR_APIEXPORT ur_result_t UR_APICALL
7464+
urEnqueueUSMDeviceAllocExp(
7465+
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
7466+
ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor
7467+
const size_t size, ///< [in] minimum size in bytes of the USM memory object to be allocated
7468+
const ur_exp_async_usm_alloc_properties_t *pProperties, ///< [in][optional] pointer to the enqueue async alloc properties
7469+
uint32_t numEventsInWaitList, ///< [in] size of the event wait list
7470+
const ur_event_handle_t *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of
7471+
///< events that must be complete before the kernel execution.
7472+
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
7473+
void **ppMem, ///< [out] pointer to USM memory object
7474+
ur_event_handle_t *phEvent ///< [out][optional] return an event object that identifies the async alloc
7475+
);
7476+
7477+
///////////////////////////////////////////////////////////////////////////////
7478+
/// @brief Enqueue an async shared allocation
7479+
///
7480+
/// @returns
7481+
/// - ::UR_RESULT_SUCCESS
7482+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
7483+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
7484+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
7485+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
7486+
/// + `NULL == hQueue`
7487+
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
7488+
/// + `NULL != pProperties && ::UR_EXP_ASYNC_USM_ALLOC_FLAGS_MASK & pProperties->flags`
7489+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
7490+
/// + `NULL == ppMem`
7491+
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
7492+
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
7493+
UR_APIEXPORT ur_result_t UR_APICALL
7494+
urEnqueueUSMSharedAllocExp(
7495+
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
7496+
ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor
7497+
const size_t size, ///< [in] minimum size in bytes of the USM memory object to be allocated
7498+
const ur_exp_async_usm_alloc_properties_t *pProperties, ///< [in][optional] pointer to the enqueue async alloc properties
7499+
uint32_t numEventsInWaitList, ///< [in] size of the event wait list
7500+
const ur_event_handle_t *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of
7501+
///< events that must be complete before the kernel execution.
7502+
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
7503+
void **ppMem, ///< [out] pointer to USM memory object
7504+
ur_event_handle_t *phEvent ///< [out][optional] return an event object that identifies the async alloc
7505+
);
7506+
7507+
///////////////////////////////////////////////////////////////////////////////
7508+
/// @brief Enqueue an async host allocation
7509+
///
7510+
/// @returns
7511+
/// - ::UR_RESULT_SUCCESS
7512+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
7513+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
7514+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
7515+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
7516+
/// + `NULL == hQueue`
7517+
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
7518+
/// + `NULL != pProperties && ::UR_EXP_ASYNC_USM_ALLOC_FLAGS_MASK & pProperties->flags`
7519+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
7520+
/// + `NULL == ppMem`
7521+
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
7522+
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
7523+
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
7524+
UR_APIEXPORT ur_result_t UR_APICALL
7525+
urEnqueueUSMHostAllocExp(
7526+
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
7527+
ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor
7528+
const size_t size, ///< [in] minimum size in bytes of the USM memory object to be allocated
7529+
const ur_exp_async_usm_alloc_properties_t *pProperties, ///< [in][optional] pointer to the enqueue async alloc properties
7530+
uint32_t numEventsInWaitList, ///< [in] size of the event wait list
7531+
const ur_event_handle_t *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of
7532+
///< events that must be complete before the kernel execution.
7533+
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
7534+
void **ppMem, ///< [out] pointer to USM memory object
7535+
ur_event_handle_t *phEvent ///< [out][optional] return an event object that identifies the async alloc
7536+
);
7537+
7538+
///////////////////////////////////////////////////////////////////////////////
7539+
/// @brief Enqueue an async host allocation
7540+
///
7541+
/// @returns
7542+
/// - ::UR_RESULT_SUCCESS
7543+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
7544+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
7545+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
7546+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
7547+
/// + `NULL == hQueue`
7548+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
7549+
/// + `NULL == pMem`
7550+
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
7551+
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
7552+
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
7553+
UR_APIEXPORT ur_result_t UR_APICALL
7554+
urEnqueueUSMFreeExp(
7555+
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
7556+
ur_usm_pool_handle_t pPool, ///< [in][optional] USM pool descriptor
7557+
void *pMem, ///< [in] pointer to USM memory object
7558+
uint32_t numEventsInWaitList, ///< [in] size of the event wait list
7559+
const ur_event_handle_t *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of
7560+
///< events that must be complete before the kernel execution.
7561+
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
7562+
ur_event_handle_t *phEvent ///< [out][optional] return an event object that identifies the async alloc
7563+
);
7564+
74067565
#if !defined(__GNUC__)
74077566
#pragma endregion
74087567
#endif
@@ -11432,6 +11591,64 @@ typedef struct ur_enqueue_kernel_launch_custom_exp_params_t {
1143211591
ur_event_handle_t **pphEvent;
1143311592
} ur_enqueue_kernel_launch_custom_exp_params_t;
1143411593

11594+
///////////////////////////////////////////////////////////////////////////////
11595+
/// @brief Function parameters for urEnqueueUSMDeviceAllocExp
11596+
/// @details Each entry is a pointer to the parameter passed to the function;
11597+
/// allowing the callback the ability to modify the parameter's value
11598+
typedef struct ur_enqueue_usm_device_alloc_exp_params_t {
11599+
ur_queue_handle_t *phQueue;
11600+
ur_usm_pool_handle_t *ppPool;
11601+
const size_t *psize;
11602+
const ur_exp_async_usm_alloc_properties_t **ppProperties;
11603+
uint32_t *pnumEventsInWaitList;
11604+
const ur_event_handle_t **pphEventWaitList;
11605+
void ***pppMem;
11606+
ur_event_handle_t **pphEvent;
11607+
} ur_enqueue_usm_device_alloc_exp_params_t;
11608+
11609+
///////////////////////////////////////////////////////////////////////////////
11610+
/// @brief Function parameters for urEnqueueUSMSharedAllocExp
11611+
/// @details Each entry is a pointer to the parameter passed to the function;
11612+
/// allowing the callback the ability to modify the parameter's value
11613+
typedef struct ur_enqueue_usm_shared_alloc_exp_params_t {
11614+
ur_queue_handle_t *phQueue;
11615+
ur_usm_pool_handle_t *ppPool;
11616+
const size_t *psize;
11617+
const ur_exp_async_usm_alloc_properties_t **ppProperties;
11618+
uint32_t *pnumEventsInWaitList;
11619+
const ur_event_handle_t **pphEventWaitList;
11620+
void ***pppMem;
11621+
ur_event_handle_t **pphEvent;
11622+
} ur_enqueue_usm_shared_alloc_exp_params_t;
11623+
11624+
///////////////////////////////////////////////////////////////////////////////
11625+
/// @brief Function parameters for urEnqueueUSMHostAllocExp
11626+
/// @details Each entry is a pointer to the parameter passed to the function;
11627+
/// allowing the callback the ability to modify the parameter's value
11628+
typedef struct ur_enqueue_usm_host_alloc_exp_params_t {
11629+
ur_queue_handle_t *phQueue;
11630+
ur_usm_pool_handle_t *ppPool;
11631+
const size_t *psize;
11632+
const ur_exp_async_usm_alloc_properties_t **ppProperties;
11633+
uint32_t *pnumEventsInWaitList;
11634+
const ur_event_handle_t **pphEventWaitList;
11635+
void ***pppMem;
11636+
ur_event_handle_t **pphEvent;
11637+
} ur_enqueue_usm_host_alloc_exp_params_t;
11638+
11639+
///////////////////////////////////////////////////////////////////////////////
11640+
/// @brief Function parameters for urEnqueueUSMFreeExp
11641+
/// @details Each entry is a pointer to the parameter passed to the function;
11642+
/// allowing the callback the ability to modify the parameter's value
11643+
typedef struct ur_enqueue_usm_free_exp_params_t {
11644+
ur_queue_handle_t *phQueue;
11645+
ur_usm_pool_handle_t *ppPool;
11646+
void **ppMem;
11647+
uint32_t *pnumEventsInWaitList;
11648+
const ur_event_handle_t **pphEventWaitList;
11649+
ur_event_handle_t **pphEvent;
11650+
} ur_enqueue_usm_free_exp_params_t;
11651+
1143511652
///////////////////////////////////////////////////////////////////////////////
1143611653
/// @brief Function parameters for urEnqueueCooperativeKernelLaunchExp
1143711654
/// @details Each entry is a pointer to the parameter passed to the function;

include/ur_api_funcs.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ _UR_API(urEnqueueDeviceGlobalVariableRead)
127127
_UR_API(urEnqueueReadHostPipe)
128128
_UR_API(urEnqueueWriteHostPipe)
129129
_UR_API(urEnqueueKernelLaunchCustomExp)
130+
_UR_API(urEnqueueUSMDeviceAllocExp)
131+
_UR_API(urEnqueueUSMSharedAllocExp)
132+
_UR_API(urEnqueueUSMHostAllocExp)
133+
_UR_API(urEnqueueUSMFreeExp)
130134
_UR_API(urEnqueueCooperativeKernelLaunchExp)
131135
_UR_API(urEnqueueTimestampRecordingExp)
132136
_UR_API(urEnqueueNativeCommandExp)

include/ur_ddi.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,52 @@ typedef ur_result_t(UR_APICALL *ur_pfnEnqueueKernelLaunchCustomExp_t)(
14631463
const ur_event_handle_t *,
14641464
ur_event_handle_t *);
14651465

1466+
///////////////////////////////////////////////////////////////////////////////
1467+
/// @brief Function-pointer for urEnqueueUSMDeviceAllocExp
1468+
typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMDeviceAllocExp_t)(
1469+
ur_queue_handle_t,
1470+
ur_usm_pool_handle_t,
1471+
const size_t,
1472+
const ur_exp_async_usm_alloc_properties_t *,
1473+
uint32_t,
1474+
const ur_event_handle_t *,
1475+
void **,
1476+
ur_event_handle_t *);
1477+
1478+
///////////////////////////////////////////////////////////////////////////////
1479+
/// @brief Function-pointer for urEnqueueUSMSharedAllocExp
1480+
typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMSharedAllocExp_t)(
1481+
ur_queue_handle_t,
1482+
ur_usm_pool_handle_t,
1483+
const size_t,
1484+
const ur_exp_async_usm_alloc_properties_t *,
1485+
uint32_t,
1486+
const ur_event_handle_t *,
1487+
void **,
1488+
ur_event_handle_t *);
1489+
1490+
///////////////////////////////////////////////////////////////////////////////
1491+
/// @brief Function-pointer for urEnqueueUSMHostAllocExp
1492+
typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMHostAllocExp_t)(
1493+
ur_queue_handle_t,
1494+
ur_usm_pool_handle_t,
1495+
const size_t,
1496+
const ur_exp_async_usm_alloc_properties_t *,
1497+
uint32_t,
1498+
const ur_event_handle_t *,
1499+
void **,
1500+
ur_event_handle_t *);
1501+
1502+
///////////////////////////////////////////////////////////////////////////////
1503+
/// @brief Function-pointer for urEnqueueUSMFreeExp
1504+
typedef ur_result_t(UR_APICALL *ur_pfnEnqueueUSMFreeExp_t)(
1505+
ur_queue_handle_t,
1506+
ur_usm_pool_handle_t,
1507+
void *,
1508+
uint32_t,
1509+
const ur_event_handle_t *,
1510+
ur_event_handle_t *);
1511+
14661512
///////////////////////////////////////////////////////////////////////////////
14671513
/// @brief Function-pointer for urEnqueueCooperativeKernelLaunchExp
14681514
typedef ur_result_t(UR_APICALL *ur_pfnEnqueueCooperativeKernelLaunchExp_t)(
@@ -1502,6 +1548,10 @@ typedef ur_result_t(UR_APICALL *ur_pfnEnqueueNativeCommandExp_t)(
15021548
/// @brief Table of EnqueueExp functions pointers
15031549
typedef struct ur_enqueue_exp_dditable_t {
15041550
ur_pfnEnqueueKernelLaunchCustomExp_t pfnKernelLaunchCustomExp;
1551+
ur_pfnEnqueueUSMDeviceAllocExp_t pfnUSMDeviceAllocExp;
1552+
ur_pfnEnqueueUSMSharedAllocExp_t pfnUSMSharedAllocExp;
1553+
ur_pfnEnqueueUSMHostAllocExp_t pfnUSMHostAllocExp;
1554+
ur_pfnEnqueueUSMFreeExp_t pfnUSMFreeExp;
15051555
ur_pfnEnqueueCooperativeKernelLaunchExp_t pfnCooperativeKernelLaunchExp;
15061556
ur_pfnEnqueueTimestampRecordingExp_t pfnTimestampRecordingExp;
15071557
ur_pfnEnqueueNativeCommandExp_t pfnNativeCommandExp;

0 commit comments

Comments
 (0)