Skip to content

Commit 92e608f

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 c583ecc commit 92e608f

File tree

14 files changed

+1214
-306
lines changed

14 files changed

+1214
-306
lines changed

include/ur.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ class ur_function_v(IntEnum):
196196
ADAPTER_RETAIN = 179 ## Enumerator for ::urAdapterRetain
197197
ADAPTER_GET_LAST_ERROR = 180 ## Enumerator for ::urAdapterGetLastError
198198
ADAPTER_GET_INFO = 181 ## Enumerator for ::urAdapterGetInfo
199-
PROGRAM_BUILD_EXP = 182 ## Enumerator for ::urProgramBuildExp
199+
PROGRAM_BUILD_EXP = 197 ## Enumerator for ::urProgramBuildExp
200+
PROGRAM_COMPILE_EXP = 198 ## Enumerator for ::urProgramCompileExp
201+
PROGRAM_LINK_EXP = 199 ## Enumerator for ::urProgramLinkExp
200202

201203
class ur_function_t(c_int):
202204
def __str__(self):
@@ -2254,6 +2256,11 @@ class ur_exp_command_buffer_sync_point_t(c_ulong):
22542256
class ur_exp_command_buffer_handle_t(c_void_p):
22552257
pass
22562258

2259+
###############################################################################
2260+
## @brief The extension string which defines support for test
2261+
## which is returned when querying device extensions.
2262+
UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP = "ur_exp_multi_device_compile"
2263+
22572264
###############################################################################
22582265
## @brief Supported peer info
22592266
class ur_exp_peer_info_v(IntEnum):
@@ -2573,16 +2580,32 @@ class ur_program_dditable_t(Structure):
25732580
###############################################################################
25742581
## @brief Function-pointer for urProgramBuildExp
25752582
if __use_win_types:
2576-
_urProgramBuildExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2583+
_urProgramBuildExp_t = WINFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2584+
else:
2585+
_urProgramBuildExp_t = CFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2586+
2587+
###############################################################################
2588+
## @brief Function-pointer for urProgramCompileExp
2589+
if __use_win_types:
2590+
_urProgramCompileExp_t = WINFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2591+
else:
2592+
_urProgramCompileExp_t = CFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2593+
2594+
###############################################################################
2595+
## @brief Function-pointer for urProgramLinkExp
2596+
if __use_win_types:
2597+
_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) )
25772598
else:
2578-
_urProgramBuildExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2599+
_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) )
25792600

25802601

25812602
###############################################################################
25822603
## @brief Table of ProgramExp functions pointers
25832604
class ur_program_exp_dditable_t(Structure):
25842605
_fields_ = [
2585-
("pfnBuildExp", c_void_p) ## _urProgramBuildExp_t
2606+
("pfnBuildExp", c_void_p), ## _urProgramBuildExp_t
2607+
("pfnCompileExp", c_void_p), ## _urProgramCompileExp_t
2608+
("pfnLinkExp", c_void_p) ## _urProgramLinkExp_t
25862609
]
25872610

25882611
###############################################################################
@@ -3882,6 +3905,8 @@ def __init__(self, version : ur_api_version_t):
38823905

38833906
# attach function interface to function address
38843907
self.urProgramBuildExp = _urProgramBuildExp_t(self.__dditable.ProgramExp.pfnBuildExp)
3908+
self.urProgramCompileExp = _urProgramCompileExp_t(self.__dditable.ProgramExp.pfnCompileExp)
3909+
self.urProgramLinkExp = _urProgramLinkExp_t(self.__dditable.ProgramExp.pfnLinkExp)
38853910

38863911
# call driver to get function pointers
38873912
Kernel = ur_kernel_dditable_t()

include/ur_api.h

