Skip to content

Commit 13aaca7

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 b63431e commit 13aaca7

File tree

14 files changed

+1222
-303
lines changed

14 files changed

+1222
-303
lines changed

include/ur.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ class ur_function_v(IntEnum):
197197
ADAPTER_GET_LAST_ERROR = 180 ## Enumerator for ::urAdapterGetLastError
198198
ADAPTER_GET_INFO = 181 ## Enumerator for ::urAdapterGetInfo
199199
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):
@@ -2249,6 +2251,11 @@ class ur_exp_command_buffer_sync_point_t(c_ulong):
22492251
class ur_exp_command_buffer_handle_t(c_void_p):
22502252
pass
22512253

2254+
###############################################################################
2255+
## @brief The extension string which defines support for test
2256+
## which is returned when querying device extensions.
2257+
UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP = "ur_exp_multi_device_compile"
2258+
22522259
###############################################################################
22532260
## @brief Supported peer info
22542261
class ur_exp_peer_info_v(IntEnum):
@@ -2568,16 +2575,32 @@ class ur_program_dditable_t(Structure):
25682575
###############################################################################
25692576
## @brief Function-pointer for urProgramBuildExp
25702577
if __use_win_types:
2571-
_urProgramBuildExp_t = WINFUNCTYPE( ur_result_t, ur_context_handle_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2578+
_urProgramBuildExp_t = WINFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2579+
else:
2580+
_urProgramBuildExp_t = CFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2581+
2582+
###############################################################################
2583+
## @brief Function-pointer for urProgramCompileExp
2584+
if __use_win_types:
2585+
_urProgramCompileExp_t = WINFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2586+
else:
2587+
_urProgramCompileExp_t = CFUNCTYPE( ur_result_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2588+
2589+
###############################################################################
2590+
## @brief Function-pointer for urProgramLinkExp
2591+
if __use_win_types:
2592+
_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) )
25722593
else:
2573-
_urProgramBuildExp_t = CFUNCTYPE( ur_result_t, ur_context_handle_t, ur_program_handle_t, c_ulong, POINTER(ur_device_handle_t), c_char_p )
2594+
_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) )
25742595

25752596

25762597
###############################################################################
25772598
## @brief Table of ProgramExp functions pointers
25782599
class ur_program_exp_dditable_t(Structure):
25792600
_fields_ = [
2580-
("pfnBuildExp", c_void_p) ## _urProgramBuildExp_t
2601+
("pfnBuildExp", c_void_p), ## _urProgramBuildExp_t
2602+
("pfnCompileExp", c_void_p), ## _urProgramCompileExp_t
2603+
("pfnLinkExp", c_void_p) ## _urProgramLinkExp_t
25812604
]
25822605

25832606
###############################################################################
@@ -3877,6 +3900,8 @@ def __init__(self, version : ur_api_version_t):
38773900

38783901
# attach function interface to function address
38793902
self.urProgramBuildExp = _urProgramBuildExp_t(self.__dditable.ProgramExp.pfnBuildExp)
3903+
self.urProgramCompileExp = _urProgramCompileExp_t(self.__dditable.ProgramExp.pfnCompileExp)
3904+
self.urProgramLinkExp = _urProgramLinkExp_t(self.__dditable.ProgramExp.pfnLinkExp)
38803905

38813906
# call driver to get function pointers
38823907
Kernel = ur_kernel_dditable_t()

include/ur_api.h

Lines changed: 152 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ typedef enum ur_function_t {
206206
UR_FUNCTION_ADAPTER_GET_LAST_ERROR = 180, ///< Enumerator for ::urAdapterGetLastError
207207
UR_FUNCTION_ADAPTER_GET_INFO = 181, ///< Enumerator for ::urAdapterGetInfo
208208
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
@@ -3994,43 +3996,6 @@ urProgramBuild(
39943996
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
39953997
);
39963998

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

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

8678+
///////////////////////////////////////////////////////////////////////////////
8679+
/// @brief Function parameters for urProgramCompileExp
8680+
/// @details Each entry is a pointer to the parameter passed to the function;
8681+
/// allowing the callback the ability to modify the parameter's value
8682+
typedef struct ur_program_compile_exp_params_t {
8683+
ur_program_handle_t *phProgram;
8684+
uint32_t *pnumDevices;
8685+
ur_device_handle_t **pphDevices;
8686+
const char **ppOptions;
8687+
} ur_program_compile_exp_params_t;
8688+
85898689
///////////////////////////////////////////////////////////////////////////////
85908690
/// @brief Function parameters for urProgramLink
85918691
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -8598,6 +8698,20 @@ typedef struct ur_program_link_params_t {
85988698
ur_program_handle_t **pphProgram;
85998699
} ur_program_link_params_t;
86008700

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