Skip to content

Commit 32ff17d

Browse files
authored
Merge pull request #919 from igchor/multi_dev_build_0.7
[UR][L0] Add support for passing device list to urProgramBuild
2 parents 47b6386 + 13aaca7 commit 32ff17d

File tree

15 files changed

+1510
-0
lines changed

15 files changed

+1510
-0
lines changed

.github/workflows/cmake.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ jobs:
110110
- name: Install prerequisites
111111
run: python3 -m pip install -r third_party/requirements.txt
112112

113+
- name: Install doxygen
114+
run: |
115+
$WorkingDir = $PWD.Path
116+
Invoke-WebRequest -Uri https://github.com/doxygen/doxygen/releases/download/Release_1_9_8/doxygen-1.9.8.windows.x64.bin.zip -OutFile "$WorkingDir\doxygen.zip"
117+
Expand-Archive -Path "$WorkingDir\doxygen.zip"
118+
Add-Content $env:GITHUB_PATH "$WorkingDir\doxygen"
119+
113120
- name: Configure CMake
114121
run: >
115122
cmake

include/ur.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +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 = 197 ## Enumerator for ::urProgramBuildExp
200+
PROGRAM_COMPILE_EXP = 198 ## Enumerator for ::urProgramCompileExp
201+
PROGRAM_LINK_EXP = 199 ## Enumerator for ::urProgramLinkExp
199202

200203
class ur_function_t(c_int):
201204
def __str__(self):
@@ -2248,6 +2251,11 @@ class ur_exp_command_buffer_sync_point_t(c_ulong):
22482251
class ur_exp_command_buffer_handle_t(c_void_p):
22492252
pass
22502253

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+
22512259
###############################################################################
22522260
## @brief Supported peer info
22532261
class ur_exp_peer_info_v(IntEnum):
@@ -2564,6 +2572,37 @@ class ur_program_dditable_t(Structure):
25642572
("pfnCreateWithNativeHandle", c_void_p) ## _urProgramCreateWithNativeHandle_t
25652573
]
25662574

2575+
###############################################################################
2576+
## @brief Function-pointer for urProgramBuildExp
2577+
if __use_win_types:
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) )
2593+
else:
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) )
2595+
2596+
2597+
###############################################################################
2598+
## @brief Table of ProgramExp functions pointers
2599+
class ur_program_exp_dditable_t(Structure):
2600+
_fields_ = [
2601+
("pfnBuildExp", c_void_p), ## _urProgramBuildExp_t
2602+
("pfnCompileExp", c_void_p), ## _urProgramCompileExp_t
2603+
("pfnLinkExp", c_void_p) ## _urProgramLinkExp_t
2604+
]
2605+
25672606
###############################################################################
25682607
## @brief Function-pointer for urKernelCreate
25692608
if __use_win_types:
@@ -3749,6 +3788,7 @@ class ur_dditable_t(Structure):
37493788
("Context", ur_context_dditable_t),
37503789
("Event", ur_event_dditable_t),
37513790
("Program", ur_program_dditable_t),
3791+
("ProgramExp", ur_program_exp_dditable_t),
37523792
("Kernel", ur_kernel_dditable_t),
37533793
("Sampler", ur_sampler_dditable_t),
37543794
("Mem", ur_mem_dditable_t),
@@ -3851,6 +3891,18 @@ def __init__(self, version : ur_api_version_t):
38513891
self.urProgramGetNativeHandle = _urProgramGetNativeHandle_t(self.__dditable.Program.pfnGetNativeHandle)
38523892
self.urProgramCreateWithNativeHandle = _urProgramCreateWithNativeHandle_t(self.__dditable.Program.pfnCreateWithNativeHandle)
38533893

3894+
# call driver to get function pointers
3895+
ProgramExp = ur_program_exp_dditable_t()
3896+
r = ur_result_v(self.__dll.urGetProgramExpProcAddrTable(version, byref(ProgramExp)))
3897+
if r != ur_result_v.SUCCESS:
3898+
raise Exception(r)
3899+
self.__dditable.ProgramExp = ProgramExp
3900+
3901+
# attach function interface to function address
3902+
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)
3905+
38543906
# call driver to get function pointers
38553907
Kernel = ur_kernel_dditable_t()
38563908
r = ur_result_v(self.__dll.urGetKernelProcAddrTable(version, byref(Kernel)))

