Skip to content

Commit c90b27b

Browse files
committed
[UR][L0] Add multi-device-compile experimental feature
Expand upon the introduction of `urProgramBuildExp` and include `urProgramCompileExp` and `urProgramLinkExp` which include a device-list in place of a context. These more closely align with the PI/OpenCL analogues but only to introduce device-lists, not all extant arguments from those entry-points. This patch also moves the `urProgramBuildExp` definition into an experimental feature file and introduces a brief document containing motivation.
1 parent e5df409 commit c90b27b

File tree

14 files changed

+1221
-307
lines changed

14 files changed

+1221
-307
lines changed

include/ur.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ class ur_function_v(IntEnum):
203203
COMMAND_BUFFER_APPEND_USM_PREFETCH_EXP = 195 ## Enumerator for ::urCommandBufferAppendUSMPrefetchExp
204204
COMMAND_BUFFER_APPEND_USM_ADVISE_EXP = 196 ## Enumerator for ::urCommandBufferAppendUSMAdviseExp
205205
PROGRAM_BUILD_EXP = 197 ## Enumerator for ::urProgramBuildExp
206-
LOADER_CONFIG_SET_CODE_LOCATION_CALLBACK = 198 ## Enumerator for ::urLoaderConfigSetCodeLocationCallback
206+
PROGRAM_COMPILE_EXP = 198 ## Enumerator for ::urProgramCompileExp
207+
PROGRAM_LINK_EXP = 199 ## Enumerator for ::urProgramLinkExp
208+
LOADER_CONFIG_SET_CODE_LOCATION_CALLBACK = 200 ## Enumerator for ::urLoaderConfigSetCodeLocationCallback
207209

208210
class ur_function_t(c_int):
209211
def __str__(self):
@@ -2316,6 +2318,11 @@ class ur_exp_command_buffer_handle_t(c_void_p):
23162318
## which is returned when querying device extensions.
23172319
UR_COOPERATIVE_KERNELS_EXTENSION_STRING_EXP = "ur_exp_cooperative_kernels"
23182320

2321+
###############################################################################
2322+
## @brief The extension string which defines support for test
2323+
## which is returned when querying device extensions.
2324+
UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP = "ur_exp_multi_device_compile"
2325+
23192326
###############################################################################
23202327
## @brief Supported peer info
23212328
class ur_exp_peer_info_v(IntEnum):
@@ -2635,16 +2642,32 @@ class ur_program_dditable_t(Structure):
26352642
###############################################################################
26362643
## @brief Function-pointer for urProgramBuildExp
26372644
if __use_win_types:
2638-
_urProgramBuildExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2645+
_urProgramBuildExp_t = WINFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2646+
else:
2647+
_urProgramBuildExp_t = CFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2648+
2649+
###############################################################################
2650+
## @brief Function-pointer for urProgramCompileExp
2651+
if __use_win_types:
2652+
_urProgramCompileExp_t = WINFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2653+
else:
2654+
_urProgramCompileExp_t = CFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2655+
2656+
###############################################################################
2657+
## @brief Function-pointer for urProgramLinkExp
2658+
if __use_win_types:
2659+
_urProgramLinkExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, c_ulong, POINTER(ur_device_handle_t), c_ulong, POINTER(ur_program_handle_t), c_char_p, POINTER(ur_program_handle_t) )
26392660
else:
2640-
_urProgramBuildExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2661+
_urProgramLinkExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, c_ulong, POINTER(ur_device_handle_t), c_ulong, POINTER(ur_program_handle_t), c_char_p, POINTER(ur_program_handle_t) )
26412662

26422663

26432664
###############################################################################
26442665
## @brief Table of ProgramExp functions pointers
26452666
class ur_program_exp_dditable_t(Structure):
26462667
_fields_ = [
2647-
("pfnBuildExp", c_void_p) ## _urProgramBuildExp_t
2668+
("pfnBuildExp", c_void_p), ## _urProgramBuildExp_t
2669+
("pfnCompileExp", c_void_p), ## _urProgramCompileExp_t
2670+
("pfnLinkExp", c_void_p) ## _urProgramLinkExp_t
26482671
]
26492672

26502673
###############################################################################
@@ -3992,6 +4015,8 @@ def __init__(self, version : ur_api_version_t):
39924015

