Skip to content

Commit 73e9e32

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 591638f commit 73e9e32

File tree

14 files changed

+1221
-302
lines changed

14 files changed

+1221
-302
lines changed

include/ur.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ 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+
PROGRAM_COMPILE_EXP = 198 ## Enumerator for ::urProgramCompileExp
207+
PROGRAM_LINK_EXP = 199 ## Enumerator for ::urProgramLinkExp
206208

207209
class ur_function_t(c_int):
208210
def __str__(self):
@@ -2297,6 +2299,11 @@ class ur_exp_command_buffer_handle_t(c_void_p):
22972299
## which is returned when querying device extensions.
22982300
UR_COOPERATIVE_KERNELS_EXTENSION_STRING_EXP = "ur_exp_cooperative_kernels"
22992301

2302+
###############################################################################
2303+
## @brief The extension string which defines support for test
2304+
## which is returned when querying device extensions.
2305+
UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP = "ur_exp_multi_device_compile"
2306+
23002307
###############################################################################
23012308
## @brief Supported peer info
23022309
class ur_exp_peer_info_v(IntEnum):
@@ -2616,16 +2623,32 @@ class ur_program_dditable_t(Structure):
26162623
###############################################################################
26172624
## @brief Function-pointer for urProgramBuildExp
26182625
if __use_win_types:
2619-
_urProgramBuildExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2626+
_urProgramBuildExp_t = WINFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2627+
else:
2628+
_urProgramBuildExp_t = CFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2629+
2630+
###############################################################################
2631+
## @brief Function-pointer for urProgramCompileExp
2632+
if __use_win_types:
2633+
_urProgramCompileExp_t = WINFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2634+
else:
2635+
_urProgramCompileExp_t = CFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2636+
2637+
###############################################################################
2638+
## @brief Function-pointer for urProgramLinkExp
2639+
if __use_win_types:
2640+
_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) )
26202641
else:
2621-
_urProgramBuildExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2642+
_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) )
26222643

26232644

26242645
###############################################################################
26252646
## @brief Table of ProgramExp functions pointers
26262647
class ur_program_exp_dditable_t(Structure):
26272648
_fields_ = [
2628-
("pfnBuildExp", c_void_p) ## _urProgramBuildExp_t
2649+
("pfnBuildExp", c_void_p), ## _urProgramBuildExp_t
2650+
("pfnCompileExp", c_void_p), ## _urProgramCompileExp_t
2651+
("pfnLinkExp", c_void_p) ## _urProgramLinkExp_t
26292652
]
26302653

26312654
###############################################################################
@@ -3973,6 +3996,8 @@ def __init__(self, version : ur_api_version_t):
39733996

39743997
# attach function interface to function address
39753998
self.urProgramBuildExp = _urProgramBuildExp_t(self.__dditable.ProgramExp.pfnBuildExp)
3999+
self.urProgramCompileExp = _urProgramCompileExp_t(self.__dditable.ProgramExp.pfnCompileExp)
4000+
self.urProgramLinkExp = _urProgramLinkExp_t(self.__dditable.ProgramExp.pfnLinkExp)
39764001

39774002
# call driver to get function pointers
39784003
Kernel = ur_kernel_dditable_t()

include/ur_api.h

Lines changed: 152 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ 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_PROGRAM_COMPILE_EXP = 198, ///< Enumerator for ::urProgramCompileExp
216+
UR_FUNCTION_PROGRAM_LINK_EXP = 199, ///< Enumerator for ::urProgramLinkExp
215217
/// @cond
216218
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
217219
/// @endcond
@@ -4032,43 +4034,6 @@ urProgramBuild(
40324034
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
40334035
);
40344036