include/ur_api.h

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +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 = 197, ///< Enumerator for ::urProgramBuildExp
209+
UR_FUNCTION_PROGRAM_COMPILE_EXP = 198, ///< Enumerator for ::urProgramCompileExp
210+
UR_FUNCTION_PROGRAM_LINK_EXP = 199, ///< Enumerator for ::urProgramLinkExp
208211
/// @cond
209212
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
210213
/// @endcond
@@ -8025,6 +8028,131 @@ urCommandBufferEnqueueExp(
80258028
///< command-buffer execution instance.
80268029
);
80278030

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+
80288156
#if !defined(__GNUC__)
80298157
#pragma endregion
80308158
#endif
@@ -8526,6 +8654,17 @@ typedef struct ur_program_build_params_t {
85268654
const char **ppOptions;
85278655
} ur_program_build_params_t;
85288656

8657+
///////////////////////////////////////////////////////////////////////////////
8658+
/// @brief Function parameters for urProgramBuildExp
8659+
/// @details Each entry is a pointer to the parameter passed to the function;
8660+
/// allowing the callback the ability to modify the parameter's value
8661+
typedef struct ur_program_build_exp_params_t {
8662+
ur_program_handle_t *phProgram;
8663+
uint32_t *pnumDevices;
8664+
ur_device_handle_t **pphDevices;
8665+
const char **ppOptions;
8666+
} ur_program_build_exp_params_t;
8667+
85298668
///////////////////////////////////////////////////////////////////////////////
85308669
/// @brief Function parameters for urProgramCompile
85318670
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -8536,6 +8675,17 @@ typedef struct ur_program_compile_params_t {
85368675
const char **ppOptions;
85378676
} ur_program_compile_params_t;
85388677

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+
85398689
///////////////////////////////////////////////////////////////////////////////
85408690
/// @brief Function parameters for urProgramLink
85418691
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -8548,6 +8698,20 @@ typedef struct ur_program_link_params_t {
85488698
ur_program_handle_t **pphProgram;
85498699
} ur_program_link_params_t;
85508700

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+
85518715
///////////////////////////////////////////////////////////////////////////////
85528716
/// @brief Function parameters for urProgramRetain
85538717
/// @details Each entry is a pointer to the parameter passed to the function;

include/ur_ddi.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,62 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetProgramProcAddrTable_t)(
408408
ur_api_version_t,
409409
ur_program_dditable_t *);
410410

411+
///////////////////////////////////////////////////////////////////////////////
412+
/// @brief Function-pointer for urProgramBuildExp
413+
typedef ur_result_t(UR_APICALL *ur_pfnProgramBuildExp_t)(
414+
ur_program_handle_t,
415+
uint32_t,
416+
ur_device_handle_t *,
417+
const char *);
418+
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+
438+
///////////////////////////////////////////////////////////////////////////////
439+
/// @brief Table of ProgramExp functions pointers
440+
typedef struct ur_program_exp_dditable_t {
441+
ur_pfnProgramBuildExp_t pfnBuildExp;
442+
ur_pfnProgramCompileExp_t pfnCompileExp;
443+
ur_pfnProgramLinkExp_t pfnLinkExp;
444+
} ur_program_exp_dditable_t;
445+
446+
///////////////////////////////////////////////////////////////////////////////
447+
/// @brief Exported function for filling application's ProgramExp table
448+
/// with current process' addresses
449+
///
450+
/// @returns
451+
/// - ::UR_RESULT_SUCCESS
452+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
453+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
454+
/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION
455+
UR_DLLEXPORT ur_result_t UR_APICALL
456+
urGetProgramExpProcAddrTable(
457+
ur_api_version_t version, ///< [in] API version requested
458+
ur_program_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers
459+
);
460+
461+
///////////////////////////////////////////////////////////////////////////////
462+
/// @brief Function-pointer for urGetProgramExpProcAddrTable
463+
typedef ur_result_t(UR_APICALL *ur_pfnGetProgramExpProcAddrTable_t)(
464+
ur_api_version_t,
465+
ur_program_exp_dditable_t *);
466+
411467
///////////////////////////////////////////////////////////////////////////////
412468
/// @brief Function-pointer for urKernelCreate
413469
typedef ur_result_t(UR_APICALL *ur_pfnKernelCreate_t)(
@@ -2139,6 +2195,7 @@ typedef struct ur_dditable_t {
21392195
ur_context_dditable_t Context;
21402196
ur_event_dditable_t Event;
21412197
ur_program_dditable_t Program;
2198+
ur_program_exp_dditable_t ProgramExp;
21422199
ur_kernel_dditable_t Kernel;
21432200
ur_sampler_dditable_t Sampler;
21442201
ur_mem_dditable_t Mem;

0 commit comments

Comments
 (0)