Lines changed: 153 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ typedef enum ur_function_t {
205205
UR_FUNCTION_ADAPTER_RETAIN = 179, ///< Enumerator for ::urAdapterRetain
206206
UR_FUNCTION_ADAPTER_GET_LAST_ERROR = 180, ///< Enumerator for ::urAdapterGetLastError
207207
UR_FUNCTION_ADAPTER_GET_INFO = 181, ///< Enumerator for ::urAdapterGetInfo
208-
UR_FUNCTION_PROGRAM_BUILD_EXP = 182, ///< Enumerator for ::urProgramBuildExp
208+
UR_FUNCTION_PROGRAM_BUILD_EXP = 197, ///< Enumerator for ::urProgramBuildExp
209+
UR_FUNCTION_PROGRAM_COMPILE_EXP = 198, ///< Enumerator for ::urProgramCompileExp
210+
UR_FUNCTION_PROGRAM_LINK_EXP = 199, ///< Enumerator for ::urProgramLinkExp
209211
/// @cond
210212
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
211213
/// @endcond
@@ -4001,43 +4003,6 @@ urProgramBuild(
40014003
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
40024004
);
40034005

4004-
///////////////////////////////////////////////////////////////////////////////
4005-
/// @brief Produces an executable program from one program, negates need for the
4006-
/// linking step.
4007-
///
4008-
/// @details
4009-
/// - The application may call this function from simultaneous threads.
4010-
/// - Following a successful call to this entry point, the program passed
4011-
/// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type
4012-
/// for each device in `hContext`.
4013-
///
4014-
/// @remarks
4015-
/// _Analogues_
4016-
/// - **clBuildProgram**
4017-
///
4018-
/// @returns
4019-
/// - ::UR_RESULT_SUCCESS
4020-
/// - ::UR_RESULT_ERROR_UNINITIALIZED
4021-
/// - ::UR_RESULT_ERROR_DEVICE_LOST
4022-
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
4023-
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
4024-
/// + `NULL == hContext`
4025-
/// + `NULL == hProgram`
4026-
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
4027-
/// + `NULL == phDevices`
4028-
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
4029-
/// + If `hProgram` isn't a valid program object.
4030-
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
4031-
/// + If an error occurred when building `hProgram`.
4032-
UR_APIEXPORT ur_result_t UR_APICALL
4033-
urProgramBuildExp(
4034-
ur_context_handle_t hContext, ///< [in] handle of the context instance.
4035-
ur_program_handle_t hProgram, ///< [in] Handle of the program to build.
4036-
uint32_t numDevices, ///< [in] number of devices
4037-
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
4038-
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
4039-
);
4040-
40414006
///////////////////////////////////////////////////////////////////////////////
40424007
/// @brief Produces an executable program from one or more programs.
40434008
///
@@ -8068,6 +8033,131 @@ urCommandBufferEnqueueExp(
80688033
///< command-buffer execution instance.
80698034
);
80708035

8036+
#if !defined(__GNUC__)
8037+
#pragma endregion
8038+
#endif
8039+
// Intel 'oneAPI' Unified Runtime Experimental APIs for multi-device compile
8040+
#if !defined(__GNUC__)
8041+
#pragma region multi device compile(experimental)
8042+
#endif
8043+
///////////////////////////////////////////////////////////////////////////////
8044+
#ifndef UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP
8045+
/// @brief The extension string which defines support for test
8046+
/// which is returned when querying device extensions.
8047+
#define UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP "ur_exp_multi_device_compile"
8048+
#endif // UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP
8049+
8050+
///////////////////////////////////////////////////////////////////////////////
8051+
/// @brief Produces an executable program from one program, negates need for the
8052+
/// linking step.
8053+
///
8054+
/// @details
8055+
/// - The application may call this function from simultaneous threads.
8056+
/// - Following a successful call to this entry point, the program passed
8057+
/// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type
8058+
/// for each device in `phDevices`.
8059+
///
8060+
/// @remarks
8061+
/// _Analogues_
8062+
/// - **clBuildProgram**
8063+
///
8064+
/// @returns
8065+
/// - ::UR_RESULT_SUCCESS
8066+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8067+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8068+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8069+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8070+
/// + `NULL == hProgram`
8071+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8072+
/// + `NULL == phDevices`
8073+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8074+
/// + If `hProgram` isn't a valid program object.
8075+
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
8076+
/// + If an error occurred when building `hProgram`.
8077+
UR_APIEXPORT ur_result_t UR_APICALL
8078+
urProgramBuildExp(
8079+
ur_program_handle_t hProgram, ///< [in] Handle of the program to build.
8080+
uint32_t numDevices, ///< [in] number of devices
8081+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8082+
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
8083+
);
8084+
8085+
///////////////////////////////////////////////////////////////////////////////
8086+
/// @brief Produces an executable program from one or more programs.
8087+
///
8088+
/// @details
8089+
/// - The application may call this function from simultaneous threads.
8090+
/// - Following a successful call to this entry point `hProgram` will
8091+
/// contain a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type
8092+
/// for each device in `phDevices`.
8093+
///
8094+
/// @remarks
8095+
/// _Analogues_
8096+
/// - **clCompileProgram**
8097+
///
8098+
/// @returns
8099+
/// - ::UR_RESULT_SUCCESS
8100+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8101+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8102+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8103+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8104+
/// + `NULL == hProgram`
8105+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8106+
/// + `NULL == phDevices`
8107+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8108+
/// + If `hProgram` isn't a valid program object.
8109+
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
8110+
/// + If an error occurred while compiling `hProgram`.
8111+
UR_APIEXPORT ur_result_t UR_APICALL
8112+
urProgramCompileExp(
8113+
ur_program_handle_t hProgram, ///< [in][out] handle of the program to compile.
8114+
uint32_t numDevices, ///< [in] number of devices
8115+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8116+
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
8117+
);
8118+
8119+
///////////////////////////////////////////////////////////////////////////////
8120+
/// @brief Produces an executable program from one or more programs.
8121+
///
8122+
/// @details
8123+
/// - The application may call this function from simultaneous threads.
8124+
/// - Following a successful call to this entry point the program returned
8125+
/// in `phProgram` will contain a binary of the
8126+
/// ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in
8127+
/// `phDevices`.
8128+
///
8129+
/// @remarks
8130+
/// _Analogues_
8131+
/// - **clLinkProgram**
8132+
///
8133+
/// @returns
8134+
/// - ::UR_RESULT_SUCCESS
8135+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
8136+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
8137+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
8138+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
8139+
/// + `NULL == hContext`
8140+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
8141+
/// + `NULL == phDevices`
8142+
/// + `NULL == phPrograms`
8143+
/// + `NULL == phProgram`
8144+
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
8145+
/// + If one of the programs in `phPrograms` isn't a valid program object.
8146+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
8147+
/// + `count == 0`
8148+
/// - ::UR_RESULT_ERROR_PROGRAM_LINK_FAILURE
8149+
/// + If an error occurred while linking `phPrograms`.
8150+
UR_APIEXPORT ur_result_t UR_APICALL
8151+
urProgramLinkExp(
8152+
ur_context_handle_t hContext, ///< [in] handle of the context instance.
8153+
uint32_t numDevices, ///< [in] number of devices
8154+
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
8155+
uint32_t count, ///< [in] number of program handles in `phPrograms`.
8156+
const ur_program_handle_t *phPrograms, ///< [in][range(0, count)] pointer to array of program handles.
8157+
const char *pOptions, ///< [in][optional] pointer to linker options null-terminated string.
8158+
ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created.
8159+
);
8160+
80718161
#if !defined(__GNUC__)
80728162
#pragma endregion
80738163
#endif
@@ -8574,7 +8664,6 @@ typedef struct ur_program_build_params_t {
85748664
/// @details Each entry is a pointer to the parameter passed to the function;
85758665
/// allowing the callback the ability to modify the parameter's value
85768666
typedef struct ur_program_build_exp_params_t {
8577-
ur_context_handle_t *phContext;
85788667
ur_program_handle_t *phProgram;
85798668
uint32_t *pnumDevices;
85808669
ur_device_handle_t **pphDevices;
@@ -8591,6 +8680,17 @@ typedef struct ur_program_compile_params_t {
85918680
const char **ppOptions;
85928681
} ur_program_compile_params_t;
85938682

8683+
///////////////////////////////////////////////////////////////////////////////
8684+
/// @brief Function parameters for urProgramCompileExp
8685+
/// @details Each entry is a pointer to the parameter passed to the function;
8686+
/// allowing the callback the ability to modify the parameter's value
8687+
typedef struct ur_program_compile_exp_params_t {
8688+
ur_program_handle_t *phProgram;
8689+
uint32_t *pnumDevices;
8690+
ur_device_handle_t **pphDevices;
8691+
const char **ppOptions;
8692+
} ur_program_compile_exp_params_t;
8693+
85948694
///////////////////////////////////////////////////////////////////////////////
85958695
/// @brief Function parameters for urProgramLink
85968696
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -8603,6 +8703,20 @@ typedef struct ur_program_link_params_t {
86038703
ur_program_handle_t **pphProgram;
86048704
} ur_program_link_params_t;
86058705

8706+
///////////////////////////////////////////////////////////////////////////////
8707+
/// @brief Function parameters for urProgramLinkExp
8708+
/// @details Each entry is a pointer to the parameter passed to the function;
8709+
/// allowing the callback the ability to modify the parameter's value
8710+
typedef struct ur_program_link_exp_params_t {
8711+
ur_context_handle_t *phContext;
8712+
uint32_t *pnumDevices;
8713+
ur_device_handle_t **pphDevices;
8714+
uint32_t *pcount;
8715+
const ur_program_handle_t **pphPrograms;
8716+
const char **ppOptions;
8717+
ur_program_handle_t **pphProgram;
8718+
} ur_program_link_exp_params_t;
8719+
86068720
///////////////////////////////////////////////////////////////////////////////
86078721
/// @brief Function parameters for urProgramRetain
86088722
/// @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)