4035-
///////////////////////////////////////////////////////////////////////////////
4036-
/// @brief Produces an executable program from one program, negates need for the
4037-
/// linking step.
4038-
///
4039-
/// @details
4040-
/// - The application may call this function from simultaneous threads.
4041-
/// - Following a successful call to this entry point, the program passed
4042-
/// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type
4043-
/// for each device in `hContext`.
4044-
///
4045-
/// @remarks
4046-
/// _Analogues_
4047-
/// - **clBuildProgram**
4048-
///
4049-
/// @returns
4050-
/// - ::UR_RESULT_SUCCESS
4051-
/// - ::UR_RESULT_ERROR_UNINITIALIZED
4052-
/// - ::UR_RESULT_ERROR_DEVICE_LOST
4053-
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
4054-
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
4055-
/// + `NULL == hContext`
4056-
/// + `NULL == hProgram`
4057-
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
4058-
/// + `NULL == phDevices`
4059-
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
4060-
/// + If `hProgram` isn't a valid program object.
4061-
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
4062-
/// + If an error occurred when building `hProgram`.
4063-
UR_APIEXPORT ur_result_t UR_APICALL
4064-
urProgramBuildExp(
4065-
ur_context_handle_t hContext, ///< [in] handle of the context instance.
4066-
ur_program_handle_t hProgram, ///< [in] Handle of the program to build.
4067-
uint32_t numDevices, ///< [in] number of devices
4068-
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
4069-
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
4070-
);
4071-
40724037
///////////////////////////////////////////////////////////////////////////////
40734038
/// @brief Produces an executable program from one or more programs.
40744039
///
@@ -8402,6 +8367,131 @@ urKernelSuggestMaxCooperativeGroupCountExp(
84028367
uint32_t *pGroupCountRet ///< [out] pointer to maximum number of groups
84038368
);
84048369

