Skip to content

Commit ce152a6

Browse files
authored
Merge pull request intel#934 from nrspruit/fixprogrambuild_updated
[UR][L0] Add support for passing device list to urProgramBuild/Link/Compile
2 parents 04799e7 + 0790bf8 commit ce152a6

24 files changed

+1682
-42
lines changed

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):
@@ -2253,6 +2256,11 @@ class ur_exp_command_buffer_sync_point_t(c_ulong):
22532256
class ur_exp_command_buffer_handle_t(c_void_p):
22542257
pass
22552258

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+
22562264
###############################################################################
22572265
## @brief Supported peer info
22582266
class ur_exp_peer_info_v(IntEnum):
@@ -2569,6 +2577,37 @@ class ur_program_dditable_t(Structure):
25692577
("pfnCreateWithNativeHandle", c_void_p) ## _urProgramCreateWithNativeHandle_t
25702578
]
25712579

2580+
###############################################################################
2581+
## @brief Function-pointer for urProgramBuildExp
2582+
if __use_win_types:
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) )
2598+
else:
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) )
2600+
2601+
2602+
###############################################################################
2603+
## @brief Table of ProgramExp functions pointers
2604+
class ur_program_exp_dditable_t(Structure):
2605+
_fields_ = [
2606+
("pfnBuildExp", c_void_p), ## _urProgramBuildExp_t
2607+
("pfnCompileExp", c_void_p), ## _urProgramCompileExp_t
2608+
("pfnLinkExp", c_void_p) ## _urProgramLinkExp_t
2609+
]
2610+
25722611
###############################################################################
25732612
## @brief Function-pointer for urKernelCreate
25742613
if __use_win_types:
@@ -3754,6 +3793,7 @@ class ur_dditable_t(Structure):
37543793
("Context", ur_context_dditable_t),
37553794
("Event", ur_event_dditable_t),
37563795
("Program", ur_program_dditable_t),
3796+
("ProgramExp", ur_program_exp_dditable_t),
37573797
("Kernel", ur_kernel_dditable_t),
37583798
("Sampler", ur_sampler_dditable_t),
37593799
("Mem", ur_mem_dditable_t),
@@ -3856,6 +3896,18 @@ def __init__(self, version : ur_api_version_t):
38563896
self.urProgramGetNativeHandle = _urProgramGetNativeHandle_t(self.__dditable.Program.pfnGetNativeHandle)
38573897
self.urProgramCreateWithNativeHandle = _urProgramCreateWithNativeHandle_t(self.__dditable.Program.pfnCreateWithNativeHandle)
38583898

3899+
# call driver to get function pointers
3900+
ProgramExp = ur_program_exp_dditable_t()
3901+
r = ur_result_v(self.__dll.urGetProgramExpProcAddrTable(version, byref(ProgramExp)))
3902+
if r != ur_result_v.SUCCESS:
3903+
raise Exception(r)
3904+
self.__dditable.ProgramExp = ProgramExp
3905+
3906+
# attach function interface to function address
3907+
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)
3910+
38593911
# call driver to get function pointers
38603912
Kernel = ur_kernel_dditable_t()
38613913
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
@@ -8030,6 +8033,131 @@ urCommandBufferEnqueueExp(
80308033
///< command-buffer execution instance.
80318034
);
80328035

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+
80338161
#if !defined(__GNUC__)
80348162
#pragma endregion
80358163
#endif
@@ -8531,6 +8659,17 @@ typedef struct ur_program_build_params_t {
85318659
const char **ppOptions;
85328660
} ur_program_build_params_t;
85338661

8662+
///////////////////////////////////////////////////////////////////////////////
8663+
/// @brief Function parameters for urProgramBuildExp
8664+
/// @details Each entry is a pointer to the parameter passed to the function;
8665+
/// allowing the callback the ability to modify the parameter's value
8666+
typedef struct ur_program_build_exp_params_t {
8667+
ur_program_handle_t *phProgram;
8668+
uint32_t *pnumDevices;
8669+
ur_device_handle_t **pphDevices;
8670+
const char **ppOptions;
8671+
} ur_program_build_exp_params_t;
8672+
85348673
///////////////////////////////////////////////////////////////////////////////
85358674
/// @brief Function parameters for urProgramCompile
85368675
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -8541,6 +8680,17 @@ typedef struct ur_program_compile_params_t {
85418680
const char **ppOptions;
85428681
} ur_program_compile_params_t;
85438682

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+
85448694
///////////////////////////////////////////////////////////////////////////////
85458695
/// @brief Function parameters for urProgramLink
85468696
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -8553,6 +8703,20 @@ typedef struct ur_program_link_params_t {
85538703
ur_program_handle_t **pphProgram;
85548704
} ur_program_link_params_t;
85558705

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+
85568720
///////////////////////////////////////////////////////////////////////////////
85578721
/// @brief Function parameters for urProgramRetain
85588722
/// @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)