Skip to content

Commit

Permalink
Merge changes from multi device compile extension into core spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongreig committed Sep 23, 2024
1 parent 9ca3ec7 commit b5c3e7c
Show file tree
Hide file tree
Showing 47 changed files with 345 additions and 2,057 deletions.
2 changes: 1 addition & 1 deletion examples/codegen/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int main() {
ur_program_handle_t hProgram;
ur_check(urProgramCreateWithIL(hContext, spv.data(), spv.size(), nullptr,
&hProgram));
ur_check(urProgramBuild(hContext, hProgram, nullptr));
ur_check(urProgramBuild(hProgram, 1, &current_device, nullptr));

ur_mem_handle_t dA, dB;
ur_check(urMemBufferCreate(hContext, UR_MEM_FLAG_READ_WRITE,
Expand Down
199 changes: 23 additions & 176 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ typedef enum ur_function_t {
UR_FUNCTION_ADAPTER_RETAIN = 179, ///< Enumerator for ::urAdapterRetain
UR_FUNCTION_ADAPTER_GET_LAST_ERROR = 180, ///< Enumerator for ::urAdapterGetLastError
UR_FUNCTION_ADAPTER_GET_INFO = 181, ///< Enumerator for ::urAdapterGetInfo
UR_FUNCTION_PROGRAM_BUILD_EXP = 197, ///< Enumerator for ::urProgramBuildExp
UR_FUNCTION_PROGRAM_COMPILE_EXP = 198, ///< Enumerator for ::urProgramCompileExp
UR_FUNCTION_PROGRAM_LINK_EXP = 199, ///< Enumerator for ::urProgramLinkExp
UR_FUNCTION_LOADER_CONFIG_SET_CODE_LOCATION_CALLBACK = 200, ///< Enumerator for ::urLoaderConfigSetCodeLocationCallback
UR_FUNCTION_LOADER_INIT = 201, ///< Enumerator for ::urLoaderInit
UR_FUNCTION_LOADER_TEAR_DOWN = 202, ///< Enumerator for ::urLoaderTearDown
Expand Down Expand Up @@ -4262,17 +4259,21 @@ urProgramCreateWithBinary(
/// - ::UR_RESULT_ERROR_DEVICE_LOST
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hContext`
/// + `NULL == hProgram`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phDevices`
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
/// + If `hProgram` isn't a valid program object.
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
/// + If an error occurred when building `hProgram`.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// + `numDevices == 0`
UR_APIEXPORT ur_result_t UR_APICALL
urProgramBuild(
ur_context_handle_t hContext, ///< [in] handle of the context instance.
ur_program_handle_t hProgram, ///< [in] Handle of the program to build.
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
ur_program_handle_t hProgram, ///< [in] Handle of the program to build.
uint32_t numDevices, ///< [in] length of `phDevices`
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
);

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -4294,17 +4295,21 @@ urProgramBuild(
/// - ::UR_RESULT_ERROR_DEVICE_LOST
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hContext`
/// + `NULL == hProgram`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phDevices`
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
/// + If `hProgram` isn't a valid program object.
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
/// + If an error occurred while compiling `hProgram`.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// + `numDevices == 0`
UR_APIEXPORT ur_result_t UR_APICALL
urProgramCompile(
ur_context_handle_t hContext, ///< [in] handle of the context instance.
ur_program_handle_t hProgram, ///< [in][out] handle of the program to compile.
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
ur_program_handle_t hProgram, ///< [in][out] handle of the program to compile.
uint32_t numDevices, ///< [in] length of `phDevices`
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
);

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -4334,17 +4339,21 @@ urProgramCompile(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phDevices`
/// + `NULL == phPrograms`
/// + `NULL == phProgram`
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
/// + If one of the programs in `phPrograms` isn't a valid program object.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// + `numDevices == 0`
/// + `count == 0`
/// - ::UR_RESULT_ERROR_PROGRAM_LINK_FAILURE
/// + If an error occurred while linking `phPrograms`.
UR_APIEXPORT ur_result_t UR_APICALL
urProgramLink(
ur_context_handle_t hContext, ///< [in] handle of the context instance.
uint32_t numDevices, ///< [in] number of devices
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
uint32_t count, ///< [in] number of program handles in `phPrograms`.
const ur_program_handle_t *phPrograms, ///< [in][range(0, count)] pointer to array of program handles.
const char *pOptions, ///< [in][optional] pointer to linker options null-terminated string.
Expand Down Expand Up @@ -9266,136 +9275,6 @@ urEnqueueKernelLaunchCustomExp(
///< kernel execution instance.
);

#if !defined(__GNUC__)
#pragma endregion
#endif
// Intel 'oneAPI' Unified Runtime Experimental APIs for multi-device compile
#if !defined(__GNUC__)
#pragma region multi_device_compile_(experimental)
#endif
///////////////////////////////////////////////////////////////////////////////
#ifndef UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP
/// @brief The extension string which defines support for test
/// which is returned when querying device extensions.
#define UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP "ur_exp_multi_device_compile"
#endif // UR_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP

///////////////////////////////////////////////////////////////////////////////
/// @brief Produces an executable program from one program, negates need for the
/// linking step.
///
/// @details
/// - The application may call this function from simultaneous threads.
/// - Following a successful call to this entry point, the program passed
/// will contain a binary of the ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type
/// for each device in `phDevices`.
///
/// @remarks
/// _Analogues_
/// - **clBuildProgram**
///
/// @returns
/// - ::UR_RESULT_SUCCESS
/// - ::UR_RESULT_ERROR_UNINITIALIZED
/// - ::UR_RESULT_ERROR_DEVICE_LOST
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hProgram`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phDevices`
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
/// + If `hProgram` isn't a valid program object.
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
/// + If an error occurred when building `hProgram`.
UR_APIEXPORT ur_result_t UR_APICALL
urProgramBuildExp(
ur_program_handle_t hProgram, ///< [in] Handle of the program to build.
uint32_t numDevices, ///< [in] number of devices
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
);

///////////////////////////////////////////////////////////////////////////////
/// @brief Produces an executable program from one or more programs.
///
/// @details
/// - The application may call this function from simultaneous threads.
/// - Following a successful call to this entry point `hProgram` will
/// contain a binary of the ::UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type
/// for each device in `phDevices`.
///
/// @remarks
/// _Analogues_
/// - **clCompileProgram**
///
/// @returns
/// - ::UR_RESULT_SUCCESS
/// - ::UR_RESULT_ERROR_UNINITIALIZED
/// - ::UR_RESULT_ERROR_DEVICE_LOST
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hProgram`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phDevices`
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
/// + If `hProgram` isn't a valid program object.
/// - ::UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE
/// + If an error occurred while compiling `hProgram`.
UR_APIEXPORT ur_result_t UR_APICALL
urProgramCompileExp(
ur_program_handle_t hProgram, ///< [in][out] handle of the program to compile.
uint32_t numDevices, ///< [in] number of devices
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
const char *pOptions ///< [in][optional] pointer to build options null-terminated string.
);

///////////////////////////////////////////////////////////////////////////////
/// @brief Produces an executable program from one or more programs.
///
/// @details
/// - The application may call this function from simultaneous threads.
/// - Following a successful call to this entry point the program returned
/// in `phProgram` will contain a binary of the
/// ::UR_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in
/// `phDevices`.
/// - If a non-success code is returned and `phProgram` is not `nullptr`, it
/// will contain an unspecified program or `nullptr`. Implementations may
/// use the build log of this program (accessible via
/// ::urProgramGetBuildInfo) to provide an error log for the linking
/// failure.
///
/// @remarks
/// _Analogues_
/// - **clLinkProgram**
///
/// @returns
/// - ::UR_RESULT_SUCCESS
/// - ::UR_RESULT_ERROR_UNINITIALIZED
/// - ::UR_RESULT_ERROR_DEVICE_LOST
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phDevices`
/// + `NULL == phPrograms`
/// + `NULL == phProgram`
/// - ::UR_RESULT_ERROR_INVALID_PROGRAM
/// + If one of the programs in `phPrograms` isn't a valid program object.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// + `count == 0`
/// - ::UR_RESULT_ERROR_PROGRAM_LINK_FAILURE
/// + If an error occurred while linking `phPrograms`.
UR_APIEXPORT ur_result_t UR_APICALL
urProgramLinkExp(
ur_context_handle_t hContext, ///< [in] handle of the context instance.
uint32_t numDevices, ///< [in] number of devices
ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] pointer to array of device handles
uint32_t count, ///< [in] number of program handles in `phPrograms`.
const ur_program_handle_t *phPrograms, ///< [in][range(0, count)] pointer to array of program handles.
const char *pOptions, ///< [in][optional] pointer to linker options null-terminated string.
ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created.
);

#if !defined(__GNUC__)
#pragma endregion
#endif
Expand Down Expand Up @@ -9993,68 +9872,36 @@ typedef struct ur_program_create_with_binary_params_t {
/// @details Each entry is a pointer to the parameter passed to the function;
/// allowing the callback the ability to modify the parameter's value
typedef struct ur_program_build_params_t {
ur_context_handle_t *phContext;
ur_program_handle_t *phProgram;
const char **ppOptions;
} ur_program_build_params_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Function parameters for urProgramBuildExp
/// @details Each entry is a pointer to the parameter passed to the function;
/// allowing the callback the ability to modify the parameter's value
typedef struct ur_program_build_exp_params_t {
ur_program_handle_t *phProgram;
uint32_t *pnumDevices;
ur_device_handle_t **pphDevices;
const char **ppOptions;
} ur_program_build_exp_params_t;
} ur_program_build_params_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Function parameters for urProgramCompile
/// @details Each entry is a pointer to the parameter passed to the function;
/// allowing the callback the ability to modify the parameter's value
typedef struct ur_program_compile_params_t {
ur_context_handle_t *phContext;
ur_program_handle_t *phProgram;
const char **ppOptions;
} ur_program_compile_params_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Function parameters for urProgramCompileExp
/// @details Each entry is a pointer to the parameter passed to the function;
/// allowing the callback the ability to modify the parameter's value
typedef struct ur_program_compile_exp_params_t {
ur_program_handle_t *phProgram;
uint32_t *pnumDevices;
ur_device_handle_t **pphDevices;
const char **ppOptions;
} ur_program_compile_exp_params_t;
} ur_program_compile_params_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Function parameters for urProgramLink
/// @details Each entry is a pointer to the parameter passed to the function;
/// allowing the callback the ability to modify the parameter's value
typedef struct ur_program_link_params_t {
ur_context_handle_t *phContext;
uint32_t *pcount;
const ur_program_handle_t **pphPrograms;
const char **ppOptions;
ur_program_handle_t **pphProgram;
} ur_program_link_params_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Function parameters for urProgramLinkExp
/// @details Each entry is a pointer to the parameter passed to the function;
/// allowing the callback the ability to modify the parameter's value
typedef struct ur_program_link_exp_params_t {
ur_context_handle_t *phContext;
uint32_t *pnumDevices;
ur_device_handle_t **pphDevices;
uint32_t *pcount;
const ur_program_handle_t **pphPrograms;
const char **ppOptions;
ur_program_handle_t **pphProgram;
} ur_program_link_exp_params_t;
} ur_program_link_params_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Function parameters for urProgramRetain
Expand Down
3 changes: 0 additions & 3 deletions include/ur_api_funcs.def
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ _UR_API(urProgramGetBuildInfo)
_UR_API(urProgramSetSpecializationConstants)
_UR_API(urProgramGetNativeHandle)
_UR_API(urProgramCreateWithNativeHandle)
_UR_API(urProgramBuildExp)
_UR_API(urProgramCompileExp)
_UR_API(urProgramLinkExp)
_UR_API(urKernelCreate)
_UR_API(urKernelGetInfo)
_UR_API(urKernelGetGroupInfo)
Expand Down
Loading

0 comments on commit b5c3e7c

Please sign in to comment.