8370+
#if !defined(__GNUC__)
8371+
#pragma endregion
8372+
#endif
8373+
// Intel 'oneAPI' Unified Runtime Experimental APIs for multi-device compile
8374+
#if !defined(__GNUC__)
8375+
#pragma region multi device compile(experimental)
8376+
#endif
8377+
///////////////////////////////////////////////////////////////////////////////
8378+
#ifndef UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP
8379+
/// @brief The extension string which defines support for test
8380+
/// which is returned when querying device extensions.
8381+
#define UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP "ur_exp_multi_device_compile"
8382+
#endif // UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP
8383+
8384+
///////////////////////////////////////////////////////////////////////////////
8385+
/// @brief Produces an executable program from one program, negates need for the
8386+
/// linking step.
8387+
///
8388+
/// @details
8389+
/// - The application may call this function from simultaneous threads.
8390+
/// - Following a successful call to this entry point, the program passed
8391+
/// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type
8392+
/// for each device in `phDevices`.
8393+
///
8394+
/// @remarks
8395+
/// _Analogues_
8396+
/// - **clBuildProgram**
8397+
///
8398+
/// @returns
8399+
/// - ::UR_RESULT_SUCCESS
8400+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8401+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8402+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8403+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8404+
/// + `NULL == hProgram`
8405+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8406+
/// + `NULL == phDevices`
8407+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8408+
/// + If `hProgram` isn't a valid program object.
8409+
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
8410+
/// + If an error occurred when building `hProgram`.
8411+
UR_APIEXPORT ur_result_t UR_APICALL
8412+
urProgramBuildExp(
8413+
ur_program_handle_t hProgram, ///< [in] Handle of the program to build.
8414+
uint32_t numDevices, ///< [in] number of devices
8415+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8416+
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
8417+
);
8418+
8419+
///////////////////////////////////////////////////////////////////////////////
8420+
/// @brief Produces an executable program from one or more programs.
8421+
///
8422+
/// @details
8423+
/// - The application may call this function from simultaneous threads.
8424+
/// - Following a successful call to this entry point `hProgram` will
8425+
/// contain a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type
8426+
/// for each device in `phDevices`.
8427+
///
8428+
/// @remarks
8429+
/// _Analogues_
8430+
/// - **clCompileProgram**
8431+
///
8432+
/// @returns
8433+
/// - ::UR_RESULT_SUCCESS
8434+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8435+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8436+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8437+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8438+
/// + `NULL == hProgram`
8439+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8440+
/// + `NULL == phDevices`
8441+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8442+
/// + If `hProgram` isn't a valid program object.
8443+
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
8444+
/// + If an error occurred while compiling `hProgram`.
8445+
UR_APIEXPORT ur_result_t UR_APICALL
8446+
urProgramCompileExp(
8447+
ur_program_handle_t hProgram, ///< [in][out] handle of the program to compile.
8448+
uint32_t numDevices, ///< [in] number of devices
8449+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8450+
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
8451+
);
8452+
8453+
///////////////////////////////////////////////////////////////////////////////
8454+
/// @brief Produces an executable program from one or more programs.
8455+
///
8456+
/// @details
8457+
/// - The application may call this function from simultaneous threads.
8458+
/// - Following a successful call to this entry point the program returned
8459+
/// in `phProgram` will contain a binary of the
8460+
/// ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in
8461+
/// `phDevices`.
8462+
///
8463+
/// @remarks
8464+
/// _Analogues_
8465+
/// - **clLinkProgram**
8466+
///
8467+
/// @returns
8468+
/// - ::UR_RESULT_SUCCESS
8469+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8470+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8471+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8472+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8473+
/// + `NULL == hContext`
8474+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8475+
/// + `NULL == phDevices`
8476+
/// + `NULL == phPrograms`
8477+
/// + `NULL == phProgram`
8478+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8479+
/// + If one of the programs in `phPrograms` isn't a valid program object.
8480+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
8481+
/// + `count == 0`
8482+
/// - ::UR_RESULT_ERROR_PROGRAM_LINK_FAILURE
8483+
/// + If an error occurred while linking `phPrograms`.
8484+
UR_APIEXPORT ur_result_t UR_APICALL
8485+
urProgramLinkExp(
8486+
ur_context_handle_t hContext, ///< [in] handle of the context instance.
8487+
uint32_t numDevices, ///< [in] number of devices
8488+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8489+
uint32_t count, ///< [in] number of program handles in `phPrograms`.
8490+
const ur_program_handle_t *phPrograms, ///< [in][range(0, count)] pointer to array of program handles.
8491+
const char *pOptions, ///< [in][optional] pointer to linker options null-terminated string.
8492+
ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created.
8493+
);
8494+
84058495
#if !defined(__GNUC__)
84068496
#pragma endregion
84078497
#endif
@@ -8908,7 +8998,6 @@ typedef struct ur_program_build_params_t {
89088998
/// @details Each entry is a pointer to the parameter passed to the function;
89098999
/// allowing the callback the ability to modify the parameter's value
89109000
typedef struct ur_program_build_exp_params_t {
8911-
ur_context_handle_t *phContext;
89129001
ur_program_handle_t *phProgram;
89139002
uint32_t *pnumDevices;
89149003
ur_device_handle_t **pphDevices;
@@ -8925,6 +9014,17 @@ typedef struct ur_program_compile_params_t {
89259014
const char **ppOptions;
89269015
} ur_program_compile_params_t;
89279016

9017+
///////////////////////////////////////////////////////////////////////////////
9018+
/// @brief Function parameters for urProgramCompileExp
9019+
/// @details Each entry is a pointer to the parameter passed to the function;
9020+
/// allowing the callback the ability to modify the parameter's value
9021+
typedef struct ur_program_compile_exp_params_t {
9022+
ur_program_handle_t *phProgram;
9023+
uint32_t *pnumDevices;
9024+
ur_device_handle_t **pphDevices;
9025+
const char **ppOptions;
9026+
} ur_program_compile_exp_params_t;
9027+
89289028
///////////////////////////////////////////////////////////////////////////////
89299029
/// @brief Function parameters for urProgramLink
89309030
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -8937,6 +9037,20 @@ typedef struct ur_program_link_params_t {
89379037
ur_program_handle_t **pphProgram;
89389038
} ur_program_link_params_t;
89399039

9040+
///////////////////////////////////////////////////////////////////////////////
9041+
/// @brief Function parameters for urProgramLinkExp
9042+
/// @details Each entry is a pointer to the parameter passed to the function;
9043+
/// allowing the callback the ability to modify the parameter's value
9044+
typedef struct ur_program_link_exp_params_t {
9045+
ur_context_handle_t *phContext;
9046+
uint32_t *pnumDevices;
9047+
ur_device_handle_t **pphDevices;
9048+
uint32_t *pcount;
9049+
const ur_program_handle_t **pphPrograms;
9050+
const char **ppOptions;
9051+
ur_program_handle_t **pphProgram;
9052+
} ur_program_link_exp_params_t;
9053+
89409054
///////////////////////////////////////////////////////////////////////////////
89419055
/// @brief Function parameters for urProgramRetain
89429056
/// @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)