39934016
# attach function interface to function address
39944017
self.urProgramBuildExp = _urProgramBuildExp_t(self.__dditable.ProgramExp.pfnBuildExp)
4018+
self.urProgramCompileExp = _urProgramCompileExp_t(self.__dditable.ProgramExp.pfnCompileExp)
4019+
self.urProgramLinkExp = _urProgramLinkExp_t(self.__dditable.ProgramExp.pfnLinkExp)
39954020

39964021
# call driver to get function pointers
39974022
Kernel = ur_kernel_dditable_t()

include/ur_api.h

Lines changed: 153 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ typedef enum ur_function_t {
212212
UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_PREFETCH_EXP = 195, ///< Enumerator for ::urCommandBufferAppendUSMPrefetchExp
213213
UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_ADVISE_EXP = 196, ///< Enumerator for ::urCommandBufferAppendUSMAdviseExp
214214
UR_FUNCTION_PROGRAM_BUILD_EXP = 197, ///< Enumerator for ::urProgramBuildExp
215-
UR_FUNCTION_LOADER_CONFIG_SET_CODE_LOCATION_CALLBACK = 198, ///< Enumerator for ::urLoaderConfigSetCodeLocationCallback
215+
UR_FUNCTION_PROGRAM_COMPILE_EXP = 198, ///< Enumerator for ::urProgramCompileExp
216+
UR_FUNCTION_PROGRAM_LINK_EXP = 199, ///< Enumerator for ::urProgramLinkExp
217+
UR_FUNCTION_LOADER_CONFIG_SET_CODE_LOCATION_CALLBACK = 200, ///< Enumerator for ::urLoaderConfigSetCodeLocationCallback
216218
/// @cond
217219
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
218220
/// @endcond
@@ -4076,43 +4078,6 @@ urProgramBuild(
40764078
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
40774079
);
40784080

4079-
///////////////////////////////////////////////////////////////////////////////
4080-
/// @brief Produces an executable program from one program, negates need for the
4081-
/// linking step.
4082-
///
4083-
/// @details
4084-
/// - The application may call this function from simultaneous threads.
4085-
/// - Following a successful call to this entry point, the program passed
4086-
/// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type
4087-
/// for each device in `hContext`.
4088-
///
4089-
/// @remarks
4090-
/// _Analogues_
4091-
/// - **clBuildProgram**
4092-
///
4093-
/// @returns
4094-
/// - ::UR_RESULT_SUCCESS
4095-
/// - ::UR_RESULT_ERROR_UNINITIALIZED
4096-
/// - ::UR_RESULT_ERROR_DEVICE_LOST
4097-
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
4098-
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
4099-
/// + `NULL == hContext`
4100-
/// + `NULL == hProgram`
4101-
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
4102-
/// + `NULL == phDevices`
4103-
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
4104-
/// + If `hProgram` isn't a valid program object.
4105-
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
4106-
/// + If an error occurred when building `hProgram`.
4107-
UR_APIEXPORT ur_result_t UR_APICALL
4108-
urProgramBuildExp(
4109-
ur_context_handle_t hContext, ///< [in] handle of the context instance.
4110-
ur_program_handle_t hProgram, ///< [in] Handle of the program to build.
4111-
uint32_t numDevices, ///< [in] number of devices
4112-
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
4113-
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
4114-
);
4115-
41164081
///////////////////////////////////////////////////////////////////////////////
41174082
/// @brief Produces an executable program from one or more programs.
41184083
///
@@ -8446,6 +8411,131 @@ urKernelSuggestMaxCooperativeGroupCountExp(
84468411
uint32_t *pGroupCountRet ///< [out] pointer to maximum number of groups
84478412
);
84488413

8414+
#if !defined(__GNUC__)
8415+
#pragma endregion
8416+
#endif
8417+
// Intel 'oneAPI' Unified Runtime Experimental APIs for multi-device compile
8418+
#if !defined(__GNUC__)
8419+
#pragma region multi device compile(experimental)
8420+
#endif
8421+
///////////////////////////////////////////////////////////////////////////////
8422+
#ifndef UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP
8423+
/// @brief The extension string which defines support for test
8424+
/// which is returned when querying device extensions.
8425+
#define UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP "ur_exp_multi_device_compile"
8426+
#endif // UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP
8427+
8428+
///////////////////////////////////////////////////////////////////////////////
8429+
/// @brief Produces an executable program from one program, negates need for the
8430+
/// linking step.
8431+
///
8432+
/// @details
8433+
/// - The application may call this function from simultaneous threads.
8434+
/// - Following a successful call to this entry point, the program passed
8435+
/// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type
8436+
/// for each device in `phDevices`.
8437+
///
8438+
/// @remarks
8439+
/// _Analogues_
8440+
/// - **clBuildProgram**
8441+
///
8442+
/// @returns
8443+
/// - ::UR_RESULT_SUCCESS
8444+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8445+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8446+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8447+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8448+
/// + `NULL == hProgram`
8449+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8450+
/// + `NULL == phDevices`
8451+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8452+
/// + If `hProgram` isn't a valid program object.
8453+
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
8454+
/// + If an error occurred when building `hProgram`.
8455+
UR_APIEXPORT ur_result_t UR_APICALL
8456+
urProgramBuildExp(
8457+
ur_program_handle_t hProgram, ///< [in] Handle of the program to build.
8458+
uint32_t numDevices, ///< [in] number of devices
8459+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8460+
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
8461+
);
8462+
8463+
///////////////////////////////////////////////////////////////////////////////
8464+
/// @brief Produces an executable program from one or more programs.
8465+
///
8466+
/// @details
8467+
/// - The application may call this function from simultaneous threads.
8468+
/// - Following a successful call to this entry point `hProgram` will
8469+
/// contain a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type
8470+
/// for each device in `phDevices`.
8471+
///
8472+
/// @remarks
8473+
/// _Analogues_
8474+
/// - **clCompileProgram**
8475+
///
8476+
/// @returns
8477+
/// - ::UR_RESULT_SUCCESS
8478+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8479+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8480+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8481+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8482+
/// + `NULL == hProgram`
8483+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8484+
/// + `NULL == phDevices`
8485+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8486+
/// + If `hProgram` isn't a valid program object.
8487+
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
8488+
/// + If an error occurred while compiling `hProgram`.
8489+
UR_APIEXPORT ur_result_t UR_APICALL
8490+
urProgramCompileExp(
8491+
ur_program_handle_t hProgram, ///< [in][out] handle of the program to compile.
8492+
uint32_t numDevices, ///< [in] number of devices
8493+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8494+
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
8495+
);
8496+
8497+
///////////////////////////////////////////////////////////////////////////////
8498+
/// @brief Produces an executable program from one or more programs.
8499+
///
8500+
/// @details
8501+
/// - The application may call this function from simultaneous threads.
8502+
/// - Following a successful call to this entry point the program returned
8503+
/// in `phProgram` will contain a binary of the
8504+
/// ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in
8505+
/// `phDevices`.
8506+
///
8507+
/// @remarks
8508+
/// _Analogues_
8509+
/// - **clLinkProgram**
8510+
///
8511+
/// @returns
8512+
/// - ::UR_RESULT_SUCCESS
8513+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8514+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8515+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8516+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8517+
/// + `NULL == hContext`
8518+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8519+
/// + `NULL == phDevices`
8520+
/// + `NULL == phPrograms`
8521+
/// + `NULL == phProgram`
8522+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8523+
/// + If one of the programs in `phPrograms` isn't a valid program object.
8524+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
8525+
/// + `count == 0`
8526+
/// - ::UR_RESULT_ERROR_PROGRAM_LINK_FAILURE
8527+
/// + If an error occurred while linking `phPrograms`.
8528+
UR_APIEXPORT ur_result_t UR_APICALL
8529+
urProgramLinkExp(
8530+
ur_context_handle_t hContext, ///< [in] handle of the context instance.
8531+
uint32_t numDevices, ///< [in] number of devices
8532+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8533+
uint32_t count, ///< [in] number of program handles in `phPrograms`.
8534+
const ur_program_handle_t *phPrograms, ///< [in][range(0, count)] pointer to array of program handles.
8535+
const char *pOptions, ///< [in][optional] pointer to linker options null-terminated string.
8536+
ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created.
8537+
);
8538+
84498539
#if !defined(__GNUC__)
84508540
#pragma endregion
84518541
#endif
@@ -8962,7 +9052,6 @@ typedef struct ur_program_build_params_t {
89629052
/// @details Each entry is a pointer to the parameter passed to the function;
89639053
/// allowing the callback the ability to modify the parameter's value
89649054
typedef struct ur_program_build_exp_params_t {
8965-
ur_context_handle_t *phContext;
89669055
ur_program_handle_t *phProgram;
89679056
uint32_t *pnumDevices;
89689057
ur_device_handle_t **pphDevices;
@@ -8979,6 +9068,17 @@ typedef struct ur_program_compile_params_t {
89799068
const char **ppOptions;
89809069
} ur_program_compile_params_t;
89819070

9071+
///////////////////////////////////////////////////////////////////////////////
9072+
/// @brief Function parameters for urProgramCompileExp
9073+
/// @details Each entry is a pointer to the parameter passed to the function;
9074+
/// allowing the callback the ability to modify the parameter's value
9075+
typedef struct ur_program_compile_exp_params_t {
9076+
ur_program_handle_t *phProgram;
9077+
uint32_t *pnumDevices;
9078+
ur_device_handle_t **pphDevices;
9079+
const char **ppOptions;
9080+
} ur_program_compile_exp_params_t;
9081+
89829082
///////////////////////////////////////////////////////////////////////////////
89839083
/// @brief Function parameters for urProgramLink
89849084
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -8991,6 +9091,20 @@ typedef struct ur_program_link_params_t {
89919091
ur_program_handle_t **pphProgram;
89929092
} ur_program_link_params_t;
89939093

9094+
///////////////////////////////////////////////////////////////////////////////
9095+
/// @brief Function parameters for urProgramLinkExp
9096+
/// @details Each entry is a pointer to the parameter passed to the function;
9097+
/// allowing the callback the ability to modify the parameter's value
9098+
typedef struct ur_program_link_exp_params_t {
9099+
ur_context_handle_t *phContext;
9100+
uint32_t *pnumDevices;
9101+
ur_device_handle_t **pphDevices;
9102+
uint32_t *pcount;
9103+
const ur_program_handle_t **pphPrograms;
9104+
const char **ppOptions;
9105+
ur_program_handle_t **pphProgram;
9106+
} ur_program_link_exp_params_t;
9107+
89949108
///////////////////////////////////////////////////////////////////////////////
89959109
/// @brief Function parameters for urProgramRetain
89969110
/// @details Each entry is a pointer to the parameter passed to the function;

include/ur_ddi.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,16 +411,36 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetProgramProcAddrTable_t)(
411411
///////////////////////////////////////////////////////////////////////////////
412412
/// @brief Function-pointer for urProgramBuildExp
413413
typedef ur_result_t(UR_APICALL *ur_pfnProgramBuildExp_t)(
414-
ur_context_handle_t,
415414
ur_program_handle_t,
416415
uint32_t,
417416
ur_device_handle_t *,
418417
const char *);
419418

419+
///////////////////////////////////////////////////////////////////////////////
420+
/// @brief Function-pointer for urProgramCompileExp
421+
typedef ur_result_t(UR_APICALL *ur_pfnProgramCompileExp_t)(
422+
ur_program_handle_t,
423+
uint32_t,
424+
ur_device_handle_t *,
425+
const char *);
426+
427+
///////////////////////////////////////////////////////////////////////////////
428+
/// @brief Function-pointer for urProgramLinkExp
429+
typedef ur_result_t(UR_APICALL *ur_pfnProgramLinkExp_t)(
430+
ur_context_handle_t,
431+
uint32_t,
432+
ur_device_handle_t *,
433+
uint32_t,
434+
const ur_program_handle_t *,
435+
const char *,
436+
ur_program_handle_t *);
437+
420438
///////////////////////////////////////////////////////////////////////////////
421439
/// @brief Table of ProgramExp functions pointers
422440
typedef struct ur_program_exp_dditable_t {
423441
ur_pfnProgramBuildExp_t pfnBuildExp;
442+
ur_pfnProgramCompileExp_t pfnCompileExp;
443+
ur_pfnProgramLinkExp_t pfnLinkExp;
424444
} ur_program_exp_dditable_t;
425445

426446
///////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)