diff --git a/examples/codegen/codegen.cpp b/examples/codegen/codegen.cpp index 82834688fb..592254f82b 100644 --- a/examples/codegen/codegen.cpp +++ b/examples/codegen/codegen.cpp @@ -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, ¤t_device, nullptr)); ur_mem_handle_t dA, dB; ur_check(urMemBufferCreate(hContext, UR_MEM_FLAG_READ_WRITE, diff --git a/include/ur_api.h b/include/ur_api.h index 3cf5f99624..bf619aafc5 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -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 @@ -4263,17 +4260,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. ); /////////////////////////////////////////////////////////////////////////////// @@ -4295,17 +4296,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. ); /////////////////////////////////////////////////////////////////////////////// @@ -4335,17 +4340,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. @@ -9318,136 +9327,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 @@ -10045,60 +9924,28 @@ 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; @@ -10106,7 +9953,7 @@ typedef struct ur_program_link_exp_params_t { 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 diff --git a/include/ur_api_funcs.def b/include/ur_api_funcs.def index 5cd8dd7926..9434f5b19d 100644 --- a/include/ur_api_funcs.def +++ b/include/ur_api_funcs.def @@ -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) diff --git a/include/ur_ddi.h b/include/ur_ddi.h index d2f79f4515..561f6ab0e4 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -293,15 +293,17 @@ typedef ur_result_t(UR_APICALL *ur_pfnProgramCreateWithBinary_t)( /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urProgramBuild typedef ur_result_t(UR_APICALL *ur_pfnProgramBuild_t)( - ur_context_handle_t, ur_program_handle_t, + uint32_t, + ur_device_handle_t *, const char *); /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urProgramCompile typedef ur_result_t(UR_APICALL *ur_pfnProgramCompile_t)( - ur_context_handle_t, ur_program_handle_t, + uint32_t, + ur_device_handle_t *, const char *); /////////////////////////////////////////////////////////////////////////////// @@ -309,6 +311,8 @@ typedef ur_result_t(UR_APICALL *ur_pfnProgramCompile_t)( typedef ur_result_t(UR_APICALL *ur_pfnProgramLink_t)( ur_context_handle_t, uint32_t, + ur_device_handle_t *, + uint32_t, const ur_program_handle_t *, const char *, ur_program_handle_t *); @@ -420,62 +424,6 @@ typedef ur_result_t(UR_APICALL *ur_pfnGetProgramProcAddrTable_t)( ur_api_version_t, ur_program_dditable_t *); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urProgramBuildExp -typedef ur_result_t(UR_APICALL *ur_pfnProgramBuildExp_t)( - ur_program_handle_t, - uint32_t, - ur_device_handle_t *, - const char *); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urProgramCompileExp -typedef ur_result_t(UR_APICALL *ur_pfnProgramCompileExp_t)( - ur_program_handle_t, - uint32_t, - ur_device_handle_t *, - const char *); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urProgramLinkExp -typedef ur_result_t(UR_APICALL *ur_pfnProgramLinkExp_t)( - ur_context_handle_t, - uint32_t, - ur_device_handle_t *, - uint32_t, - const ur_program_handle_t *, - const char *, - ur_program_handle_t *); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Table of ProgramExp functions pointers -typedef struct ur_program_exp_dditable_t { - ur_pfnProgramBuildExp_t pfnBuildExp; - ur_pfnProgramCompileExp_t pfnCompileExp; - ur_pfnProgramLinkExp_t pfnLinkExp; -} ur_program_exp_dditable_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Exported function for filling application's ProgramExp table -/// with current process' addresses -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION -UR_DLLEXPORT ur_result_t UR_APICALL -urGetProgramExpProcAddrTable( - ur_api_version_t version, ///< [in] API version requested - ur_program_exp_dditable_t *pDdiTable ///< [in,out] pointer to table of DDI function pointers -); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urGetProgramExpProcAddrTable -typedef ur_result_t(UR_APICALL *ur_pfnGetProgramExpProcAddrTable_t)( - ur_api_version_t, - ur_program_exp_dditable_t *); - /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urKernelCreate typedef ur_result_t(UR_APICALL *ur_pfnKernelCreate_t)( @@ -2428,7 +2376,6 @@ typedef struct ur_dditable_t { ur_context_dditable_t Context; ur_event_dditable_t Event; ur_program_dditable_t Program; - ur_program_exp_dditable_t ProgramExp; ur_kernel_dditable_t Kernel; ur_kernel_exp_dditable_t KernelExp; ur_queue_dditable_t Queue; diff --git a/include/ur_print.h b/include/ur_print.h index 54082d5330..0233e869da 100644 --- a/include/ur_print.h +++ b/include/ur_print.h @@ -1322,14 +1322,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramCreateWithBinaryParams(const s /// - `buff_size < out_size` UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramBuildParams(const struct ur_program_build_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_program_build_exp_params_t struct -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_INVALID_SIZE -/// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramBuildExpParams(const struct ur_program_build_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); - /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_program_compile_params_t struct /// @returns @@ -1338,14 +1330,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramBuildExpParams(const struct ur /// - `buff_size < out_size` UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramCompileParams(const struct ur_program_compile_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_program_compile_exp_params_t struct -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_INVALID_SIZE -/// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramCompileExpParams(const struct ur_program_compile_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); - /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_program_link_params_t struct /// @returns @@ -1354,14 +1338,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramCompileExpParams(const struct /// - `buff_size < out_size` UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramLinkParams(const struct ur_program_link_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_program_link_exp_params_t struct -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_INVALID_SIZE -/// - `buff_size < out_size` -UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramLinkExpParams(const struct ur_program_link_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); - /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_program_retain_params_t struct /// @returns diff --git a/include/ur_print.hpp b/include/ur_print.hpp index 417f33b818..d47ce44673 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -843,15 +843,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { case UR_FUNCTION_ADAPTER_GET_INFO: os << "UR_FUNCTION_ADAPTER_GET_INFO"; break; - case UR_FUNCTION_PROGRAM_BUILD_EXP: - os << "UR_FUNCTION_PROGRAM_BUILD_EXP"; - break; - case UR_FUNCTION_PROGRAM_COMPILE_EXP: - os << "UR_FUNCTION_PROGRAM_COMPILE_EXP"; - break; - case UR_FUNCTION_PROGRAM_LINK_EXP: - os << "UR_FUNCTION_PROGRAM_LINK_EXP"; - break; case UR_FUNCTION_LOADER_CONFIG_SET_CODE_LOCATION_CALLBACK: os << "UR_FUNCTION_LOADER_CONFIG_SET_CODE_LOCATION_CALLBACK"; break; @@ -11164,32 +11155,6 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct /// std::ostream & inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_program_build_params_t *params) { - os << ".hContext = "; - - ur::details::printPtr(os, - *(params->phContext)); - - os << ", "; - os << ".hProgram = "; - - ur::details::printPtr(os, - *(params->phProgram)); - - os << ", "; - os << ".pOptions = "; - - ur::details::printPtr(os, - *(params->ppOptions)); - - return os; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_program_build_exp_params_t type -/// @returns -/// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_program_build_exp_params_t *params) { - os << ".hProgram = "; ur::details::printPtr(os, @@ -11227,32 +11192,6 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct /// std::ostream & inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_program_compile_params_t *params) { - os << ".hContext = "; - - ur::details::printPtr(os, - *(params->phContext)); - - os << ", "; - os << ".hProgram = "; - - ur::details::printPtr(os, - *(params->phProgram)); - - os << ", "; - os << ".pOptions = "; - - ur::details::printPtr(os, - *(params->ppOptions)); - - return os; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_program_compile_exp_params_t type -/// @returns -/// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_program_compile_exp_params_t *params) { - os << ".hProgram = "; ur::details::printPtr(os, @@ -11292,49 +11231,6 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct os << ".hContext = "; - ur::details::printPtr(os, - *(params->phContext)); - - os << ", "; - os << ".count = "; - - os << *(params->pcount); - - os << ", "; - os << ".phPrograms = {"; - for (size_t i = 0; *(params->pphPrograms) != NULL && i < *params->pcount; ++i) { - if (i != 0) { - os << ", "; - } - - ur::details::printPtr(os, - (*(params->pphPrograms))[i]); - } - os << "}"; - - os << ", "; - os << ".pOptions = "; - - ur::details::printPtr(os, - *(params->ppOptions)); - - os << ", "; - os << ".phProgram = "; - - ur::details::printPtr(os, - *(params->pphProgram)); - - return os; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Print operator for the ur_program_link_exp_params_t type -/// @returns -/// std::ostream & -inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_program_link_exp_params_t *params) { - - os << ".hContext = "; - ur::details::printPtr(os, *(params->phContext)); @@ -17698,21 +17594,12 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, ur_function_ case UR_FUNCTION_PROGRAM_BUILD: { os << (const struct ur_program_build_params_t *)params; } break; - case UR_FUNCTION_PROGRAM_BUILD_EXP: { - os << (const struct ur_program_build_exp_params_t *)params; - } break; case UR_FUNCTION_PROGRAM_COMPILE: { os << (const struct ur_program_compile_params_t *)params; } break; - case UR_FUNCTION_PROGRAM_COMPILE_EXP: { - os << (const struct ur_program_compile_exp_params_t *)params; - } break; case UR_FUNCTION_PROGRAM_LINK: { os << (const struct ur_program_link_params_t *)params; } break; - case UR_FUNCTION_PROGRAM_LINK_EXP: { - os << (const struct ur_program_link_exp_params_t *)params; - } break; case UR_FUNCTION_PROGRAM_RETAIN: { os << (const struct ur_program_retain_params_t *)params; } break; diff --git a/scripts/core/CUDA.rst b/scripts/core/CUDA.rst index 9771693113..3d29febcc8 100644 --- a/scripts/core/CUDA.rst +++ b/scripts/core/CUDA.rst @@ -102,7 +102,7 @@ Currently ``maxrregcount`` is the only supported argument. .. parsed-literal:: - ${x}ProgramBuild(ctx, program, "maxrregcount=128"); + ${x}ProgramBuild(program, numDevices, phDevices, "maxrregcount=128"); Using SASS Modules in UR diff --git a/scripts/core/EXP-MULTI-DEVICE-COMPILE.rst b/scripts/core/EXP-MULTI-DEVICE-COMPILE.rst deleted file mode 100644 index d4c2a6cb7a..0000000000 --- a/scripts/core/EXP-MULTI-DEVICE-COMPILE.rst +++ /dev/null @@ -1,64 +0,0 @@ -<% - OneApi=tags['$OneApi'] - x=tags['$x'] - X=x.upper() -%> - -.. _experimental-multi-device-compile: - -================================================================================ -Multi Device Compile -================================================================================ - -.. warning:: - - Experimental features: - - * May be replaced, updated, or removed at any time. - * Do not require maintaining API/ABI stability of their own additions over - time. - * Do not require conformance testing of their own additions. - - - -Motivation --------------------------------------------------------------------------------- - -Instead of relying on the list of devices used to create a context, provide -interfaces which instead take a list of devices. This more closely aligns with -PI and OpenCL. Introduced to workaround a regression. May be superseded in -future. - -API --------------------------------------------------------------------------------- - -Functions -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -* ${x}ProgramBuildExp -* ${x}ProgramCompileExp -* ${x}ProgramLinkExp - -Changelog --------------------------------------------------------------------------------- - -+-----------+------------------------+ -| Revision | Changes | -+===========+========================+ -| 1.0 | Initial Draft | -+-----------+------------------------+ - -Support --------------------------------------------------------------------------------- - -Adapters which support this experimental feature *must* return the valid string -defined in ``${X}_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP`` -as one of the options from ${x}DeviceGetInfo when querying for -${X}_DEVICE_INFO_EXTENSIONS. Conversely, before using any of the -functionality defined in this experimental feature the user *must* use the -device query to determine if the adapter supports this feature. - -Contributors --------------------------------------------------------------------------------- - -* Kenneth Benzie (Benie) `k.benzie@codeplay.com `_ diff --git a/scripts/core/PROG.rst b/scripts/core/PROG.rst index ea0445cb60..e11112cc83 100644 --- a/scripts/core/PROG.rst +++ b/scripts/core/PROG.rst @@ -211,7 +211,7 @@ before they can be used to create a kernel object. ${x}ProgramCreateWithIL(hContext, ILBin, ILBinSize, nullptr, &hProgram); // Build the program. - ${x}ProgramBuild(hContext, hProgram, nullptr); + ${x}ProgramBuild(hProgram, numDevices, phDevices, nullptr); The diagram below shows the possible paths to obtaining a program that can be used to create a kernel: diff --git a/scripts/core/exp-multi-device-compile.yml b/scripts/core/exp-multi-device-compile.yml deleted file mode 100644 index 8ccba8c623..0000000000 --- a/scripts/core/exp-multi-device-compile.yml +++ /dev/null @@ -1,126 +0,0 @@ -# -# Copyright (C) 2023 Intel Corporation -# -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -# See YaML.md for syntax definition -# ---- #-------------------------------------------------------------------------- -type: header -desc: "Intel $OneApi Unified Runtime Experimental APIs for multi-device compile" -ordinal: "99" - ---- #-------------------------------------------------------------------------- -type: macro -desc: | - The extension string which defines support for test - which is returned when querying device extensions. -name: $X_MULTI_DEVICE_COMPILE_EXTENSION_STRING_EXP -value: "\"$x_exp_multi_device_compile\"" - ---- #-------------------------------------------------------------------------- -type: function -desc: "Produces an executable program from one program, negates need for the linking step." -class: $xProgram -name: BuildExp -ordinal: "2" -decl: static -analogue: - - "**clBuildProgram**" -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 $X_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in `phDevices`." -params: - - type: $x_program_handle_t - name: hProgram - desc: "[in] Handle of the program to build." - - type: uint32_t - name: numDevices - desc: "[in] number of devices" - - type: $x_device_handle_t* - name: phDevices - desc: "[in][range(0, numDevices)] pointer to array of device handles" - - type: const char* - name: pOptions - desc: "[in][optional] pointer to build options null-terminated string." -returns: - - $X_RESULT_ERROR_INVALID_PROGRAM: - - "If `hProgram` isn't a valid program object." - - $X_RESULT_ERROR_PROGRAM_BUILD_FAILURE: - - "If an error occurred when building `hProgram`." - ---- #-------------------------------------------------------------------------- -type: function -desc: "Produces an executable program from one or more programs." -class: $xProgram -name: CompileExp -decl: static -ordinal: "3" -analogue: - - "**clCompileProgram**" -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 $X_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each device in `phDevices`." -params: - - type: $x_program_handle_t - name: hProgram - desc: "[in][out] handle of the program to compile." - - type: uint32_t - name: numDevices - desc: "[in] number of devices" - - type: $x_device_handle_t* - name: phDevices - desc: "[in][range(0, numDevices)] pointer to array of device handles" - - type: const char* - name: pOptions - desc: "[in][optional] pointer to build options null-terminated string." -returns: - - $X_RESULT_ERROR_INVALID_PROGRAM: - - "If `hProgram` isn't a valid program object." - - $X_RESULT_ERROR_PROGRAM_BUILD_FAILURE: - - "If an error occurred while compiling `hProgram`." - ---- #-------------------------------------------------------------------------- -type: function -desc: "Produces an executable program from one or more programs." -class: $xProgram -name: LinkExp -decl: static -ordinal: "4" -analogue: - - "**clLinkProgram**" -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 $X_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 $xProgramGetBuildInfo) to provide an error log for the linking failure." -params: - - type: $x_context_handle_t - name: hContext - desc: "[in] handle of the context instance." - - type: uint32_t - name: numDevices - desc: "[in] number of devices" - - type: $x_device_handle_t* - name: phDevices - desc: "[in][range(0, numDevices)] pointer to array of device handles" - - type: uint32_t - name: count - desc: "[in] number of program handles in `phPrograms`." - - type: const $x_program_handle_t* - name: phPrograms - desc: "[in][range(0, count)] pointer to array of program handles." - - type: const char* - name: pOptions - desc: "[in][optional] pointer to linker options null-terminated string." - - type: $x_program_handle_t* - name: phProgram - desc: "[out] pointer to handle of program object created." -returns: - - $X_RESULT_ERROR_INVALID_PROGRAM: - - "If one of the programs in `phPrograms` isn't a valid program object." - - $X_RESULT_ERROR_INVALID_SIZE: - - "`count == 0`" - - $X_RESULT_ERROR_PROGRAM_LINK_FAILURE: - - "If an error occurred while linking `phPrograms`." diff --git a/scripts/core/program.yml b/scripts/core/program.yml index b7da9d62e7..8374297d78 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -170,12 +170,15 @@ 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 $X_PROGRAM_BINARY_TYPE_EXECUTABLE type for each device in `hContext`." params: - - type: $x_context_handle_t - name: hContext - desc: "[in] handle of the context instance." - type: $x_program_handle_t name: hProgram desc: "[in] Handle of the program to build." + - type: uint32_t + name: numDevices + desc: "[in] length of `phDevices`" + - type: $x_device_handle_t* + name: phDevices + desc: "[in][range(0, numDevices)] pointer to array of device handles" - type: const char* name: pOptions desc: "[in][optional] pointer to build options null-terminated string." @@ -184,6 +187,8 @@ returns: - "If `hProgram` isn't a valid program object." - $X_RESULT_ERROR_PROGRAM_BUILD_FAILURE: - "If an error occurred when building `hProgram`." + - $X_RESULT_ERROR_INVALID_SIZE: + - "`numDevices == 0`" --- #-------------------------------------------------------------------------- type: function desc: "Produces an executable program from one or more programs." @@ -197,12 +202,15 @@ 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 $X_PROGRAM_BINARY_TYPE_COMPILED_OBJECT type for each device in `hContext`." params: - - type: $x_context_handle_t - name: hContext - desc: "[in] handle of the context instance." - type: $x_program_handle_t name: hProgram desc: "[in][out] handle of the program to compile." + - type: uint32_t + name: numDevices + desc: "[in] length of `phDevices`" + - type: $x_device_handle_t* + name: phDevices + desc: "[in][range(0, numDevices)] pointer to array of device handles" - type: const char* name: pOptions desc: "[in][optional] pointer to build options null-terminated string." @@ -211,6 +219,8 @@ returns: - "If `hProgram` isn't a valid program object." - $X_RESULT_ERROR_PROGRAM_BUILD_FAILURE: - "If an error occurred while compiling `hProgram`." + - $X_RESULT_ERROR_INVALID_SIZE: + - "`numDevices == 0`" --- #-------------------------------------------------------------------------- type: function desc: "Produces an executable program from one or more programs." @@ -228,6 +238,12 @@ params: - type: $x_context_handle_t name: hContext desc: "[in] handle of the context instance." + - type: uint32_t + name: numDevices + desc: "[in] number of devices" + - type: $x_device_handle_t* + name: phDevices + desc: "[in][range(0, numDevices)] pointer to array of device handles" - type: uint32_t name: count desc: "[in] number of program handles in `phPrograms`." @@ -244,6 +260,7 @@ returns: - $X_RESULT_ERROR_INVALID_PROGRAM: - "If one of the programs in `phPrograms` isn't a valid program object." - $X_RESULT_ERROR_INVALID_SIZE: + - "`numDevices == 0`" - "`count == 0`" - $X_RESULT_ERROR_PROGRAM_LINK_FAILURE: - "If an error occurred while linking `phPrograms`." diff --git a/scripts/core/registry.yml b/scripts/core/registry.yml index ab59404bb4..2b0fe7d8be 100644 --- a/scripts/core/registry.yml +++ b/scripts/core/registry.yml @@ -493,15 +493,6 @@ etors: - name: ADAPTER_GET_INFO desc: Enumerator for $xAdapterGetInfo value: '181' -- name: PROGRAM_BUILD_EXP - desc: Enumerator for $xProgramBuildExp - value: '197' -- name: PROGRAM_COMPILE_EXP - desc: Enumerator for $xProgramCompileExp - value: '198' -- name: PROGRAM_LINK_EXP - desc: Enumerator for $xProgramLinkExp - value: '199' - name: LOADER_CONFIG_SET_CODE_LOCATION_CALLBACK desc: Enumerator for $xLoaderConfigSetCodeLocationCallback value: '200' diff --git a/source/adapters/adapter.def.in b/source/adapters/adapter.def.in index 3c18c78bd1..69706127f5 100644 --- a/source/adapters/adapter.def.in +++ b/source/adapters/adapter.def.in @@ -13,7 +13,6 @@ EXPORTS urGetPhysicalMemProcAddrTable urGetPlatformProcAddrTable urGetProgramProcAddrTable - urGetProgramExpProcAddrTable urGetQueueProcAddrTable urGetSamplerProcAddrTable urGetUSMProcAddrTable diff --git a/source/adapters/adapter.map.in b/source/adapters/adapter.map.in index bb08ae7d88..902c0aec69 100644 --- a/source/adapters/adapter.map.in +++ b/source/adapters/adapter.map.in @@ -13,7 +13,6 @@ urGetPhysicalMemProcAddrTable; urGetPlatformProcAddrTable; urGetProgramProcAddrTable; - urGetProgramExpProcAddrTable; urGetQueueProcAddrTable; urGetSamplerProcAddrTable; urGetUSMProcAddrTable; diff --git a/source/adapters/cuda/program.cpp b/source/adapters/cuda/program.cpp index 9b14a0a4eb..ad58010016 100644 --- a/source/adapters/cuda/program.cpp +++ b/source/adapters/cuda/program.cpp @@ -233,35 +233,20 @@ urProgramCreateWithIL(ur_context_handle_t, const void *, size_t, /// cuModuleLoadDataEx. So, urProgramCompile and urProgramBuild are equivalent /// in terms of CUDA adapter. \TODO Implement asynchronous compilation UR_APIEXPORT ur_result_t UR_APICALL -urProgramCompile(ur_context_handle_t hContext, ur_program_handle_t hProgram, - const char *pOptions) { - UR_CHECK_ERROR(urProgramBuild(hContext, hProgram, pOptions)); +urProgramCompile(ur_program_handle_t hProgram, uint32_t numDevices, + ur_device_handle_t *phDevices, const char *pOptions) { + UR_CHECK_ERROR(urProgramBuild(hProgram, numDevices, phDevices, pOptions)); hProgram->BinaryType = UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT; return UR_RESULT_SUCCESS; } -UR_APIEXPORT ur_result_t UR_APICALL urProgramCompileExp(ur_program_handle_t, - uint32_t, - ur_device_handle_t *, - const char *) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp(ur_program_handle_t, - uint32_t, - ur_device_handle_t *, - const char *) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - /// Loads the images from a UR program into a CUmodule that can be /// used later on to extract functions (kernels). /// See \ref ur_program_handle_t for implementation details. -UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_context_handle_t hContext, - ur_program_handle_t hProgram, +UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_program_handle_t hProgram, + uint32_t, + ur_device_handle_t *, const char *pOptions) { - std::ignore = hContext; - ur_result_t Result = UR_RESULT_SUCCESS; try { @@ -276,22 +261,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_context_handle_t hContext, return Result; } -UR_APIEXPORT ur_result_t UR_APICALL urProgramLinkExp( - ur_context_handle_t, uint32_t, ur_device_handle_t *, uint32_t, - const ur_program_handle_t *, const char *, ur_program_handle_t *phProgram) { - if (nullptr != phProgram) { - *phProgram = nullptr; - } - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - /// Creates a new UR program object that is the outcome of linking all input /// programs. /// \TODO Implement linker options, requires mapping of OpenCL to CUDA UR_APIEXPORT ur_result_t UR_APICALL -urProgramLink(ur_context_handle_t hContext, uint32_t count, - const ur_program_handle_t *phPrograms, const char *pOptions, - ur_program_handle_t *phProgram) { +urProgramLink(ur_context_handle_t hContext, uint32_t, ur_device_handle_t *, + uint32_t count, const ur_program_handle_t *phPrograms, + const char *pOptions, ur_program_handle_t *phProgram) { ur_result_t Result = UR_RESULT_SUCCESS; if (nullptr != phProgram) { *phProgram = nullptr; diff --git a/source/adapters/cuda/ur_interface_loader.cpp b/source/adapters/cuda/ur_interface_loader.cpp index bb3fb9aee5..18ce8fd84b 100644 --- a/source/adapters/cuda/ur_interface_loader.cpp +++ b/source/adapters/cuda/ur_interface_loader.cpp @@ -431,21 +431,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelExpProcAddrTable( return UR_RESULT_SUCCESS; } - -UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( - ur_api_version_t version, ur_program_exp_dditable_t *pDdiTable) { - auto result = validateProcInputs(version, pDdiTable); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - pDdiTable->pfnBuildExp = urProgramBuildExp; - pDdiTable->pfnCompileExp = urProgramCompileExp; - pDdiTable->pfnLinkExp = urProgramLinkExp; - - return UR_RESULT_SUCCESS; -} - #if defined(__cplusplus) } // extern "C" #endif diff --git a/source/adapters/hip/program.cpp b/source/adapters/hip/program.cpp index 7f22a9d610..e2e8b5a9f5 100644 --- a/source/adapters/hip/program.cpp +++ b/source/adapters/hip/program.cpp @@ -281,34 +281,17 @@ urProgramCreateWithIL(ur_context_handle_t, const void *, size_t, /// hipModuleLoadDataEx. So, urProgramCompile and urProgramBuild are equivalent /// in terms of HIP adapter. \TODO Implement asynchronous compilation UR_APIEXPORT ur_result_t UR_APICALL -urProgramCompile(ur_context_handle_t hContext, ur_program_handle_t hProgram, - const char *pOptions) { - UR_CHECK_ERROR(urProgramBuild(hContext, hProgram, pOptions)); - // urProgramBuild sets the BinaryType to UR_PROGRAM_BINARY_TYPE_EXECUTABLE, so - // set it to the correct value for urProgramCompile post-hoc. - hProgram->BinaryType = UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT; - return UR_RESULT_SUCCESS; -} - -UR_APIEXPORT ur_result_t UR_APICALL urProgramCompileExp(ur_program_handle_t, - uint32_t, - ur_device_handle_t *, - const char *) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp(ur_program_handle_t, - uint32_t, - ur_device_handle_t *, - const char *) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +urProgramCompile(ur_program_handle_t hProgram, uint32_t numDevices, + ur_device_handle_t *phDevices, const char *pOptions) { + return urProgramBuild(hProgram, numDevices, phDevices, pOptions); } /// Loads the images from a UR program into a hipModule_t that can be /// used later on to extract functions (kernels). /// See \ref ur_program_handle_t for implementation details. -UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_context_handle_t, - ur_program_handle_t hProgram, +UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_program_handle_t hProgram, + uint32_t, + ur_device_handle_t *, const char *pOptions) { ur_result_t Result = UR_RESULT_SUCCESS; @@ -324,7 +307,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_context_handle_t, return Result; } -UR_APIEXPORT ur_result_t UR_APICALL urProgramLinkExp( +UR_APIEXPORT ur_result_t UR_APICALL urProgramLink( ur_context_handle_t, uint32_t, ur_device_handle_t *, uint32_t, const ur_program_handle_t *, const char *, ur_program_handle_t *phProgram) { if (nullptr != phProgram) { @@ -333,15 +316,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramLinkExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } -UR_APIEXPORT ur_result_t UR_APICALL -urProgramLink(ur_context_handle_t, uint32_t, const ur_program_handle_t *, - const char *, ur_program_handle_t *phProgram) { - if (nullptr != phProgram) { - *phProgram = nullptr; - } - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - /// Created a UR program object from a HIP program handle. /// TODO: Implement this. /// NOTE: The created UR object takes ownership of the native handle. diff --git a/source/adapters/hip/ur_interface_loader.cpp b/source/adapters/hip/ur_interface_loader.cpp index af9b8fa9c3..fef13c60aa 100644 --- a/source/adapters/hip/ur_interface_loader.cpp +++ b/source/adapters/hip/ur_interface_loader.cpp @@ -396,21 +396,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelExpProcAddrTable( return UR_RESULT_SUCCESS; } - -UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( - ur_api_version_t version, ur_program_exp_dditable_t *pDdiTable) { - auto result = validateProcInputs(version, pDdiTable); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - pDdiTable->pfnBuildExp = urProgramBuildExp; - pDdiTable->pfnCompileExp = urProgramCompileExp; - pDdiTable->pfnLinkExp = urProgramLinkExp; - - return UR_RESULT_SUCCESS; -} - #if defined(__cplusplus) } // extern "C" #endif diff --git a/source/adapters/level_zero/program.cpp b/source/adapters/level_zero/program.cpp index 02aef2d058..a3ff417616 100644 --- a/source/adapters/level_zero/program.cpp +++ b/source/adapters/level_zero/program.cpp @@ -119,17 +119,6 @@ ur_result_t urProgramCreateWithBinary( } ur_result_t urProgramBuild( - ur_context_handle_t Context, ///< [in] handle of the context instance. - ur_program_handle_t Program, ///< [in] Handle of the program to build. - const char *Options ///< [in][optional] pointer to build options - ///< null-terminated string. -) { - std::vector Devices = Context->getDevices(); - return ur::level_zero::urProgramBuildExp(Program, Devices.size(), - Devices.data(), Options); -} - -ur_result_t 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 @@ -232,7 +221,7 @@ ur_result_t urProgramBuildExp( return Result; } -ur_result_t urProgramCompileExp( +ur_result_t urProgramCompile( ur_program_handle_t hProgram, ///< [in][out] handle of the program to compile. uint32_t numDevices, ///< [in] number of devices @@ -243,26 +232,14 @@ ur_result_t urProgramCompileExp( ) { std::ignore = numDevices; std::ignore = phDevices; - return ur::level_zero::urProgramCompile(hProgram->Context, hProgram, - pOptions); -} - -ur_result_t urProgramCompile( - ur_context_handle_t Context, ///< [in] handle of the context instance. - ur_program_handle_t - Program, ///< [in][out] handle of the program to compile. - const char *Options ///< [in][optional] pointer to build options - ///< null-terminated string. -) { - std::ignore = Context; - std::scoped_lock Guard(Program->Mutex); + std::scoped_lock Guard(hProgram->Mutex); // It's only valid to compile a program created from IL (we don't support // programs created from source code). // // The OpenCL spec says that the header parameters are ignored when compiling // IL programs, so we don't validate them. - if (Program->State != ur_program_handle_t_::IL) + if (hProgram->State != ur_program_handle_t_::IL) return UR_RESULT_ERROR_INVALID_OPERATION; // We don't compile anything now. Instead, we delay compilation until @@ -270,39 +247,22 @@ ur_result_t urProgramCompile( // This produces better code because the driver can do cross-module // optimizations. Therefore, we just remember the compilation flags, so we // can use them later. - if (Options) { - Program->BuildFlags = Options; + if (pOptions) { + hProgram->BuildFlags = pOptions; // if large allocations are selected, then pass // ze-opt-greater-than-4GB-buffer-required to disable // stateful optimizations and be able to use larger than // 4GB allocations on these kernels. - if (Context->getDevices()[0]->useRelaxedAllocationLimits()) { - Program->BuildFlags += " -ze-opt-greater-than-4GB-buffer-required"; + if (phDevices[0]->useRelaxedAllocationLimits()) { + hProgram->BuildFlags += " -ze-opt-greater-than-4GB-buffer-required"; } } - Program->State = ur_program_handle_t_::Object; - + hProgram->State = ur_program_handle_t_::Object; return UR_RESULT_SUCCESS; } ur_result_t urProgramLink( - ur_context_handle_t Context, ///< [in] handle of the context instance. - uint32_t Count, ///< [in] number of program handles in `phPrograms`. - const ur_program_handle_t *Programs, ///< [in][range(0, count)] pointer to - ///< array of program handles. - const char *Options, ///< [in][optional] pointer to linker options - ///< null-terminated string. - ur_program_handle_t - *Program ///< [out] pointer to handle of program object created. -) { - std::vector Devices = Context->getDevices(); - return ur::level_zero::urProgramLinkExp(Context, Devices.size(), - Devices.data(), Count, Programs, - Options, Program); -} - -ur_result_t 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 diff --git a/source/adapters/level_zero/ur_interface_loader.cpp b/source/adapters/level_zero/ur_interface_loader.cpp index 9bdd672818..b12af04190 100644 --- a/source/adapters/level_zero/ur_interface_loader.cpp +++ b/source/adapters/level_zero/ur_interface_loader.cpp @@ -365,20 +365,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetProgramProcAddrTable( return result; } -UR_APIEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( - ur_api_version_t version, ur_program_exp_dditable_t *pDdiTable) { - auto result = validateProcInputs(version, pDdiTable); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - pDdiTable->pfnBuildExp = ur::level_zero::urProgramBuildExp; - pDdiTable->pfnCompileExp = ur::level_zero::urProgramCompileExp; - pDdiTable->pfnLinkExp = ur::level_zero::urProgramLinkExp; - - return result; -} - UR_APIEXPORT ur_result_t UR_APICALL urGetQueueProcAddrTable( ur_api_version_t version, ur_queue_dditable_t *pDdiTable) { auto result = validateProcInputs(version, pDdiTable); @@ -576,10 +562,6 @@ ur_result_t urAdapterGetDdiTables(ur_dditable_t *ddi) { &ddi->Program); if (result != UR_RESULT_SUCCESS) return result; - result = ur::level_zero::urGetProgramExpProcAddrTable(UR_API_VERSION_CURRENT, - &ddi->ProgramExp); - if (result != UR_RESULT_SUCCESS) - return result; result = ur::level_zero::urGetQueueProcAddrTable(UR_API_VERSION_CURRENT, &ddi->Queue); if (result != UR_RESULT_SUCCESS) diff --git a/source/adapters/level_zero/ur_interface_loader.hpp b/source/adapters/level_zero/ur_interface_loader.hpp index 2b163f6749..19940b826e 100644 --- a/source/adapters/level_zero/ur_interface_loader.hpp +++ b/source/adapters/level_zero/ur_interface_loader.hpp @@ -190,12 +190,13 @@ ur_result_t urProgramCreateWithBinary( ur_context_handle_t hContext, ur_device_handle_t hDevice, size_t size, const uint8_t *pBinary, const ur_program_properties_t *pProperties, ur_program_handle_t *phProgram); -ur_result_t urProgramBuild(ur_context_handle_t hContext, - ur_program_handle_t hProgram, const char *pOptions); -ur_result_t urProgramCompile(ur_context_handle_t hContext, - ur_program_handle_t hProgram, +ur_result_t urProgramBuild(ur_program_handle_t hProgram, uint32_t numDevices, + ur_device_handle_t *phDevices, const char *pOptions); +ur_result_t urProgramCompile(ur_program_handle_t hProgram, uint32_t numDevices, + ur_device_handle_t *phDevices, const char *pOptions); -ur_result_t urProgramLink(ur_context_handle_t hContext, uint32_t count, +ur_result_t urProgramLink(ur_context_handle_t hContext, uint32_t numDevices, + ur_device_handle_t *phDevices, uint32_t count, const ur_program_handle_t *phPrograms, const char *pOptions, ur_program_handle_t *phProgram); ur_result_t urProgramRetain(ur_program_handle_t hProgram); @@ -670,18 +671,6 @@ ur_result_t urEnqueueKernelLaunchCustomExp( const ur_exp_launch_property_t *launchPropList, uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent); -ur_result_t urProgramBuildExp(ur_program_handle_t hProgram, uint32_t numDevices, - ur_device_handle_t *phDevices, - const char *pOptions); -ur_result_t urProgramCompileExp(ur_program_handle_t hProgram, - uint32_t numDevices, - ur_device_handle_t *phDevices, - const char *pOptions); -ur_result_t urProgramLinkExp(ur_context_handle_t hContext, uint32_t numDevices, - ur_device_handle_t *phDevices, uint32_t count, - const ur_program_handle_t *phPrograms, - const char *pOptions, - ur_program_handle_t *phProgram); ur_result_t urUSMImportExp(ur_context_handle_t hContext, void *pMem, size_t size); ur_result_t urUSMReleaseExp(ur_context_handle_t hContext, void *pMem); diff --git a/source/adapters/mock/ur_mockddi.cpp b/source/adapters/mock/ur_mockddi.cpp index 7c38f5dd1c..dd522805e1 100644 --- a/source/adapters/mock/ur_mockddi.cpp +++ b/source/adapters/mock/ur_mockddi.cpp @@ -3208,14 +3208,17 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urProgramBuild __urdlllocal 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. + 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. ) try { ur_result_t result = UR_RESULT_SUCCESS; - ur_program_build_params_t params = {&hContext, &hProgram, &pOptions}; + ur_program_build_params_t params = {&hProgram, &numDevices, &phDevices, + &pOptions}; auto beforeCallback = reinterpret_cast( mock::getCallbacks().get_before_callback("urProgramBuild")); @@ -3253,15 +3256,18 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urProgramCompile __urdlllocal 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. + 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. ) try { ur_result_t result = UR_RESULT_SUCCESS; - ur_program_compile_params_t params = {&hContext, &hProgram, &pOptions}; + ur_program_compile_params_t params = {&hProgram, &numDevices, &phDevices, + &pOptions}; auto beforeCallback = reinterpret_cast( mock::getCallbacks().get_before_callback("urProgramCompile")); @@ -3300,6 +3306,9 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( /// @brief Intercept function for urProgramLink __urdlllocal 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. @@ -3313,8 +3322,9 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( *phProgram = nullptr; } - ur_program_link_params_t params = {&hContext, &count, &phPrograms, - &pOptions, &phProgram}; + ur_program_link_params_t params = {&hContext, &numDevices, &phDevices, + &count, &phPrograms, &pOptions, + &phProgram}; auto beforeCallback = reinterpret_cast( mock::getCallbacks().get_before_callback("urProgramLink")); @@ -9771,161 +9781,6 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( return exceptionToResult(std::current_exception()); } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramBuildExp -__urdlllocal 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. - ) try { - ur_result_t result = UR_RESULT_SUCCESS; - - ur_program_build_exp_params_t params = {&hProgram, &numDevices, &phDevices, - &pOptions}; - - auto beforeCallback = reinterpret_cast( - mock::getCallbacks().get_before_callback("urProgramBuildExp")); - if (beforeCallback) { - result = beforeCallback(¶ms); - if (result != UR_RESULT_SUCCESS) { - return result; - } - } - - auto replaceCallback = reinterpret_cast( - mock::getCallbacks().get_replace_callback("urProgramBuildExp")); - if (replaceCallback) { - result = replaceCallback(¶ms); - } else { - - result = UR_RESULT_SUCCESS; - } - - if (result != UR_RESULT_SUCCESS) { - return result; - } - - auto afterCallback = reinterpret_cast( - mock::getCallbacks().get_after_callback("urProgramBuildExp")); - if (afterCallback) { - return afterCallback(¶ms); - } - - return result; -} catch (...) { - return exceptionToResult(std::current_exception()); -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramCompileExp -__urdlllocal 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. - ) try { - ur_result_t result = UR_RESULT_SUCCESS; - - ur_program_compile_exp_params_t params = {&hProgram, &numDevices, - &phDevices, &pOptions}; - - auto beforeCallback = reinterpret_cast( - mock::getCallbacks().get_before_callback("urProgramCompileExp")); - if (beforeCallback) { - result = beforeCallback(¶ms); - if (result != UR_RESULT_SUCCESS) { - return result; - } - } - - auto replaceCallback = reinterpret_cast( - mock::getCallbacks().get_replace_callback("urProgramCompileExp")); - if (replaceCallback) { - result = replaceCallback(¶ms); - } else { - - result = UR_RESULT_SUCCESS; - } - - if (result != UR_RESULT_SUCCESS) { - return result; - } - - auto afterCallback = reinterpret_cast( - mock::getCallbacks().get_after_callback("urProgramCompileExp")); - if (afterCallback) { - return afterCallback(¶ms); - } - - return result; -} catch (...) { - return exceptionToResult(std::current_exception()); -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramLinkExp -__urdlllocal 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. - ) try { - ur_result_t result = UR_RESULT_SUCCESS; - if (nullptr != phProgram) { - *phProgram = nullptr; - } - - ur_program_link_exp_params_t params = {&hContext, &numDevices, &phDevices, - &count, &phPrograms, &pOptions, - &phProgram}; - - auto beforeCallback = reinterpret_cast( - mock::getCallbacks().get_before_callback("urProgramLinkExp")); - if (beforeCallback) { - result = beforeCallback(¶ms); - if (result != UR_RESULT_SUCCESS) { - return result; - } - } - - auto replaceCallback = reinterpret_cast( - mock::getCallbacks().get_replace_callback("urProgramLinkExp")); - if (replaceCallback) { - result = replaceCallback(¶ms); - } else { - - *phProgram = mock::createDummyHandle(); - result = UR_RESULT_SUCCESS; - } - - if (result != UR_RESULT_SUCCESS) { - return result; - } - - auto afterCallback = reinterpret_cast( - mock::getCallbacks().get_after_callback("urProgramLinkExp")); - if (afterCallback) { - return afterCallback(¶ms); - } - - return result; -} catch (...) { - return exceptionToResult(std::current_exception()); -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urUSMImportExp __urdlllocal ur_result_t UR_APICALL urUSMImportExp( @@ -10932,40 +10787,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramProcAddrTable( return exceptionToResult(std::current_exception()); } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Exported function for filling application's ProgramExp table -/// with current process' addresses -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION -UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( - ur_api_version_t version, ///< [in] API version requested - ur_program_exp_dditable_t - *pDdiTable ///< [in,out] pointer to table of DDI function pointers - ) try { - if (nullptr == pDdiTable) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - - if (driver::d_context.version < version) { - return UR_RESULT_ERROR_UNSUPPORTED_VERSION; - } - - ur_result_t result = UR_RESULT_SUCCESS; - - pDdiTable->pfnBuildExp = driver::urProgramBuildExp; - - pDdiTable->pfnCompileExp = driver::urProgramCompileExp; - - pDdiTable->pfnLinkExp = driver::urProgramLinkExp; - - return result; -} catch (...) { - return exceptionToResult(std::current_exception()); -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Queue table /// with current process' addresses diff --git a/source/adapters/native_cpu/program.cpp b/source/adapters/native_cpu/program.cpp index 460660e2cd..566a6cebe2 100644 --- a/source/adapters/native_cpu/program.cpp +++ b/source/adapters/native_cpu/program.cpp @@ -106,10 +106,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary( return UR_RESULT_SUCCESS; } -UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_context_handle_t hContext, - ur_program_handle_t hProgram, - const char *pOptions) { - std::ignore = hContext; +UR_APIEXPORT ur_result_t UR_APICALL +urProgramBuild(ur_program_handle_t hProgram, uint32_t numDevices, + ur_device_handle_t *phDevices, const char *pOptions) { + std::ignore = numDevices; + std::ignore = phDevices; std::ignore = hProgram; std::ignore = pOptions; @@ -117,9 +118,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_context_handle_t hContext, } UR_APIEXPORT ur_result_t UR_APICALL -urProgramCompile(ur_context_handle_t hContext, ur_program_handle_t hProgram, - const char *pOptions) { - std::ignore = hContext; +urProgramCompile(ur_program_handle_t hProgram, uint32_t numDevices, + ur_device_handle_t *phDevices, const char *pOptions) { + std::ignore = numDevices; + std::ignore = phDevices; std::ignore = hProgram; std::ignore = pOptions; @@ -127,13 +129,16 @@ urProgramCompile(ur_context_handle_t hContext, ur_program_handle_t hProgram, } UR_APIEXPORT ur_result_t UR_APICALL -urProgramLink(ur_context_handle_t hContext, uint32_t count, +urProgramLink(ur_context_handle_t hContext, uint32_t numDevices, + ur_device_handle_t *phDevices, uint32_t count, const ur_program_handle_t *phPrograms, const char *pOptions, ur_program_handle_t *phProgram) { if (nullptr != phProgram) { *phProgram = nullptr; } std::ignore = hContext; + std::ignore = numDevices; + std::ignore = phDevices; std::ignore = count; std::ignore = phPrograms; std::ignore = pOptions; @@ -141,29 +146,6 @@ urProgramLink(ur_context_handle_t hContext, uint32_t count, DIE_NO_IMPLEMENTATION } -UR_APIEXPORT ur_result_t UR_APICALL urProgramCompileExp(ur_program_handle_t, - uint32_t, - ur_device_handle_t *, - const char *) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp(ur_program_handle_t, - uint32_t, - ur_device_handle_t *, - const char *) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -UR_APIEXPORT ur_result_t UR_APICALL urProgramLinkExp( - ur_context_handle_t, uint32_t, ur_device_handle_t *, uint32_t, - const ur_program_handle_t *, const char *, ur_program_handle_t *phProgram) { - if (nullptr != phProgram) { - *phProgram = nullptr; - } - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - UR_APIEXPORT ur_result_t UR_APICALL urProgramRetain(ur_program_handle_t hProgram) { hProgram->incrementReferenceCount(); diff --git a/source/adapters/native_cpu/ur_interface_loader.cpp b/source/adapters/native_cpu/ur_interface_loader.cpp index ff6c9d8c0f..e0682065d5 100644 --- a/source/adapters/native_cpu/ur_interface_loader.cpp +++ b/source/adapters/native_cpu/ur_interface_loader.cpp @@ -414,18 +414,4 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelExpProcAddrTable( return UR_RESULT_SUCCESS; } - -UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( - ur_api_version_t version, ur_program_exp_dditable_t *pDdiTable) { - auto result = validateProcInputs(version, pDdiTable); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - pDdiTable->pfnBuildExp = urProgramBuildExp; - pDdiTable->pfnCompileExp = urProgramCompileExp; - pDdiTable->pfnLinkExp = urProgramLinkExp; - - return UR_RESULT_SUCCESS; -} } // extern "C" diff --git a/source/adapters/opencl/program.cpp b/source/adapters/opencl/program.cpp index d843495b7e..e093f65c43 100644 --- a/source/adapters/opencl/program.cpp +++ b/source/adapters/opencl/program.cpp @@ -13,28 +13,6 @@ #include "device.hpp" #include "platform.hpp" -static ur_result_t getDevicesFromProgram( - ur_program_handle_t hProgram, - std::unique_ptr> &DevicesInProgram) { - - cl_uint DeviceCount; - CL_RETURN_ON_FAILURE(clGetProgramInfo(cl_adapter::cast(hProgram), - CL_PROGRAM_NUM_DEVICES, sizeof(cl_uint), - &DeviceCount, nullptr)); - - if (DeviceCount < 1) { - return UR_RESULT_ERROR_INVALID_CONTEXT; - } - - DevicesInProgram = std::make_unique>(DeviceCount); - - CL_RETURN_ON_FAILURE(clGetProgramInfo( - cl_adapter::cast(hProgram), CL_PROGRAM_DEVICES, - DeviceCount * sizeof(cl_device_id), (*DevicesInProgram).data(), nullptr)); - - return UR_RESULT_SUCCESS; -} - UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithIL( ur_context_handle_t hContext, const void *pIL, size_t length, const ur_program_properties_t *, ur_program_handle_t *phProgram) { @@ -119,7 +97,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary( ur_context_handle_t hContext, ur_device_handle_t hDevice, size_t size, const uint8_t *pBinary, const ur_program_properties_t *, ur_program_handle_t *phProgram) { - const cl_device_id Devices[1] = {cl_adapter::cast(hDevice)}; const size_t Lengths[1] = {size}; cl_int BinaryStatus[1]; @@ -134,16 +111,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary( } UR_APIEXPORT ur_result_t UR_APICALL -urProgramCompile([[maybe_unused]] ur_context_handle_t hContext, - ur_program_handle_t hProgram, const char *pOptions) { - - std::unique_ptr> DevicesInProgram; - UR_RETURN_ON_FAILURE(getDevicesFromProgram(hProgram, DevicesInProgram)); - +urProgramCompile(ur_program_handle_t hProgram, uint32_t numDevices, + ur_device_handle_t *phDevices, const char *pOptions) { + std::vector ClDevices; + for (uint32_t DeviceIndex = 0; DeviceIndex < numDevices; DeviceIndex++) { + ClDevices.push_back(cl_adapter::cast(phDevices[DeviceIndex])); + } CL_RETURN_ON_FAILURE(clCompileProgram(cl_adapter::cast(hProgram), - DevicesInProgram->size(), - DevicesInProgram->data(), pOptions, 0, - nullptr, nullptr, nullptr, nullptr)); + numDevices, ClDevices.data(), pOptions, + 0, nullptr, nullptr, nullptr, nullptr)); return UR_RESULT_SUCCESS; } @@ -192,29 +168,33 @@ urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName, } UR_APIEXPORT ur_result_t UR_APICALL -urProgramBuild([[maybe_unused]] ur_context_handle_t hContext, - ur_program_handle_t hProgram, const char *pOptions) { - - std::unique_ptr> DevicesInProgram; - UR_RETURN_ON_FAILURE(getDevicesFromProgram(hProgram, DevicesInProgram)); - - CL_RETURN_ON_FAILURE(clBuildProgram( - cl_adapter::cast(hProgram), DevicesInProgram->size(), - DevicesInProgram->data(), pOptions, nullptr, nullptr)); +urProgramBuild(ur_program_handle_t hProgram, uint32_t numDevices, + ur_device_handle_t *phDevices, const char *pOptions) { + std::vector ClDevices; + for (uint32_t DeviceIndex = 0; DeviceIndex < numDevices; DeviceIndex++) { + ClDevices.push_back(cl_adapter::cast(phDevices[DeviceIndex])); + } + CL_RETURN_ON_FAILURE(clBuildProgram(cl_adapter::cast(hProgram), + numDevices, ClDevices.data(), pOptions, + nullptr, nullptr)); return UR_RESULT_SUCCESS; } UR_APIEXPORT ur_result_t UR_APICALL -urProgramLink(ur_context_handle_t hContext, uint32_t count, +urProgramLink(ur_context_handle_t hContext, uint32_t numDevices, + ur_device_handle_t *phDevices, uint32_t count, const ur_program_handle_t *phPrograms, const char *pOptions, ur_program_handle_t *phProgram) { - + std::vector ClDevices; + for (uint32_t DeviceIndex = 0; DeviceIndex < numDevices; DeviceIndex++) { + ClDevices.push_back(cl_adapter::cast(phDevices[DeviceIndex])); + } cl_int CLResult; - *phProgram = cl_adapter::cast( - clLinkProgram(cl_adapter::cast(hContext), 0, nullptr, - pOptions, cl_adapter::cast(count), - cl_adapter::cast(phPrograms), nullptr, - nullptr, &CLResult)); + *phProgram = cl_adapter::cast(clLinkProgram( + cl_adapter::cast(hContext), numDevices, ClDevices.data(), + pOptions, cl_adapter::cast(count), + cl_adapter::cast(phPrograms), nullptr, nullptr, + &CLResult)); if (CL_INVALID_BINARY == CLResult) { // Some OpenCL drivers incorrectly return CL_INVALID_BINARY here, convert it @@ -227,29 +207,6 @@ urProgramLink(ur_context_handle_t hContext, uint32_t count, return UR_RESULT_SUCCESS; } -UR_APIEXPORT ur_result_t UR_APICALL urProgramCompileExp(ur_program_handle_t, - uint32_t, - ur_device_handle_t *, - const char *) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp(ur_program_handle_t, - uint32_t, - ur_device_handle_t *, - const char *) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -UR_APIEXPORT ur_result_t UR_APICALL urProgramLinkExp( - ur_context_handle_t, uint32_t, ur_device_handle_t *, uint32_t, - const ur_program_handle_t *, const char *, ur_program_handle_t *phProgram) { - if (nullptr != phProgram) { - *phProgram = nullptr; - } - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - static cl_int mapURProgramBuildInfoToCL(ur_program_build_info_t URPropName) { switch (static_cast(URPropName)) { diff --git a/source/adapters/opencl/ur_interface_loader.cpp b/source/adapters/opencl/ur_interface_loader.cpp index 100bb888cf..f1c07a9fe4 100644 --- a/source/adapters/opencl/ur_interface_loader.cpp +++ b/source/adapters/opencl/ur_interface_loader.cpp @@ -421,20 +421,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelExpProcAddrTable( return UR_RESULT_SUCCESS; } - -UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( - ur_api_version_t version, ur_program_exp_dditable_t *pDdiTable) { - auto result = validateProcInputs(version, pDdiTable); - if (UR_RESULT_SUCCESS != result) { - return result; - } - - pDdiTable->pfnBuildExp = urProgramBuildExp; - pDdiTable->pfnCompileExp = urProgramCompileExp; - pDdiTable->pfnLinkExp = urProgramLinkExp; - - return UR_RESULT_SUCCESS; -} #if defined(__cplusplus) } // extern "C" #endif diff --git a/source/loader/layers/sanitizer/ur_sanddi.cpp b/source/loader/layers/sanitizer/ur_sanddi.cpp index 39ea834164..b6e38875af 100644 --- a/source/loader/layers/sanitizer/ur_sanddi.cpp +++ b/source/loader/layers/sanitizer/ur_sanddi.cpp @@ -178,9 +178,11 @@ __urdlllocal ur_result_t UR_APICALL urUSMFree( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urProgramBuild __urdlllocal ur_result_t UR_APICALL urProgramBuild( - ur_context_handle_t hContext, ///< [in] handle of the context object ur_program_handle_t hProgram, ///< [in] handle of the program object - const char *pOptions ///< [in] string of build options + 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] string of build options ) { auto pfnProgramBuild = getContext()->urDdiTable.Program.pfnBuild; @@ -190,33 +192,8 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( getContext()->logger.debug("==== urProgramBuild"); - UR_CALL(pfnProgramBuild(hContext, hProgram, pOptions)); - - UR_CALL( - getContext()->interceptor->registerDeviceGlobals(hContext, hProgram)); - - return UR_RESULT_SUCCESS; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramBuildExp -__urdlllocal 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. -) { - auto pfnBuildExp = getContext()->urDdiTable.ProgramExp.pfnBuildExp; - - if (nullptr == pfnBuildExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - getContext()->logger.debug("==== urProgramBuildExp"); + UR_CALL(pfnProgramBuild(hProgram, numDevices, phDevices, pOptions)); - UR_CALL(pfnBuildExp(hProgram, numDevices, phDevices, pOptions)); UR_CALL(getContext()->interceptor->registerDeviceGlobals( GetContext(hProgram), hProgram)); @@ -225,35 +202,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuildExp( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urProgramLink -__urdlllocal ur_result_t UR_APICALL urProgramLink( - ur_context_handle_t hContext, ///< [in] handle of the context instance. - 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. -) { - auto pfnProgramLink = getContext()->urDdiTable.Program.pfnLink; - - if (nullptr == pfnProgramLink) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - getContext()->logger.debug("==== urProgramLink"); - - UR_CALL(pfnProgramLink(hContext, count, phPrograms, pOptions, phProgram)); - - UR_CALL( - getContext()->interceptor->registerDeviceGlobals(hContext, *phProgram)); - - return UR_RESULT_SUCCESS; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramLinkExp -ur_result_t UR_APICALL urProgramLinkExp( +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 * @@ -266,16 +215,16 @@ ur_result_t UR_APICALL urProgramLinkExp( ur_program_handle_t *phProgram ///< [out] pointer to handle of program object created. ) { - auto pfnProgramLinkExp = getContext()->urDdiTable.ProgramExp.pfnLinkExp; + auto pfnProgramLink = getContext()->urDdiTable.Program.pfnLink; - if (nullptr == pfnProgramLinkExp) { + if (nullptr == pfnProgramLink) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - getContext()->logger.debug("==== urProgramLinkExp"); + getContext()->logger.debug("==== urProgramLink"); - UR_CALL(pfnProgramLinkExp(hContext, numDevices, phDevices, count, - phPrograms, pOptions, phProgram)); + UR_CALL(pfnProgramLink(hContext, numDevices, phDevices, count, phPrograms, + pOptions, phProgram)); UR_CALL( getContext()->interceptor->registerDeviceGlobals(hContext, *phProgram)); @@ -1562,36 +1511,6 @@ __urdlllocal ur_result_t UR_APICALL urGetMemProcAddrTable( return result; } -/// @brief Exported function for filling application's ProgramExp table -/// with current process' addresses -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION -__urdlllocal ur_result_t UR_APICALL urGetProgramExpProcAddrTable( - ur_api_version_t version, ///< [in] API version requested - ur_program_exp_dditable_t - *pDdiTable ///< [in,out] pointer to table of DDI function pointers -) { - if (nullptr == pDdiTable) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - - if (UR_MAJOR_VERSION(ur_sanitizer_layer::getContext()->version) != - UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_sanitizer_layer::getContext()->version) > - UR_MINOR_VERSION(version)) { - return UR_RESULT_ERROR_UNSUPPORTED_VERSION; - } - - ur_result_t result = UR_RESULT_SUCCESS; - - pDdiTable->pfnBuildExp = ur_sanitizer_layer::urProgramBuildExp; - pDdiTable->pfnLinkExp = ur_sanitizer_layer::urProgramLinkExp; - - return result; -} /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Enqueue table /// with current process' addresses @@ -1730,11 +1649,6 @@ ur_result_t context_t::init(ur_dditable_t *dditable, UR_API_VERSION_CURRENT, &dditable->Mem); } - if (UR_RESULT_SUCCESS == result) { - result = ur_sanitizer_layer::urGetProgramExpProcAddrTable( - UR_API_VERSION_CURRENT, &dditable->ProgramExp); - } - if (UR_RESULT_SUCCESS == result) { result = ur_sanitizer_layer::urGetEnqueueProcAddrTable( UR_API_VERSION_CURRENT, &dditable->Enqueue); diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index 4381fea33e..72e23f7755 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -2696,8 +2696,10 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urProgramBuild __urdlllocal 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. + 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. ) { @@ -2707,14 +2709,15 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_program_build_params_t params = {&hContext, &hProgram, &pOptions}; + ur_program_build_params_t params = {&hProgram, &numDevices, &phDevices, + &pOptions}; uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PROGRAM_BUILD, "urProgramBuild", ¶ms); auto &logger = getContext()->logger; logger.info(" ---> urProgramBuild\n"); - ur_result_t result = pfnBuild(hContext, hProgram, pOptions); + ur_result_t result = pfnBuild(hProgram, numDevices, phDevices, pOptions); getContext()->notify_end(UR_FUNCTION_PROGRAM_BUILD, "urProgramBuild", ¶ms, &result, instance); @@ -2733,9 +2736,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urProgramCompile __urdlllocal 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. + 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. ) { @@ -2745,14 +2750,15 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_program_compile_params_t params = {&hContext, &hProgram, &pOptions}; + ur_program_compile_params_t params = {&hProgram, &numDevices, &phDevices, + &pOptions}; uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PROGRAM_COMPILE, "urProgramCompile", ¶ms); auto &logger = getContext()->logger; logger.info(" ---> urProgramCompile\n"); - ur_result_t result = pfnCompile(hContext, hProgram, pOptions); + ur_result_t result = pfnCompile(hProgram, numDevices, phDevices, pOptions); getContext()->notify_end(UR_FUNCTION_PROGRAM_COMPILE, "urProgramCompile", ¶ms, &result, instance); @@ -2772,6 +2778,9 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( /// @brief Intercept function for urProgramLink __urdlllocal 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. @@ -2789,16 +2798,17 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_program_link_params_t params = {&hContext, &count, &phPrograms, - &pOptions, &phProgram}; + ur_program_link_params_t params = {&hContext, &numDevices, &phDevices, + &count, &phPrograms, &pOptions, + &phProgram}; uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PROGRAM_LINK, "urProgramLink", ¶ms); auto &logger = getContext()->logger; logger.info(" ---> urProgramLink\n"); - ur_result_t result = - pfnLink(hContext, count, phPrograms, pOptions, phProgram); + ur_result_t result = pfnLink(hContext, numDevices, phDevices, count, + phPrograms, pOptions, phProgram); getContext()->notify_end(UR_FUNCTION_PROGRAM_LINK, "urProgramLink", ¶ms, &result, instance); @@ -8442,138 +8452,6 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramBuildExp -__urdlllocal 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. -) { - auto pfnBuildExp = getContext()->urDdiTable.ProgramExp.pfnBuildExp; - - if (nullptr == pfnBuildExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - ur_program_build_exp_params_t params = {&hProgram, &numDevices, &phDevices, - &pOptions}; - uint64_t instance = getContext()->notify_begin( - UR_FUNCTION_PROGRAM_BUILD_EXP, "urProgramBuildExp", ¶ms); - - auto &logger = getContext()->logger; - logger.info(" ---> urProgramBuildExp\n"); - - ur_result_t result = pfnBuildExp(hProgram, numDevices, phDevices, pOptions); - - getContext()->notify_end(UR_FUNCTION_PROGRAM_BUILD_EXP, "urProgramBuildExp", - ¶ms, &result, instance); - - if (logger.getLevel() <= logger::Level::INFO) { - std::ostringstream args_str; - ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_BUILD_EXP, - ¶ms); - logger.info(" <--- urProgramBuildExp({}) -> {};\n", args_str.str(), - result); - } - - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramCompileExp -__urdlllocal 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. -) { - auto pfnCompileExp = getContext()->urDdiTable.ProgramExp.pfnCompileExp; - - if (nullptr == pfnCompileExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - ur_program_compile_exp_params_t params = {&hProgram, &numDevices, - &phDevices, &pOptions}; - uint64_t instance = getContext()->notify_begin( - UR_FUNCTION_PROGRAM_COMPILE_EXP, "urProgramCompileExp", ¶ms); - - auto &logger = getContext()->logger; - logger.info(" ---> urProgramCompileExp\n"); - - ur_result_t result = - pfnCompileExp(hProgram, numDevices, phDevices, pOptions); - - getContext()->notify_end(UR_FUNCTION_PROGRAM_COMPILE_EXP, - "urProgramCompileExp", ¶ms, &result, instance); - - if (logger.getLevel() <= logger::Level::INFO) { - std::ostringstream args_str; - ur::extras::printFunctionParams( - args_str, UR_FUNCTION_PROGRAM_COMPILE_EXP, ¶ms); - logger.info(" <--- urProgramCompileExp({}) -> {};\n", args_str.str(), - result); - } - - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramLinkExp -__urdlllocal 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 (nullptr != phProgram) { - *phProgram = nullptr; - } - auto pfnLinkExp = getContext()->urDdiTable.ProgramExp.pfnLinkExp; - - if (nullptr == pfnLinkExp) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - ur_program_link_exp_params_t params = {&hContext, &numDevices, &phDevices, - &count, &phPrograms, &pOptions, - &phProgram}; - uint64_t instance = getContext()->notify_begin(UR_FUNCTION_PROGRAM_LINK_EXP, - "urProgramLinkExp", ¶ms); - - auto &logger = getContext()->logger; - logger.info(" ---> urProgramLinkExp\n"); - - ur_result_t result = pfnLinkExp(hContext, numDevices, phDevices, count, - phPrograms, pOptions, phProgram); - - getContext()->notify_end(UR_FUNCTION_PROGRAM_LINK_EXP, "urProgramLinkExp", - ¶ms, &result, instance); - - if (logger.getLevel() <= logger::Level::INFO) { - std::ostringstream args_str; - ur::extras::printFunctionParams(args_str, UR_FUNCTION_PROGRAM_LINK_EXP, - ¶ms); - logger.info(" <--- urProgramLinkExp({}) -> {};\n", args_str.str(), - result); - } - - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urUSMImportExp __urdlllocal ur_result_t UR_APICALL urUSMImportExp( @@ -9735,45 +9613,6 @@ __urdlllocal ur_result_t UR_APICALL urGetProgramProcAddrTable( return result; } /////////////////////////////////////////////////////////////////////////////// -/// @brief Exported function for filling application's ProgramExp table -/// with current process' addresses -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION -__urdlllocal ur_result_t UR_APICALL urGetProgramExpProcAddrTable( - ur_api_version_t version, ///< [in] API version requested - ur_program_exp_dditable_t - *pDdiTable ///< [in,out] pointer to table of DDI function pointers -) { - auto &dditable = ur_tracing_layer::getContext()->urDdiTable.ProgramExp; - - if (nullptr == pDdiTable) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - - if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != - UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > - UR_MINOR_VERSION(version)) { - return UR_RESULT_ERROR_UNSUPPORTED_VERSION; - } - - ur_result_t result = UR_RESULT_SUCCESS; - - dditable.pfnBuildExp = pDdiTable->pfnBuildExp; - pDdiTable->pfnBuildExp = ur_tracing_layer::urProgramBuildExp; - - dditable.pfnCompileExp = pDdiTable->pfnCompileExp; - pDdiTable->pfnCompileExp = ur_tracing_layer::urProgramCompileExp; - - dditable.pfnLinkExp = pDdiTable->pfnLinkExp; - pDdiTable->pfnLinkExp = ur_tracing_layer::urProgramLinkExp; - - return result; -} -/////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Queue table /// with current process' addresses /// @@ -10207,11 +10046,6 @@ ur_result_t context_t::init(ur_dditable_t *dditable, UR_API_VERSION_CURRENT, &dditable->Program); } - if (UR_RESULT_SUCCESS == result) { - result = ur_tracing_layer::urGetProgramExpProcAddrTable( - UR_API_VERSION_CURRENT, &dditable->ProgramExp); - } - if (UR_RESULT_SUCCESS == result) { result = ur_tracing_layer::urGetQueueProcAddrTable( UR_API_VERSION_CURRENT, &dditable->Queue); diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 48663282df..ba6f1d7ec3 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -2788,8 +2788,10 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urProgramBuild __urdlllocal 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. + 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. ) { @@ -2800,18 +2802,17 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( } if (getContext()->enableParameterValidation) { - if (NULL == hContext) { + if (NULL == hProgram) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } - if (NULL == hProgram) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + if (NULL == phDevices) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - } - if (getContext()->enableLifetimeValidation && - !getContext()->refCountContext->isReferenceValid(hContext)) { - getContext()->refCountContext->logInvalidReference(hContext); + if (numDevices == 0) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } if (getContext()->enableLifetimeValidation && @@ -2819,7 +2820,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( getContext()->refCountContext->logInvalidReference(hProgram); } - ur_result_t result = pfnBuild(hContext, hProgram, pOptions); + ur_result_t result = pfnBuild(hProgram, numDevices, phDevices, pOptions); return result; } @@ -2827,9 +2828,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urProgramCompile __urdlllocal 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. + 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. ) { @@ -2840,18 +2843,17 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( } if (getContext()->enableParameterValidation) { - if (NULL == hContext) { + if (NULL == hProgram) { return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } - if (NULL == hProgram) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + if (NULL == phDevices) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - } - if (getContext()->enableLifetimeValidation && - !getContext()->refCountContext->isReferenceValid(hContext)) { - getContext()->refCountContext->logInvalidReference(hContext); + if (numDevices == 0) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } if (getContext()->enableLifetimeValidation && @@ -2859,7 +2861,7 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( getContext()->refCountContext->logInvalidReference(hProgram); } - ur_result_t result = pfnCompile(hContext, hProgram, pOptions); + ur_result_t result = pfnCompile(hProgram, numDevices, phDevices, pOptions); return result; } @@ -2868,6 +2870,9 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( /// @brief Intercept function for urProgramLink __urdlllocal 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. @@ -2890,6 +2895,10 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == phDevices) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (NULL == phPrograms) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -2898,6 +2907,10 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } + if (numDevices == 0) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + if (count == 0) { return UR_RESULT_ERROR_INVALID_SIZE; } @@ -2908,8 +2921,8 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( getContext()->refCountContext->logInvalidReference(hContext); } - ur_result_t result = - pfnLink(hContext, count, phPrograms, pOptions, phProgram); + ur_result_t result = pfnLink(hContext, numDevices, phDevices, count, + phPrograms, pOptions, phProgram); return result; } @@ -9348,137 +9361,6 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramBuildExp -__urdlllocal 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. -) { - auto pfnBuildExp = getContext()->urDdiTable.ProgramExp.pfnBuildExp; - - if (nullptr == pfnBuildExp) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - if (getContext()->enableParameterValidation) { - if (NULL == hProgram) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - - if (NULL == phDevices) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - } - - if (getContext()->enableLifetimeValidation && - !getContext()->refCountContext->isReferenceValid(hProgram)) { - getContext()->refCountContext->logInvalidReference(hProgram); - } - - ur_result_t result = pfnBuildExp(hProgram, numDevices, phDevices, pOptions); - - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramCompileExp -__urdlllocal 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. -) { - auto pfnCompileExp = getContext()->urDdiTable.ProgramExp.pfnCompileExp; - - if (nullptr == pfnCompileExp) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - if (getContext()->enableParameterValidation) { - if (NULL == hProgram) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - - if (NULL == phDevices) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - } - - if (getContext()->enableLifetimeValidation && - !getContext()->refCountContext->isReferenceValid(hProgram)) { - getContext()->refCountContext->logInvalidReference(hProgram); - } - - ur_result_t result = - pfnCompileExp(hProgram, numDevices, phDevices, pOptions); - - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramLinkExp -__urdlllocal 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 (nullptr != phProgram) { - *phProgram = nullptr; - } - auto pfnLinkExp = getContext()->urDdiTable.ProgramExp.pfnLinkExp; - - if (nullptr == pfnLinkExp) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - if (getContext()->enableParameterValidation) { - if (NULL == hContext) { - return UR_RESULT_ERROR_INVALID_NULL_HANDLE; - } - - if (NULL == phDevices) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - - if (NULL == phPrograms) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - - if (NULL == phProgram) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - - if (count == 0) { - return UR_RESULT_ERROR_INVALID_SIZE; - } - } - - if (getContext()->enableLifetimeValidation && - !getContext()->refCountContext->isReferenceValid(hContext)) { - getContext()->refCountContext->logInvalidReference(hContext); - } - - ur_result_t result = pfnLinkExp(hContext, numDevices, phDevices, count, - phPrograms, pOptions, phProgram); - - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urUSMImportExp __urdlllocal ur_result_t UR_APICALL urUSMImportExp( @@ -10667,46 +10549,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramProcAddrTable( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Exported function for filling application's ProgramExp table -/// with current process' addresses -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION -UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( - ur_api_version_t version, ///< [in] API version requested - ur_program_exp_dditable_t - *pDdiTable ///< [in,out] pointer to table of DDI function pointers -) { - auto &dditable = ur_validation_layer::getContext()->urDdiTable.ProgramExp; - - if (nullptr == pDdiTable) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - - if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != - UR_MAJOR_VERSION(version) || - UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > - UR_MINOR_VERSION(version)) { - return UR_RESULT_ERROR_UNSUPPORTED_VERSION; - } - - ur_result_t result = UR_RESULT_SUCCESS; - - dditable.pfnBuildExp = pDdiTable->pfnBuildExp; - pDdiTable->pfnBuildExp = ur_validation_layer::urProgramBuildExp; - - dditable.pfnCompileExp = pDdiTable->pfnCompileExp; - pDdiTable->pfnCompileExp = ur_validation_layer::urProgramCompileExp; - - dditable.pfnLinkExp = pDdiTable->pfnLinkExp; - pDdiTable->pfnLinkExp = ur_validation_layer::urProgramLinkExp; - - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Queue table /// with current process' addresses @@ -11166,11 +11008,6 @@ ur_result_t context_t::init(ur_dditable_t *dditable, UR_API_VERSION_CURRENT, &dditable->Program); } - if (UR_RESULT_SUCCESS == result) { - result = ur_validation_layer::urGetProgramExpProcAddrTable( - UR_API_VERSION_CURRENT, &dditable->ProgramExp); - } - if (UR_RESULT_SUCCESS == result) { result = ur_validation_layer::urGetQueueProcAddrTable( UR_API_VERSION_CURRENT, &dditable->Queue); diff --git a/source/loader/loader.def.in b/source/loader/loader.def.in index 63a5f1843d..2939d07f3d 100644 --- a/source/loader/loader.def.in +++ b/source/loader/loader.def.in @@ -112,7 +112,6 @@ EXPORTS urGetMemProcAddrTable urGetPhysicalMemProcAddrTable urGetPlatformProcAddrTable - urGetProgramExpProcAddrTable urGetProgramProcAddrTable urGetQueueProcAddrTable urGetSamplerProcAddrTable @@ -402,11 +401,9 @@ EXPORTS urPrintPlatformNativeProperties urPrintProfilingInfo urPrintProgramBinaryType - urPrintProgramBuildExpParams urPrintProgramBuildInfo urPrintProgramBuildParams urPrintProgramBuildStatus - urPrintProgramCompileExpParams urPrintProgramCompileParams urPrintProgramCreateWithBinaryParams urPrintProgramCreateWithIlParams @@ -417,7 +414,6 @@ EXPORTS urPrintProgramGetInfoParams urPrintProgramGetNativeHandleParams urPrintProgramInfo - urPrintProgramLinkExpParams urPrintProgramLinkParams urPrintProgramMetadata urPrintProgramMetadataType @@ -496,9 +492,7 @@ EXPORTS urPrintVirtualMemSetAccessParams urPrintVirtualMemUnmapParams urProgramBuild - urProgramBuildExp urProgramCompile - urProgramCompileExp urProgramCreateWithBinary urProgramCreateWithIL urProgramCreateWithNativeHandle @@ -508,7 +502,6 @@ EXPORTS urProgramGetInfo urProgramGetNativeHandle urProgramLink - urProgramLinkExp urProgramRelease urProgramRetain urProgramSetSpecializationConstants diff --git a/source/loader/loader.map.in b/source/loader/loader.map.in index a4ca4a713f..9bb20e8634 100644 --- a/source/loader/loader.map.in +++ b/source/loader/loader.map.in @@ -112,7 +112,6 @@ urGetMemProcAddrTable; urGetPhysicalMemProcAddrTable; urGetPlatformProcAddrTable; - urGetProgramExpProcAddrTable; urGetProgramProcAddrTable; urGetQueueProcAddrTable; urGetSamplerProcAddrTable; @@ -402,11 +401,9 @@ urPrintPlatformNativeProperties; urPrintProfilingInfo; urPrintProgramBinaryType; - urPrintProgramBuildExpParams; urPrintProgramBuildInfo; urPrintProgramBuildParams; urPrintProgramBuildStatus; - urPrintProgramCompileExpParams; urPrintProgramCompileParams; urPrintProgramCreateWithBinaryParams; urPrintProgramCreateWithIlParams; @@ -417,7 +414,6 @@ urPrintProgramGetInfoParams; urPrintProgramGetNativeHandleParams; urPrintProgramInfo; - urPrintProgramLinkExpParams; urPrintProgramLinkParams; urPrintProgramMetadata; urPrintProgramMetadataType; @@ -496,9 +492,7 @@ urPrintVirtualMemSetAccessParams; urPrintVirtualMemUnmapParams; urProgramBuild; - urProgramBuildExp; urProgramCompile; - urProgramCompileExp; urProgramCreateWithBinary; urProgramCreateWithIL; urProgramCreateWithNativeHandle; @@ -508,7 +502,6 @@ urProgramGetInfo; urProgramGetNativeHandle; urProgramLink; - urProgramLinkExp; urProgramRelease; urProgramRetain; urProgramSetSpecializationConstants; diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 4d384dbb52..f74dfd0f3a 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -2612,8 +2612,10 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithBinary( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urProgramBuild __urdlllocal 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. + 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. ) { @@ -2622,20 +2624,24 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( [[maybe_unused]] auto context = getContext(); // extract platform's function pointer table - auto dditable = reinterpret_cast(hContext)->dditable; + auto dditable = reinterpret_cast(hProgram)->dditable; auto pfnBuild = dditable->ur.Program.pfnBuild; if (nullptr == pfnBuild) { return UR_RESULT_ERROR_UNINITIALIZED; } - // convert loader handle to platform handle - hContext = reinterpret_cast(hContext)->handle; - // convert loader handle to platform handle hProgram = reinterpret_cast(hProgram)->handle; + // convert loader handles to platform handles + auto phDevicesLocal = std::vector(numDevices); + for (size_t i = 0; i < numDevices; ++i) { + phDevicesLocal[i] = + reinterpret_cast(phDevices[i])->handle; + } + // forward to device-platform - result = pfnBuild(hContext, hProgram, pOptions); + result = pfnBuild(hProgram, numDevices, phDevicesLocal.data(), pOptions); return result; } @@ -2643,9 +2649,11 @@ __urdlllocal ur_result_t UR_APICALL urProgramBuild( /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urProgramCompile __urdlllocal 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. + 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. ) { @@ -2654,20 +2662,24 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( [[maybe_unused]] auto context = getContext(); // extract platform's function pointer table - auto dditable = reinterpret_cast(hContext)->dditable; + auto dditable = reinterpret_cast(hProgram)->dditable; auto pfnCompile = dditable->ur.Program.pfnCompile; if (nullptr == pfnCompile) { return UR_RESULT_ERROR_UNINITIALIZED; } - // convert loader handle to platform handle - hContext = reinterpret_cast(hContext)->handle; - // convert loader handle to platform handle hProgram = reinterpret_cast(hProgram)->handle; + // convert loader handles to platform handles + auto phDevicesLocal = std::vector(numDevices); + for (size_t i = 0; i < numDevices; ++i) { + phDevicesLocal[i] = + reinterpret_cast(phDevices[i])->handle; + } + // forward to device-platform - result = pfnCompile(hContext, hProgram, pOptions); + result = pfnCompile(hProgram, numDevices, phDevicesLocal.data(), pOptions); return result; } @@ -2676,6 +2688,9 @@ __urdlllocal ur_result_t UR_APICALL urProgramCompile( /// @brief Intercept function for urProgramLink __urdlllocal 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. @@ -2701,6 +2716,13 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( // convert loader handle to platform handle hContext = reinterpret_cast(hContext)->handle; + // convert loader handles to platform handles + auto phDevicesLocal = std::vector(numDevices); + for (size_t i = 0; i < numDevices; ++i) { + phDevicesLocal[i] = + reinterpret_cast(phDevices[i])->handle; + } + // convert loader handles to platform handles auto phProgramsLocal = std::vector(count); for (size_t i = 0; i < count; ++i) { @@ -2709,8 +2731,8 @@ __urdlllocal ur_result_t UR_APICALL urProgramLink( } // forward to device-platform - result = - pfnLink(hContext, count, phProgramsLocal.data(), pOptions, phProgram); + result = pfnLink(hContext, numDevices, phDevicesLocal.data(), count, + phProgramsLocal.data(), pOptions, phProgram); try { // convert platform handle to loader handle @@ -8245,146 +8267,6 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramBuildExp -__urdlllocal 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. -) { - ur_result_t result = UR_RESULT_SUCCESS; - - [[maybe_unused]] auto context = getContext(); - - // extract platform's function pointer table - auto dditable = reinterpret_cast(hProgram)->dditable; - auto pfnBuildExp = dditable->ur.ProgramExp.pfnBuildExp; - if (nullptr == pfnBuildExp) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - // convert loader handle to platform handle - hProgram = reinterpret_cast(hProgram)->handle; - - // convert loader handles to platform handles - auto phDevicesLocal = std::vector(numDevices); - for (size_t i = 0; i < numDevices; ++i) { - phDevicesLocal[i] = - reinterpret_cast(phDevices[i])->handle; - } - - // forward to device-platform - result = pfnBuildExp(hProgram, numDevices, phDevicesLocal.data(), pOptions); - - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramCompileExp -__urdlllocal 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. -) { - ur_result_t result = UR_RESULT_SUCCESS; - - [[maybe_unused]] auto context = getContext(); - - // extract platform's function pointer table - auto dditable = reinterpret_cast(hProgram)->dditable; - auto pfnCompileExp = dditable->ur.ProgramExp.pfnCompileExp; - if (nullptr == pfnCompileExp) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - // convert loader handle to platform handle - hProgram = reinterpret_cast(hProgram)->handle; - - // convert loader handles to platform handles - auto phDevicesLocal = std::vector(numDevices); - for (size_t i = 0; i < numDevices; ++i) { - phDevicesLocal[i] = - reinterpret_cast(phDevices[i])->handle; - } - - // forward to device-platform - result = - pfnCompileExp(hProgram, numDevices, phDevicesLocal.data(), pOptions); - - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Intercept function for urProgramLinkExp -__urdlllocal 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. -) { - ur_result_t result = UR_RESULT_SUCCESS; - if (nullptr != phProgram) { - *phProgram = nullptr; - } - - [[maybe_unused]] auto context = getContext(); - - // extract platform's function pointer table - auto dditable = reinterpret_cast(hContext)->dditable; - auto pfnLinkExp = dditable->ur.ProgramExp.pfnLinkExp; - if (nullptr == pfnLinkExp) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - // convert loader handle to platform handle - hContext = reinterpret_cast(hContext)->handle; - - // convert loader handles to platform handles - auto phDevicesLocal = std::vector(numDevices); - for (size_t i = 0; i < numDevices; ++i) { - phDevicesLocal[i] = - reinterpret_cast(phDevices[i])->handle; - } - - // convert loader handles to platform handles - auto phProgramsLocal = std::vector(count); - for (size_t i = 0; i < count; ++i) { - phProgramsLocal[i] = - reinterpret_cast(phPrograms[i])->handle; - } - - // forward to device-platform - result = pfnLinkExp(hContext, numDevices, phDevicesLocal.data(), count, - phProgramsLocal.data(), pOptions, phProgram); - - try { - // convert platform handle to loader handle - if (nullptr != phProgram) { - *phProgram = reinterpret_cast( - context->factories.ur_program_factory.getInstance(*phProgram, - dditable)); - } - } catch (std::bad_alloc &) { - result = UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; - } - - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for urUSMImportExp __urdlllocal ur_result_t UR_APICALL urUSMImportExp( @@ -9588,68 +9470,6 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramProcAddrTable( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Exported function for filling application's ProgramExp table -/// with current process' addresses -/// -/// @returns -/// - ::UR_RESULT_SUCCESS -/// - ::UR_RESULT_ERROR_UNINITIALIZED -/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER -/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION -UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramExpProcAddrTable( - ur_api_version_t version, ///< [in] API version requested - ur_program_exp_dditable_t - *pDdiTable ///< [in,out] pointer to table of DDI function pointers -) { - if (nullptr == pDdiTable) { - return UR_RESULT_ERROR_INVALID_NULL_POINTER; - } - - if (ur_loader::getContext()->version < version) { - return UR_RESULT_ERROR_UNSUPPORTED_VERSION; - } - - ur_result_t result = UR_RESULT_SUCCESS; - - // Load the device-platform DDI tables - for (auto &platform : ur_loader::getContext()->platforms) { - // statically linked adapter inside of the loader - if (platform.handle == nullptr) { - continue; - } - - if (platform.initStatus != UR_RESULT_SUCCESS) { - continue; - } - auto getTable = reinterpret_cast( - ur_loader::LibLoader::getFunctionPtr( - platform.handle.get(), "urGetProgramExpProcAddrTable")); - if (!getTable) { - continue; - } - platform.initStatus = - getTable(version, &platform.dditable.ur.ProgramExp); - } - - if (UR_RESULT_SUCCESS == result) { - if (ur_loader::getContext()->platforms.size() != 1 || - ur_loader::getContext()->forceIntercept) { - // return pointers to loader's DDIs - pDdiTable->pfnBuildExp = ur_loader::urProgramBuildExp; - pDdiTable->pfnCompileExp = ur_loader::urProgramCompileExp; - pDdiTable->pfnLinkExp = ur_loader::urProgramLinkExp; - } else { - // return pointers directly to platform's DDIs - *pDdiTable = ur_loader::getContext() - ->platforms.front() - .dditable.ur.ProgramExp; - } - } - - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Queue table /// with current process' addresses diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 1e90ccb2bb..5ed08705f5 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -3072,15 +3072,20 @@ ur_result_t UR_APICALL 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_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. + 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. ) try { @@ -3089,7 +3094,7 @@ ur_result_t UR_APICALL urProgramBuild( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnBuild(hContext, hProgram, pOptions); + return pfnBuild(hProgram, numDevices, phDevices, pOptions); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -3113,16 +3118,21 @@ ur_result_t UR_APICALL 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_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. + 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. ) try { @@ -3131,7 +3141,7 @@ ur_result_t UR_APICALL urProgramCompile( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnCompile(hContext, hProgram, pOptions); + return pfnCompile(hProgram, numDevices, phDevices, pOptions); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -3163,16 +3173,21 @@ ur_result_t UR_APICALL 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_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. @@ -3189,7 +3204,8 @@ ur_result_t UR_APICALL urProgramLink( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnLink(hContext, count, phPrograms, pOptions, phProgram); + return pfnLink(hContext, numDevices, phDevices, count, phPrograms, pOptions, + phProgram); } catch (...) { return exceptionToResult(std::current_exception()); } @@ -8685,160 +8701,6 @@ ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( return exceptionToResult(std::current_exception()); } -/////////////////////////////////////////////////////////////////////////////// -/// @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_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. - ) try { - auto pfnBuildExp = ur_lib::getContext()->urDdiTable.ProgramExp.pfnBuildExp; - if (nullptr == pfnBuildExp) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - return pfnBuildExp(hProgram, numDevices, phDevices, pOptions); -} catch (...) { - return exceptionToResult(std::current_exception()); -} - -/////////////////////////////////////////////////////////////////////////////// -/// @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_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. - ) try { - auto pfnCompileExp = - ur_lib::getContext()->urDdiTable.ProgramExp.pfnCompileExp; - if (nullptr == pfnCompileExp) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - return pfnCompileExp(hProgram, numDevices, phDevices, pOptions); -} catch (...) { - return exceptionToResult(std::current_exception()); -} - -/////////////////////////////////////////////////////////////////////////////// -/// @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_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. - ) try { - if (nullptr != phProgram) { - *phProgram = nullptr; - } - auto pfnLinkExp = ur_lib::getContext()->urDdiTable.ProgramExp.pfnLinkExp; - if (nullptr == pfnLinkExp) { - return UR_RESULT_ERROR_UNINITIALIZED; - } - - return pfnLinkExp(hContext, numDevices, phDevices, count, phPrograms, - pOptions, phProgram); -} catch (...) { - return exceptionToResult(std::current_exception()); -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Import memory into USM /// diff --git a/source/loader/ur_libddi.cpp b/source/loader/ur_libddi.cpp index 4d88bb2044..992eb3b676 100644 --- a/source/loader/ur_libddi.cpp +++ b/source/loader/ur_libddi.cpp @@ -84,11 +84,6 @@ __urdlllocal ur_result_t context_t::ddiInit() { &urDdiTable.Program); } - if (UR_RESULT_SUCCESS == result) { - result = urGetProgramExpProcAddrTable(UR_API_VERSION_CURRENT, - &urDdiTable.ProgramExp); - } - if (UR_RESULT_SUCCESS == result) { result = urGetQueueProcAddrTable(UR_API_VERSION_CURRENT, &urDdiTable.Queue); diff --git a/source/loader/ur_print.cpp b/source/loader/ur_print.cpp index 454dc6d436..1e0c2e29ed 100644 --- a/source/loader/ur_print.cpp +++ b/source/loader/ur_print.cpp @@ -2219,15 +2219,6 @@ urPrintProgramBuildParams(const struct ur_program_build_params_t *params, return str_copy(&ss, buffer, buff_size, out_size); } -ur_result_t -urPrintProgramBuildExpParams(const struct ur_program_build_exp_params_t *params, - char *buffer, const size_t buff_size, - size_t *out_size) { - std::stringstream ss; - ss << params; - return str_copy(&ss, buffer, buff_size, out_size); -} - ur_result_t urPrintProgramCompileParams(const struct ur_program_compile_params_t *params, char *buffer, const size_t buff_size, @@ -2237,14 +2228,6 @@ urPrintProgramCompileParams(const struct ur_program_compile_params_t *params, return str_copy(&ss, buffer, buff_size, out_size); } -ur_result_t urPrintProgramCompileExpParams( - const struct ur_program_compile_exp_params_t *params, char *buffer, - const size_t buff_size, size_t *out_size) { - std::stringstream ss; - ss << params; - return str_copy(&ss, buffer, buff_size, out_size); -} - ur_result_t urPrintProgramLinkParams(const struct ur_program_link_params_t *params, char *buffer, const size_t buff_size, @@ -2254,15 +2237,6 @@ urPrintProgramLinkParams(const struct ur_program_link_params_t *params, return str_copy(&ss, buffer, buff_size, out_size); } -ur_result_t -urPrintProgramLinkExpParams(const struct ur_program_link_exp_params_t *params, - char *buffer, const size_t buff_size, - size_t *out_size) { - std::stringstream ss; - ss << params; - return str_copy(&ss, buffer, buff_size, out_size); -} - ur_result_t urPrintProgramRetainParams(const struct ur_program_retain_params_t *params, char *buffer, const size_t buff_size, diff --git a/source/ur_api.cpp b/source/ur_api.cpp index e850247f84..d6a4ec27a8 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -2631,15 +2631,20 @@ ur_result_t UR_APICALL 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_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. + 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. ) { @@ -2666,16 +2671,21 @@ ur_result_t UR_APICALL 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_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. + 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. ) { @@ -2710,16 +2720,21 @@ ur_result_t UR_APICALL 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_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. @@ -7337,137 +7352,6 @@ ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( return result; } -/////////////////////////////////////////////////////////////////////////////// -/// @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_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. -) { - ur_result_t result = UR_RESULT_SUCCESS; - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @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_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. -) { - ur_result_t result = UR_RESULT_SUCCESS; - return result; -} - -/////////////////////////////////////////////////////////////////////////////// -/// @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_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. -) { - ur_result_t result = UR_RESULT_SUCCESS; - return result; -} - /////////////////////////////////////////////////////////////////////////////// /// @brief Import memory into USM /// diff --git a/test/adapters/cuda/kernel_tests.cpp b/test/adapters/cuda/kernel_tests.cpp index 80ec9146fd..74080f12bf 100644 --- a/test/adapters/cuda/kernel_tests.cpp +++ b/test/adapters/cuda/kernel_tests.cpp @@ -78,7 +78,7 @@ TEST_P(cudaKernelTest, CreateProgramAndKernel) { context, device, std::strlen(ptxSource), (const uint8_t *)ptxSource, nullptr, program.ptr())); ASSERT_NE(program, nullptr); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); uur::raii::Kernel kernel = nullptr; ASSERT_SUCCESS(urKernelCreate(program, "_Z8myKernelPi", kernel.ptr())); @@ -121,7 +121,7 @@ TEST_P(cudaKernelTest, CreateProgramAndKernelWithMetadata) { &programProps, program.ptr())); ASSERT_NE(program, nullptr); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); uur::raii::Kernel kernel = nullptr; ASSERT_SUCCESS(urKernelCreate(program, "_Z8myKernelPi", kernel.ptr())); @@ -142,7 +142,7 @@ TEST_P(cudaKernelTest, URKernelArgumentSimple) { context, device, std::strlen(ptxSource), (const uint8_t *)ptxSource, nullptr, program.ptr())); ASSERT_NE(program, nullptr); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); uur::raii::Kernel kernel = nullptr; ASSERT_SUCCESS(urKernelCreate(program, "_Z8myKernelPi", kernel.ptr())); @@ -164,7 +164,7 @@ TEST_P(cudaKernelTest, URKernelArgumentSetTwice) { context, device, std::strlen(ptxSource), (const uint8_t *)ptxSource, nullptr, program.ptr())); ASSERT_NE(program, nullptr); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); uur::raii::Kernel kernel = nullptr; ASSERT_SUCCESS(urKernelCreate(program, "_Z8myKernelPi", kernel.ptr())); @@ -193,7 +193,7 @@ TEST_P(cudaKernelTest, URKernelDispatch) { context, device, std::strlen(ptxSource), (const uint8_t *)ptxSource, nullptr, program.ptr())); ASSERT_NE(program, nullptr); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); uur::raii::Kernel kernel = nullptr; ASSERT_SUCCESS(urKernelCreate(program, "_Z8myKernelPi", kernel.ptr())); @@ -222,7 +222,7 @@ TEST_P(cudaKernelTest, URKernelDispatchTwo) { context, device, std::strlen(ptxSource), (const uint8_t *)twoParams, nullptr, program.ptr())); ASSERT_NE(program, nullptr); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); uur::raii::Kernel kernel = nullptr; ASSERT_SUCCESS(urKernelCreate(program, "twoParamKernel", kernel.ptr())); diff --git a/test/adapters/level_zero/urProgramLink.cpp b/test/adapters/level_zero/urProgramLink.cpp index b84247ec47..6fcdb92d5d 100644 --- a/test/adapters/level_zero/urProgramLink.cpp +++ b/test/adapters/level_zero/urProgramLink.cpp @@ -11,10 +11,10 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urLevelZeroProgramLinkTest); TEST_P(urLevelZeroProgramLinkTest, InvalidLinkOptionsPrintedInLog) { ur_program_handle_t linked_program = nullptr; - ASSERT_SUCCESS(urProgramCompile(context, program, "-foo")); - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_PROGRAM_LINK_FAILURE, - urProgramLink(context, 1, &program, "-foo", &linked_program)); + ASSERT_SUCCESS(urProgramCompile(program, 1, &device, "-foo")); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_PROGRAM_LINK_FAILURE, + urProgramLink(context, 1, &device, 1, &program, "-foo", + &linked_program)); size_t logSize; std::vector log; diff --git a/test/conformance/enqueue/urEnqueueKernelLaunchAndMemcpyInOrder.cpp b/test/conformance/enqueue/urEnqueueKernelLaunchAndMemcpyInOrder.cpp index f8ed6d4f42..722ebfaf01 100644 --- a/test/conformance/enqueue/urEnqueueKernelLaunchAndMemcpyInOrder.cpp +++ b/test/conformance/enqueue/urEnqueueKernelLaunchAndMemcpyInOrder.cpp @@ -64,7 +64,7 @@ struct urMultiQueueLaunchMemcpyTest : uur::urMultiDeviceContextTestTemplate<1>, &programs[i])); UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( - urProgramBuild(context, programs[i], nullptr)); + urProgramBuild(programs[i], 1, &devices[i], nullptr)); ASSERT_SUCCESS( urKernelCreate(programs[i], KernelName.data(), &kernels[i])); diff --git a/test/conformance/exp_command_buffer/fixtures.h b/test/conformance/exp_command_buffer/fixtures.h index 442cbbc7f6..f66756d9c9 100644 --- a/test/conformance/exp_command_buffer/fixtures.h +++ b/test/conformance/exp_command_buffer/fixtures.h @@ -260,7 +260,7 @@ struct TestKernel { std::string KernelName = KernelNames[0]; ASSERT_FALSE(KernelName.empty()); - ASSERT_SUCCESS(urProgramBuild(Context, Program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(Program, 1, &Device, nullptr)); ASSERT_SUCCESS(urKernelCreate(Program, KernelName.data(), &Kernel)); } diff --git a/test/conformance/kernel/urKernelCreate.cpp b/test/conformance/kernel/urKernelCreate.cpp index 4629d3f87e..f6f6de4d72 100644 --- a/test/conformance/kernel/urKernelCreate.cpp +++ b/test/conformance/kernel/urKernelCreate.cpp @@ -9,7 +9,7 @@ struct urKernelCreateTest : uur::urProgramTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urProgramTest::SetUp()); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); auto kernel_names = uur::KernelsEnvironment::instance->GetEntryPointNames( this->program_name); @@ -78,7 +78,7 @@ TEST_F(urMultiDeviceKernelCreateTest, WithProgramBuild) { platform, context, devices[i], *il_binary, &properties, program.ptr())); - ASSERT_SUCCESS(urProgramBuild(context, program.get(), nullptr)); + ASSERT_SUCCESS(urProgramBuild(program.get(), 1, &devices[i], nullptr)); ASSERT_SUCCESS( urKernelCreate(program.get(), kernelName.data(), kernel.ptr())); @@ -113,11 +113,13 @@ TEST_F(urMultiDeviceKernelCreateTest, WithProgramCompileAndLink) { platform, context, devices[i], *il_binary, &properties, program.ptr())); - ASSERT_SUCCESS(urProgramCompile(context, program.get(), nullptr)); + ASSERT_SUCCESS( + urProgramCompile(program.get(), 1, &devices[i], nullptr)); uur::raii::Program linked_program; ASSERT_EQ_RESULT(UR_RESULT_SUCCESS, - urProgramLink(context, 1, program.ptr(), nullptr, + urProgramLink(context, 1, &devices[i], 1, + program.ptr(), nullptr, linked_program.ptr())); ASSERT_SUCCESS(urKernelCreate(linked_program.get(), kernelName.data(), diff --git a/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp b/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp index f7617a2940..cebdf5923c 100644 --- a/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp +++ b/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp @@ -76,7 +76,8 @@ struct urMultiDeviceContextMemBufferTest : urMultiDeviceContextTest { ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram( platform, context, devices[i], *il_binary, &properties, &programs[i])); - ASSERT_SUCCESS(urProgramBuild(context, programs[i], nullptr)); + ASSERT_SUCCESS( + urProgramBuild(programs[i], 1, &devices[i], nullptr)); auto kernel_names = uur::KernelsEnvironment::instance->GetEntryPointNames( program_name); diff --git a/test/conformance/program/program_adapter_native_cpu.match b/test/conformance/program/program_adapter_native_cpu.match index f9aeace343..f4067a8b33 100644 --- a/test/conformance/program/program_adapter_native_cpu.match +++ b/test/conformance/program/program_adapter_native_cpu.match @@ -1,11 +1,14 @@ {{NONDETERMINISTIC}} {{OPT}}urProgramBuildTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramBuildTest.SuccessWithOptions/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +{{OPT}}urProgramBuildTest.InvalidNullPointerDevices/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +{{OPT}}urProgramBuildTest.InvalidSizeNumDevices/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramBuildTest.InvalidNullHandleContext/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramBuildTest.InvalidNullHandleProgram/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramBuildTest.BuildFailure/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramCompileTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} -{{OPT}}urProgramCompileTest.InvalidNullHandleContext/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +{{OPT}}urProgramCompileTest.InvalidNullPointerDevices/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +{{OPT}}urProgramCompileTest.InvalidSizeNumDevices/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramCompileTest.InvalidNullHandleProgram/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramCreateWithBinaryTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramCreateWithBinaryTest.InvalidNullHandleContext/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} @@ -127,6 +130,8 @@ {{OPT}}urProgramLinkTest.InvalidNullHandleContext/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramLinkTest.InvalidNullPointerProgram/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramLinkTest.InvalidNullPointerInputPrograms/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +{{OPT}}urProgramLinkTest.InvalidSizeNumDevices/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +{{OPT}}urProgramLinkTest.InvalidNullPointerDevices/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramLinkTest.InvalidSizeCount/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramLinkTest.SetOutputOnZeroCount/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramLinkErrorTest.LinkFailure/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} diff --git a/test/conformance/program/urProgramBuild.cpp b/test/conformance/program/urProgramBuild.cpp index a7e7e4a275..8ca756b356 100644 --- a/test/conformance/program/urProgramBuild.cpp +++ b/test/conformance/program/urProgramBuild.cpp @@ -9,22 +9,27 @@ using urProgramBuildTest = uur::urProgramTest; UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramBuildTest); TEST_P(urProgramBuildTest, Success) { - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); } TEST_P(urProgramBuildTest, SuccessWithOptions) { const char *pOptions = ""; - ASSERT_SUCCESS(urProgramBuild(context, program, pOptions)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, pOptions)); } -TEST_P(urProgramBuildTest, InvalidNullHandleContext) { +TEST_P(urProgramBuildTest, InvalidNullHandleProgram) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urProgramBuild(nullptr, program, nullptr)); + urProgramBuild(nullptr, 1, &device, nullptr)); } -TEST_P(urProgramBuildTest, InvalidNullHandleProgram) { - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urProgramBuild(context, nullptr, nullptr)); +TEST_P(urProgramBuildTest, InvalidNullPointerDevices) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urProgramBuild(program, 1, nullptr, nullptr)); +} + +TEST_P(urProgramBuildTest, InvalidSizeNumDevices) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urProgramBuild(program, 0, &device, nullptr)); } TEST_P(urProgramBuildTest, BuildFailure) { @@ -54,5 +59,5 @@ TEST_P(urProgramBuildTest, BuildFailure) { il_binary->size(), nullptr, &program)); ASSERT_EQ_RESULT(UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE, - urProgramBuild(context, program, nullptr)); + urProgramBuild(program, 1, &device, nullptr)); } diff --git a/test/conformance/program/urProgramCompile.cpp b/test/conformance/program/urProgramCompile.cpp index 5fcae35f6c..0f2669ab16 100644 --- a/test/conformance/program/urProgramCompile.cpp +++ b/test/conformance/program/urProgramCompile.cpp @@ -9,15 +9,20 @@ using urProgramCompileTest = uur::urProgramTest; UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramCompileTest); TEST_P(urProgramCompileTest, Success) { - ASSERT_SUCCESS(urProgramCompile(context, program, nullptr)); + ASSERT_SUCCESS(urProgramCompile(program, 1, &device, nullptr)); } -TEST_P(urProgramCompileTest, InvalidNullHandleContext) { +TEST_P(urProgramCompileTest, InvalidNullHandleProgram) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urProgramCompile(nullptr, program, nullptr)); + urProgramCompile(nullptr, 1, &device, nullptr)); } -TEST_P(urProgramCompileTest, InvalidNullHandleProgram) { - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urProgramCompile(context, nullptr, nullptr)); +TEST_P(urProgramCompileTest, InvalidNullPointerDevices) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urProgramCompile(program, 1, nullptr, nullptr)); +} + +TEST_P(urProgramCompileTest, InvalidSizeNumDevices) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urProgramCompile(program, 0, &device, nullptr)); } diff --git a/test/conformance/program/urProgramCreateWithBinary.cpp b/test/conformance/program/urProgramCreateWithBinary.cpp index 0f525dd293..50ab554b55 100644 --- a/test/conformance/program/urProgramCreateWithBinary.cpp +++ b/test/conformance/program/urProgramCreateWithBinary.cpp @@ -8,12 +8,13 @@ struct urProgramCreateWithBinaryTest : uur::urProgramTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urProgramTest::SetUp()); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); size_t binary_sizes_len = 0; ASSERT_SUCCESS(urProgramGetInfo(program, UR_PROGRAM_INFO_BINARY_SIZES, 0, nullptr, &binary_sizes_len)); // We're expecting one binary ASSERT_EQ(binary_sizes_len / sizeof(size_t), 1); + size_t binary_size = 0; ASSERT_SUCCESS(urProgramGetInfo(program, UR_PROGRAM_INFO_BINARY_SIZES, sizeof(binary_size), &binary_size, diff --git a/test/conformance/program/urProgramGetBuildInfo.cpp b/test/conformance/program/urProgramGetBuildInfo.cpp index 02faebcfb0..81c2151bfe 100644 --- a/test/conformance/program/urProgramGetBuildInfo.cpp +++ b/test/conformance/program/urProgramGetBuildInfo.cpp @@ -10,7 +10,7 @@ struct urProgramGetBuildInfoTest void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE( urProgramTestWithParam::SetUp()); - ASSERT_SUCCESS(urProgramBuild(this->context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); } }; @@ -24,7 +24,7 @@ UUR_TEST_SUITE_P(urProgramGetBuildInfoTest, struct urProgramGetBuildInfoSingleTest : uur::urProgramTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urProgramTest::SetUp()); - ASSERT_SUCCESS(urProgramBuild(this->context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); } }; UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramGetBuildInfoSingleTest); diff --git a/test/conformance/program/urProgramGetFunctionPointer.cpp b/test/conformance/program/urProgramGetFunctionPointer.cpp index 00f5ad74e0..80430cc0f5 100644 --- a/test/conformance/program/urProgramGetFunctionPointer.cpp +++ b/test/conformance/program/urProgramGetFunctionPointer.cpp @@ -8,7 +8,7 @@ struct urProgramGetFunctionPointerTest : uur::urProgramTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urProgramTest::SetUp()); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); auto kernel_names = uur::KernelsEnvironment::instance->GetEntryPointNames( this->program_name); diff --git a/test/conformance/program/urProgramGetInfo.cpp b/test/conformance/program/urProgramGetInfo.cpp index c9cdb7b066..fc81d0214f 100644 --- a/test/conformance/program/urProgramGetInfo.cpp +++ b/test/conformance/program/urProgramGetInfo.cpp @@ -10,7 +10,7 @@ struct urProgramGetInfoTest : uur::urProgramTestWithParam { UUR_RETURN_ON_FATAL_FAILURE( urProgramTestWithParam::SetUp()); // Some queries need the program to be built. - ASSERT_SUCCESS(urProgramBuild(this->context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); } }; @@ -26,7 +26,7 @@ UUR_TEST_SUITE_P( struct urProgramGetInfoSingleTest : uur::urProgramTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urProgramTest::SetUp()); - ASSERT_SUCCESS(urProgramBuild(this->context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); } }; UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramGetInfoSingleTest); diff --git a/test/conformance/program/urProgramLink.cpp b/test/conformance/program/urProgramLink.cpp index e14c38d883..99977f8c3b 100644 --- a/test/conformance/program/urProgramLink.cpp +++ b/test/conformance/program/urProgramLink.cpp @@ -17,7 +17,7 @@ struct urProgramLinkTest : uur::urProgramTest { if (backend == UR_PLATFORM_BACKEND_HIP) { GTEST_SKIP(); } - ASSERT_SUCCESS(urProgramCompile(context, program, nullptr)); + ASSERT_SUCCESS(urProgramCompile(program, 1, &device, nullptr)); } void TearDown() override { @@ -56,7 +56,7 @@ struct urProgramLinkErrorTest : uur::urQueueTest { linker_error_program_name, il_binary)); ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram( platform, context, device, *il_binary, nullptr, &program)); - ASSERT_SUCCESS(urProgramCompile(context, program, nullptr)); + ASSERT_SUCCESS(urProgramCompile(program, 1, &device, nullptr)); } void TearDown() override { @@ -72,8 +72,8 @@ struct urProgramLinkErrorTest : uur::urQueueTest { UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramLinkErrorTest); TEST_P(urProgramLinkTest, Success) { - ASSERT_SUCCESS( - urProgramLink(context, 1, &program, nullptr, &linked_program)); + ASSERT_SUCCESS(urProgramLink(context, 1, &device, 1, &program, nullptr, + &linked_program)); ur_program_binary_type_t binary_type = UR_PROGRAM_BINARY_TYPE_NONE; ASSERT_SUCCESS(urProgramGetBuildInfo( linked_program, device, UR_PROGRAM_BUILD_INFO_BINARY_TYPE, @@ -82,40 +82,53 @@ TEST_P(urProgramLinkTest, Success) { } TEST_P(urProgramLinkTest, InvalidNullHandleContext) { - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urProgramLink(nullptr, 1, &program, nullptr, &linked_program)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urProgramLink(nullptr, 1, &device, 1, &program, nullptr, + &linked_program)); } TEST_P(urProgramLinkTest, InvalidNullPointerProgram) { - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, - urProgramLink(context, 1, &program, nullptr, nullptr)); + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_NULL_POINTER, + urProgramLink(context, 1, &device, 1, &program, nullptr, nullptr)); } TEST_P(urProgramLinkTest, InvalidNullPointerInputPrograms) { - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_POINTER, - urProgramLink(context, 1, nullptr, nullptr, &linked_program)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urProgramLink(context, 1, &device, 1, nullptr, nullptr, + &linked_program)); } TEST_P(urProgramLinkTest, InvalidSizeCount) { - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_SIZE, - urProgramLink(context, 0, &program, nullptr, &linked_program)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urProgramLink(context, 1, &device, 0, &program, nullptr, + &linked_program)); +} + +TEST_P(urProgramLinkTest, InvalidSizeNumDevices) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urProgramLink(context, 0, &device, 1, &program, nullptr, + &linked_program)); +} + +TEST_P(urProgramLinkTest, InvalidNullPointerDevices) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urProgramLink(context, 1, nullptr, 1, &program, nullptr, + &linked_program)); } TEST_P(urProgramLinkErrorTest, LinkFailure) { - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_PROGRAM_LINK_FAILURE, - urProgramLink(context, 1, &program, nullptr, &linked_program)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_PROGRAM_LINK_FAILURE, + urProgramLink(context, 1, &device, 1, &program, nullptr, + &linked_program)); } TEST_P(urProgramLinkTest, SetOutputOnZeroCount) { uintptr_t invalid_pointer; linked_program = reinterpret_cast(&invalid_pointer); - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_SIZE, - urProgramLink(context, 0, &program, nullptr, &linked_program)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, + urProgramLink(context, 1, &device, 0, &program, nullptr, + &linked_program)); ASSERT_NE(linked_program, reinterpret_cast(&invalid_pointer)); } @@ -123,9 +136,9 @@ TEST_P(urProgramLinkTest, SetOutputOnZeroCount) { TEST_P(urProgramLinkErrorTest, SetOutputOnLinkError) { uintptr_t invalid_pointer; linked_program = reinterpret_cast(&invalid_pointer); - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_PROGRAM_LINK_FAILURE, - urProgramLink(context, 1, &program, nullptr, &linked_program)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_PROGRAM_LINK_FAILURE, + urProgramLink(context, 1, &device, 1, &program, nullptr, + &linked_program)); ASSERT_NE(linked_program, reinterpret_cast(&invalid_pointer)); } diff --git a/test/conformance/program/urProgramSetSpecializationConstants.cpp b/test/conformance/program/urProgramSetSpecializationConstants.cpp index 6d5b70322f..8cace68fb1 100644 --- a/test/conformance/program/urProgramSetSpecializationConstants.cpp +++ b/test/conformance/program/urProgramSetSpecializationConstants.cpp @@ -31,7 +31,7 @@ UUR_INSTANTIATE_KERNEL_TEST_SUITE_P( TEST_P(urProgramSetSpecializationConstantsTest, Success) { ASSERT_SUCCESS(urProgramSetSpecializationConstants(program, 1, &info)); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); auto entry_points = uur::KernelsEnvironment::instance->GetEntryPointNames(program_name); kernel_name = entry_points[0]; @@ -54,7 +54,7 @@ TEST_P(urProgramSetSpecializationConstantsTest, UseDefaultValue) { "AMD; not running."; } - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); auto entry_points = uur::KernelsEnvironment::instance->GetEntryPointNames(program_name); kernel_name = entry_points[0]; @@ -81,7 +81,7 @@ TEST_P(urProgramSetMultipleSpecializationConstantsTest, MultipleCalls) { ur_specialization_constant_info_t info_b = {1, sizeof(uint64_t), &b}; ASSERT_SUCCESS(urProgramSetSpecializationConstants(program, 1, &info_b)); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); auto entry_points = uur::KernelsEnvironment::instance->GetEntryPointNames(program_name); kernel_name = entry_points[0]; @@ -110,7 +110,7 @@ TEST_P(urProgramSetMultipleSpecializationConstantsTest, SingleCall) { }; ASSERT_SUCCESS(urProgramSetSpecializationConstants(program, 3, &info[0])); - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); auto entry_points = uur::KernelsEnvironment::instance->GetEntryPointNames(program_name); kernel_name = entry_points[0]; diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 0aeee2d909..d8064a99bf 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -1237,7 +1237,7 @@ struct urBaseKernelTest : urProgramTest { } void Build() { - ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); + ASSERT_SUCCESS(urProgramBuild(program, 1, &device, nullptr)); ASSERT_SUCCESS(urKernelCreate(program, kernel_name.data(), &kernel)); } @@ -1273,7 +1273,8 @@ struct urBaseKernelTestWithParam : urProgramTestWithParam { } void Build() { - ASSERT_SUCCESS(urProgramBuild(this->context, this->program, nullptr)); + ASSERT_SUCCESS( + urProgramBuild(this->program, 1, &this->device, nullptr)); ASSERT_SUCCESS( urKernelCreate(this->program, kernel_name.data(), &kernel)); } diff --git a/test/fuzz/urFuzz.cpp b/test/fuzz/urFuzz.cpp index c186d4bfcc..357f05665a 100644 --- a/test/fuzz/urFuzz.cpp +++ b/test/fuzz/urFuzz.cpp @@ -374,7 +374,7 @@ int ur_program_create_with_il(TestState &state) { urProgramCreateWithIL(context, il_bin.data(), il_bin.size(), nullptr, &program); - urProgramBuild(context, program, nullptr); + urProgramBuild(program, 1, &device, nullptr); ur_mem_handle_t memory_buffer; urMemBufferCreate(context, UR_MEM_FLAG_READ_WRITE, vec_size * sizeof(int),