Skip to content

Commit c5d3b9d

Browse files
authored
Merge pull request #1645 from hdelan/exp-interop-entrypoint
[UR] Add experimental interface for native enqueue
2 parents 187c2fa + 52a7fc6 commit c5d3b9d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1406
-21
lines changed

include/ur_api.h

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ typedef enum ur_function_t {
225225
UR_FUNCTION_KERNEL_GET_SUGGESTED_LOCAL_WORK_SIZE = 225, ///< Enumerator for ::urKernelGetSuggestedLocalWorkSize
226226
UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_MEMORY_EXP = 226, ///< Enumerator for ::urBindlessImagesImportExternalMemoryExp
227227
UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_EXP = 227, ///< Enumerator for ::urBindlessImagesImportExternalSemaphoreExp
228+
UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP = 228, ///< Enumerator for ::urEnqueueNativeCommandExp
228229
/// @cond
229230
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
230231
/// @endcond
@@ -281,6 +282,7 @@ typedef enum ur_structure_type_t {
281282
UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE = 0x2004, ///< ::ur_exp_win32_handle_t
282283
UR_STRUCTURE_TYPE_EXP_SAMPLER_ADDR_MODES = 0x2005, ///< ::ur_exp_sampler_addr_modes_t
283284
UR_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES = 0x2006, ///< ::ur_exp_sampler_cubemap_properties_t
285+
UR_STRUCTURE_TYPE_EXP_ENQUEUE_NATIVE_COMMAND_PROPERTIES = 0x3000, ///< ::ur_exp_enqueue_native_command_properties_t
284286
/// @cond
285287
UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff
286288
/// @endcond
@@ -1648,6 +1650,8 @@ typedef enum ur_device_info_t {
16481650
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_EXP = 0x2017, ///< [::ur_bool_t] returns true if the device is capable of fetching
16491651
///< non-USM backed 3D sampled image data.
16501652
UR_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT_EXP = 0x2018, ///< [::ur_bool_t] returns true if the device supports timestamp recording
1653+
UR_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT_EXP = 0x2020, ///< [::ur_bool_t] returns true if the device supports enqueueing of native
1654+
///< work
16511655
/// @cond
16521656
UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff
16531657
/// @endcond
@@ -1673,7 +1677,7 @@ typedef enum ur_device_info_t {
16731677
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
16741678
/// + `NULL == hDevice`
16751679
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
1676-
/// + `::UR_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT_EXP < propName`
1680+
/// + `::UR_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT_EXP < propName`
16771681
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
16781682
/// + If `propName` is not supported by the adapter.
16791683
/// - ::UR_RESULT_ERROR_INVALID_SIZE
@@ -5683,6 +5687,7 @@ typedef enum ur_command_t {
56835687
UR_COMMAND_INTEROP_SEMAPHORE_WAIT_EXP = 0x2000, ///< Event created by ::urBindlessImagesWaitExternalSemaphoreExp
56845688
UR_COMMAND_INTEROP_SEMAPHORE_SIGNAL_EXP = 0x2001, ///< Event created by ::urBindlessImagesSignalExternalSemaphoreExp
56855689
UR_COMMAND_TIMESTAMP_RECORDING_EXP = 0x2002, ///< Event created by ::urEnqueueTimestampRecordingExp
5690+
UR_COMMAND_ENQUEUE_NATIVE_EXP = 0x2004, ///< Event created by ::urEnqueueNativeCommandExp
56865691
/// @cond
56875692
UR_COMMAND_FORCE_UINT32 = 0x7fffffff
56885693
/// @endcond
@@ -9497,6 +9502,80 @@ urUsmP2PPeerAccessGetInfoExp(
94979502
size_t *pPropSizeRet ///< [out][optional] pointer to the actual size in bytes of the queried propName.
94989503
);
94999504

9505+
#if !defined(__GNUC__)
9506+
#pragma endregion
9507+
#endif
9508+
// Intel 'oneAPI' Unified Runtime Experimental API for enqueuing work through native APIs
9509+
#if !defined(__GNUC__)
9510+
#pragma region native enqueue(experimental)
9511+
#endif
9512+
///////////////////////////////////////////////////////////////////////////////
9513+
/// @brief Native enqueue properties
9514+
typedef uint32_t ur_exp_enqueue_native_command_flags_t;
9515+
typedef enum ur_exp_enqueue_native_command_flag_t {
9516+
UR_EXP_ENQUEUE_NATIVE_COMMAND_FLAG_TBD = UR_BIT(0), ///< reserved for future use.
9517+
/// @cond
9518+
UR_EXP_ENQUEUE_NATIVE_COMMAND_FLAG_FORCE_UINT32 = 0x7fffffff
9519+
/// @endcond
9520+
9521+
} ur_exp_enqueue_native_command_flag_t;
9522+
/// @brief Bit Mask for validating ur_exp_enqueue_native_command_flags_t
9523+
#define UR_EXP_ENQUEUE_NATIVE_COMMAND_FLAGS_MASK 0xfffffffe
9524+
9525+
///////////////////////////////////////////////////////////////////////////////
9526+
/// @brief Native enqueue properties
9527+
typedef struct ur_exp_enqueue_native_command_properties_t {
9528+
ur_structure_type_t stype; ///< [in] type of this structure, must be
9529+
///< ::UR_STRUCTURE_TYPE_EXP_ENQUEUE_NATIVE_COMMAND_PROPERTIES
9530+
void *pNext; ///< [in,out][optional] pointer to extension-specific structure
9531+
ur_exp_enqueue_native_command_flags_t flags; ///< [in] native enqueue flags
9532+
9533+
} ur_exp_enqueue_native_command_properties_t;
9534+
9535+
///////////////////////////////////////////////////////////////////////////////
9536+
/// @brief Function enqueueing work through the native API to be executed
9537+
/// immediately.
9538+
typedef void (*ur_exp_enqueue_native_command_function_t)(
9539+
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
9540+
void *pUserData ///< [in][out] pointer to data to be passed to callback
9541+
);
9542+
9543+
///////////////////////////////////////////////////////////////////////////////
9544+
/// @brief Immediately enqueue work through a native backend API
9545+
///
9546+
/// @returns
9547+
/// - ::UR_RESULT_SUCCESS
9548+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
9549+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
9550+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
9551+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
9552+
/// + `NULL == hQueue`
9553+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
9554+
/// + `NULL == pfnNativeEnqueue`
9555+
/// + `NULL == phEvent`
9556+
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
9557+
/// + `NULL != pProperties && ::UR_EXP_ENQUEUE_NATIVE_COMMAND_FLAGS_MASK & pProperties->flags`
9558+
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST
9559+
UR_APIEXPORT ur_result_t UR_APICALL
9560+
urEnqueueNativeCommandExp(
9561+
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
9562+
ur_exp_enqueue_native_command_function_t pfnNativeEnqueue, ///< [in] function calling the native underlying API, to be executed
9563+
///< immediately.
9564+
void *data, ///< [in][optional] data used by pfnNativeEnqueue
9565+
uint32_t numMemsInMemList, ///< [in] size of the mem list
9566+
const ur_mem_handle_t *phMemList, ///< [in][optional][range(0, numMemsInMemList)] mems that are used within
9567+
///< pfnNativeEnqueue using ::urMemGetNativeHandle.
9568+
///< If nullptr, the numMemsInMemList must be 0, indicating that no mems
9569+
///< are accessed with ::urMemGetNativeHandle within pfnNativeEnqueue.
9570+
const ur_exp_enqueue_native_command_properties_t *pProperties, ///< [in][optional] pointer to the native enqueue properties
9571+
uint32_t numEventsInWaitList, ///< [in] size of the event wait list
9572+
const ur_event_handle_t *phEventWaitList, ///< [in][optional][range(0, numEventsInWaitList)] pointer to a list of
9573+
///< events that must be complete before the kernel execution.
9574+
///< If nullptr, the numEventsInWaitList must be 0, indicating no wait events.
9575+
ur_event_handle_t *phEvent ///< [in,out] return an event object that identifies the work that has
9576+
///< been enqueued in nativeEnqueueFunc.
9577+
);
9578+
95009579
#if !defined(__GNUC__)
95019580
#pragma endregion
95029581
#endif
@@ -10916,6 +10995,22 @@ typedef struct ur_enqueue_timestamp_recording_exp_params_t {
1091610995
ur_event_handle_t **pphEvent;
1091710996
} ur_enqueue_timestamp_recording_exp_params_t;
1091810997

10998+
///////////////////////////////////////////////////////////////////////////////
10999+
/// @brief Function parameters for urEnqueueNativeCommandExp
11000+
/// @details Each entry is a pointer to the parameter passed to the function;
11001+
/// allowing the callback the ability to modify the parameter's value
11002+
typedef struct ur_enqueue_native_command_exp_params_t {
11003+
ur_queue_handle_t *phQueue;
11004+
ur_exp_enqueue_native_command_function_t *ppfnNativeEnqueue;
11005+
void **pdata;
11006+
uint32_t *pnumMemsInMemList;
11007+
const ur_mem_handle_t **pphMemList;
11008+
const ur_exp_enqueue_native_command_properties_t **ppProperties;
11009+
uint32_t *pnumEventsInWaitList;
11010+
const ur_event_handle_t **pphEventWaitList;
11011+
ur_event_handle_t **pphEvent;
11012+
} ur_enqueue_native_command_exp_params_t;
11013+
1091911014
///////////////////////////////////////////////////////////////////////////////
1092011015
/// @brief Function parameters for urBindlessImagesUnsampledImageHandleDestroyExp
1092111016
/// @details Each entry is a pointer to the parameter passed to the function;

include/ur_ddi.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,12 +1483,26 @@ typedef ur_result_t(UR_APICALL *ur_pfnEnqueueTimestampRecordingExp_t)(
14831483
const ur_event_handle_t *,
14841484
ur_event_handle_t *);
14851485

1486+
///////////////////////////////////////////////////////////////////////////////
1487+
/// @brief Function-pointer for urEnqueueNativeCommandExp
1488+
typedef ur_result_t(UR_APICALL *ur_pfnEnqueueNativeCommandExp_t)(
1489+
ur_queue_handle_t,
1490+
ur_exp_enqueue_native_command_function_t,
1491+
void *,
1492+
uint32_t,
1493+
const ur_mem_handle_t *,
1494+
const ur_exp_enqueue_native_command_properties_t *,
1495+
uint32_t,
1496+
const ur_event_handle_t *,
1497+
ur_event_handle_t *);
1498+
14861499
///////////////////////////////////////////////////////////////////////////////
14871500
/// @brief Table of EnqueueExp functions pointers
14881501
typedef struct ur_enqueue_exp_dditable_t {
14891502
ur_pfnEnqueueKernelLaunchCustomExp_t pfnKernelLaunchCustomExp;
14901503
ur_pfnEnqueueCooperativeKernelLaunchExp_t pfnCooperativeKernelLaunchExp;
14911504
ur_pfnEnqueueTimestampRecordingExp_t pfnTimestampRecordingExp;
1505+
ur_pfnEnqueueNativeCommandExp_t pfnNativeCommandExp;
14921506
} ur_enqueue_exp_dditable_t;
14931507

14941508
///////////////////////////////////////////////////////////////////////////////

include/ur_print.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,22 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintExpLaunchProperty(const struct ur_exp
10421042
/// - `buff_size < out_size`
10431043
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpPeerInfo(enum ur_exp_peer_info_t value, char *buffer, const size_t buff_size, size_t *out_size);
10441044

1045+
///////////////////////////////////////////////////////////////////////////////
1046+
/// @brief Print ur_exp_enqueue_native_command_flag_t enum
1047+
/// @returns
1048+
/// - ::UR_RESULT_SUCCESS
1049+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1050+
/// - `buff_size < out_size`
1051+
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpEnqueueNativeCommandFlags(enum ur_exp_enqueue_native_command_flag_t value, char *buffer, const size_t buff_size, size_t *out_size);
1052+
1053+
///////////////////////////////////////////////////////////////////////////////
1054+
/// @brief Print ur_exp_enqueue_native_command_properties_t struct
1055+
/// @returns
1056+
/// - ::UR_RESULT_SUCCESS
1057+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1058+
/// - `buff_size < out_size`
1059+
UR_APIEXPORT ur_result_t UR_APICALL urPrintExpEnqueueNativeCommandProperties(const struct ur_exp_enqueue_native_command_properties_t params, char *buffer, const size_t buff_size, size_t *out_size);
1060+
10451061
///////////////////////////////////////////////////////////////////////////////
10461062
/// @brief Print ur_loader_config_create_params_t struct
10471063
/// @returns
@@ -2010,6 +2026,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintEnqueueCooperativeKernelLaunchExpPara
20102026
/// - `buff_size < out_size`
20112027
UR_APIEXPORT ur_result_t UR_APICALL urPrintEnqueueTimestampRecordingExpParams(const struct ur_enqueue_timestamp_recording_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
20122028

2029+
///////////////////////////////////////////////////////////////////////////////
2030+
/// @brief Print ur_enqueue_native_command_exp_params_t struct
2031+
/// @returns
2032+
/// - ::UR_RESULT_SUCCESS
2033+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
2034+
/// - `buff_size < out_size`
2035+
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);
2036+
20132037
///////////////////////////////////////////////////////////////////////////////
20142038
/// @brief Print ur_bindless_images_unsampled_image_handle_destroy_exp_params_t struct
20152039
/// @returns

0 commit comments

Comments
 (0)