diff --git a/include/ur_api.h b/include/ur_api.h index 442c364e0c..07185a834d 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -465,7 +465,8 @@ typedef enum ur_result_t { UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT = 56, ///< [Validation] image format is not supported by the device UR_RESULT_ERROR_INVALID_NATIVE_BINARY = 57, ///< [Validation] native binary is not supported by the device UR_RESULT_ERROR_INVALID_GLOBAL_NAME = 58, ///< [Validation] global variable is not found in the program - UR_RESULT_ERROR_INVALID_FUNCTION_NAME = 59, ///< [Validation] function name is not found in the program + UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE = 59, ///< [Validation] function name is in the program but its address could not + ///< be determined UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION = 60, ///< [Validation] group size dimension is not valid for the kernel or ///< device UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION = 61, ///< [Validation] global width dimension is not valid for the kernel or @@ -4233,8 +4234,8 @@ urProgramRelease( /// @details /// - Retrieves a pointer to the functions with the given name and defined /// in the given program. -/// - ::UR_RESULT_ERROR_INVALID_FUNCTION_NAME is returned if the function -/// can not be obtained. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE is returned if the +/// function can not be obtained. /// - The application may call this function from simultaneous threads for /// the same device. /// - The implementation of this function should be thread-safe. @@ -4254,6 +4255,10 @@ urProgramRelease( /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pFunctionName` /// + `NULL == ppFunctionPointer` +/// - ::UR_RESULT_ERROR_INVALID_KERNEL_NAME +/// + If `pFunctionName` couldn't be found in `hProgram`. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE +/// + If `pFunctionName` could be located, but its address couldn't be retrieved. UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( ur_device_handle_t hDevice, ///< [in] handle of the device to retrieve pointer for. diff --git a/include/ur_print.hpp b/include/ur_print.hpp index 6b27b2a443..56c901ecf1 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -1433,8 +1433,8 @@ inline std::ostream &operator<<(std::ostream &os, ur_result_t value) { case UR_RESULT_ERROR_INVALID_GLOBAL_NAME: os << "UR_RESULT_ERROR_INVALID_GLOBAL_NAME"; break; - case UR_RESULT_ERROR_INVALID_FUNCTION_NAME: - os << "UR_RESULT_ERROR_INVALID_FUNCTION_NAME"; + case UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE: + os << "UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE"; break; case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: os << "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; diff --git a/scripts/core/common.yml b/scripts/core/common.yml index f96f26a4cf..d0bc146a67 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -253,8 +253,8 @@ etors: desc: "[Validation] native binary is not supported by the device" - name: ERROR_INVALID_GLOBAL_NAME desc: "[Validation] global variable is not found in the program" - - name: ERROR_INVALID_FUNCTION_NAME - desc: "[Validation] function name is not found in the program" + - name: ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE + desc: "[Validation] function name is in the program but its address could not be determined" - name: ERROR_INVALID_GROUP_SIZE_DIMENSION desc: "[Validation] group size dimension is not valid for the kernel or device" - name: ERROR_INVALID_GLOBAL_WIDTH_DIMENSION diff --git a/scripts/core/program.yml b/scripts/core/program.yml index 88b652210b..55a2dcc3ad 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -288,7 +288,7 @@ analogue: - "**clGetDeviceFunctionPointerINTEL**" details: - "Retrieves a pointer to the functions with the given name and defined in the given program." - - "$X_RESULT_ERROR_INVALID_FUNCTION_NAME is returned if the function can not be obtained." + - "$X_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE is returned if the function can not be obtained." - "The application may call this function from simultaneous threads for the same device." - "The implementation of this function should be thread-safe." params: @@ -310,6 +310,11 @@ params: name: ppFunctionPointer desc: | [out] Returns the pointer to the function if it is found in the program. +returns: + - $X_RESULT_ERROR_INVALID_KERNEL_NAME: + - "If `pFunctionName` couldn't be found in `hProgram`." + - $X_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE: + - "If `pFunctionName` could be located, but its address couldn't be retrieved." --- #-------------------------------------------------------------------------- type: enum desc: "Get Program object information" diff --git a/source/adapters/cuda/command_buffer.hpp b/source/adapters/cuda/command_buffer.hpp index 18264410c4..d2a912e798 100644 --- a/source/adapters/cuda/command_buffer.hpp +++ b/source/adapters/cuda/command_buffer.hpp @@ -135,8 +135,8 @@ static inline const char *getUrResultString(ur_result_t Result) { return "UR_RESULT_ERROR_INVALID_NATIVE_BINARY"; case UR_RESULT_ERROR_INVALID_GLOBAL_NAME: return "UR_RESULT_ERROR_INVALID_GLOBAL_NAME"; - case UR_RESULT_ERROR_INVALID_FUNCTION_NAME: - return "UR_RESULT_ERROR_INVALID_FUNCTION_NAME"; + case UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE: + return "UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE"; case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: return "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; case UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION: diff --git a/source/adapters/cuda/program.cpp b/source/adapters/cuda/program.cpp index 022fd258f7..9a0a736c11 100644 --- a/source/adapters/cuda/program.cpp +++ b/source/adapters/cuda/program.cpp @@ -484,7 +484,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( UR_CHECK_ERROR(Ret); if (Ret == CUDA_ERROR_NOT_FOUND) { *ppFunctionPointer = 0; - Result = UR_RESULT_ERROR_INVALID_FUNCTION_NAME; + Result = UR_RESULT_ERROR_INVALID_KERNEL_NAME; } return Result; diff --git a/source/adapters/hip/program.cpp b/source/adapters/hip/program.cpp index 81f1be1194..d995edc24a 100644 --- a/source/adapters/hip/program.cpp +++ b/source/adapters/hip/program.cpp @@ -490,7 +490,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( UR_CHECK_ERROR(Ret); if (Ret == hipErrorNotFound) { *ppFunctionPointer = 0; - Result = UR_RESULT_ERROR_INVALID_FUNCTION_NAME; + Result = UR_RESULT_ERROR_INVALID_KERNEL_NAME; } return Result; diff --git a/source/adapters/level_zero/common.cpp b/source/adapters/level_zero/common.cpp index 1d3c53ca3b..82c1425916 100644 --- a/source/adapters/level_zero/common.cpp +++ b/source/adapters/level_zero/common.cpp @@ -45,9 +45,8 @@ ur_result_t ze2urResult(ze_result_t ZeResult) { case ZE_RESULT_ERROR_INVALID_NATIVE_BINARY: return UR_RESULT_ERROR_INVALID_BINARY; case ZE_RESULT_ERROR_INVALID_KERNEL_NAME: - return UR_RESULT_ERROR_INVALID_KERNEL_NAME; case ZE_RESULT_ERROR_INVALID_FUNCTION_NAME: - return UR_RESULT_ERROR_INVALID_FUNCTION_NAME; + return UR_RESULT_ERROR_INVALID_KERNEL_NAME; case ZE_RESULT_ERROR_OVERLAPPING_REGIONS: return UR_RESULT_ERROR_INVALID_OPERATION; case ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: diff --git a/source/adapters/level_zero/common.hpp b/source/adapters/level_zero/common.hpp index 5c363a5984..69b8524d4d 100644 --- a/source/adapters/level_zero/common.hpp +++ b/source/adapters/level_zero/common.hpp @@ -147,8 +147,8 @@ static auto getUrResultString = [](ur_result_t Result) { return "UR_RESULT_ERROR_INVALID_NATIVE_BINARY"; case UR_RESULT_ERROR_INVALID_GLOBAL_NAME: return "UR_RESULT_ERROR_INVALID_GLOBAL_NAME"; - case UR_RESULT_ERROR_INVALID_FUNCTION_NAME: - return "UR_RESULT_ERROR_INVALID_FUNCTION_NAME"; + case UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE: + return "UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE"; case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: return "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; case UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION: diff --git a/source/adapters/level_zero/program.cpp b/source/adapters/level_zero/program.cpp index 4c77d14f33..b6c5504ebd 100644 --- a/source/adapters/level_zero/program.cpp +++ b/source/adapters/level_zero/program.cpp @@ -568,7 +568,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( // exists ClResult.pop_back(); if (is_in_separated_string(ClResult, ';', std::string(FunctionName))) - return UR_RESULT_ERROR_INVALID_FUNCTION_NAME; + return UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE; return UR_RESULT_ERROR_INVALID_KERNEL_NAME; } diff --git a/source/adapters/native_cpu/kernel.cpp b/source/adapters/native_cpu/kernel.cpp index 5a7a286adc..7682eafa7f 100644 --- a/source/adapters/native_cpu/kernel.cpp +++ b/source/adapters/native_cpu/kernel.cpp @@ -87,7 +87,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetInfo(ur_kernel_handle_t hKernel, if (hKernel->_name) { return ReturnValue(hKernel->_name); } - return UR_RESULT_ERROR_INVALID_FUNCTION_NAME; + return UR_RESULT_ERROR_INVALID_KERNEL; // case UR_KERNEL_INFO_NUM_ARGS: // return ReturnValue(uint32_t{ Kernel->ZeKernelProperties->numKernelArgs // }); diff --git a/source/adapters/opencl/program.cpp b/source/adapters/opencl/program.cpp index f628c8152b..cf7388dd46 100644 --- a/source/adapters/opencl/program.cpp +++ b/source/adapters/opencl/program.cpp @@ -444,10 +444,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( CLContext, cl_ext::ExtFuncPtrCache->clGetDeviceFunctionPointerCache, cl_ext::GetDeviceFunctionPointerName, &FuncT)); - if (!FuncT) { - return UR_RESULT_ERROR_INVALID_FUNCTION_NAME; - } - // Check if the kernel name exists to prevent the OpenCL runtime from throwing // an exception with the cpu runtime. // TODO: Use fallback search method if the clGetDeviceFunctionPointerINTEL @@ -481,7 +477,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( // that the function name is invalid. if (CLResult == CL_INVALID_ARG_VALUE) { *ppFunctionPointer = 0; - return UR_RESULT_ERROR_INVALID_FUNCTION_NAME; + return UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE; } CL_RETURN_ON_FAILURE(CLResult); diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index cd4a70c91e..4ffc80e997 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -3141,8 +3141,8 @@ ur_result_t UR_APICALL urProgramRelease( /// @details /// - Retrieves a pointer to the functions with the given name and defined /// in the given program. -/// - ::UR_RESULT_ERROR_INVALID_FUNCTION_NAME is returned if the function -/// can not be obtained. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE is returned if the +/// function can not be obtained. /// - The application may call this function from simultaneous threads for /// the same device. /// - The implementation of this function should be thread-safe. @@ -3162,6 +3162,10 @@ ur_result_t UR_APICALL urProgramRelease( /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pFunctionName` /// + `NULL == ppFunctionPointer` +/// - ::UR_RESULT_ERROR_INVALID_KERNEL_NAME +/// + If `pFunctionName` couldn't be found in `hProgram`. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE +/// + If `pFunctionName` could be located, but its address couldn't be retrieved. ur_result_t UR_APICALL urProgramGetFunctionPointer( ur_device_handle_t hDevice, ///< [in] handle of the device to retrieve pointer for. diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 26f24aba08..9f6487485d 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -2668,8 +2668,8 @@ ur_result_t UR_APICALL urProgramRelease( /// @details /// - Retrieves a pointer to the functions with the given name and defined /// in the given program. -/// - ::UR_RESULT_ERROR_INVALID_FUNCTION_NAME is returned if the function -/// can not be obtained. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE is returned if the +/// function can not be obtained. /// - The application may call this function from simultaneous threads for /// the same device. /// - The implementation of this function should be thread-safe. @@ -2689,6 +2689,10 @@ ur_result_t UR_APICALL urProgramRelease( /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pFunctionName` /// + `NULL == ppFunctionPointer` +/// - ::UR_RESULT_ERROR_INVALID_KERNEL_NAME +/// + If `pFunctionName` couldn't be found in `hProgram`. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE +/// + If `pFunctionName` could be located, but its address couldn't be retrieved. ur_result_t UR_APICALL urProgramGetFunctionPointer( ur_device_handle_t hDevice, ///< [in] handle of the device to retrieve pointer for. diff --git a/test/conformance/program/program_adapter_level_zero.match b/test/conformance/program/program_adapter_level_zero.match index 5bbdfd554c..9e902dca94 100644 --- a/test/conformance/program/program_adapter_level_zero.match +++ b/test/conformance/program/program_adapter_level_zero.match @@ -2,5 +2,5 @@ urProgramCreateWithNativeHandleTest.Success/Intel_R__oneAPI_Unified_Runtime_over urProgramCreateWithNativeHandleTest.InvalidNullHandleContext/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urProgramCreateWithNativeHandleTest.InvalidNullPointerProgram/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urProgramGetBuildInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_UR_PROGRAM_BUILD_INFO_STATUS -urProgramGetFunctionPointerTest.InvalidFunctionName/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ +urProgramGetFunctionPointerTest.InvalidKernelName/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ Aborted diff --git a/test/conformance/program/program_adapter_opencl.match b/test/conformance/program/program_adapter_opencl.match index 0d429016ee..a644fbfbb0 100644 --- a/test/conformance/program/program_adapter_opencl.match +++ b/test/conformance/program/program_adapter_opencl.match @@ -1,3 +1,2 @@ -urProgramGetFunctionPointerTest.InvalidFunctionName/Intel_R__OpenCL___{{.*}}_ urProgramGetInfoTest.Success/Intel_R__OpenCL___{{.*}}___UR_PROGRAM_INFO_SOURCE urProgramGetInfoTest.Success/Intel_R__OpenCL___{{.*}}___UR_PROGRAM_INFO_BINARIES diff --git a/test/conformance/program/urProgramGetFunctionPointer.cpp b/test/conformance/program/urProgramGetFunctionPointer.cpp index 3eb00b991f..00f5ad74e0 100644 --- a/test/conformance/program/urProgramGetFunctionPointer.cpp +++ b/test/conformance/program/urProgramGetFunctionPointer.cpp @@ -26,10 +26,10 @@ TEST_P(urProgramGetFunctionPointerTest, Success) { ASSERT_NE(function_pointer, nullptr); } -TEST_P(urProgramGetFunctionPointerTest, InvalidFunctionName) { +TEST_P(urProgramGetFunctionPointerTest, InvalidKernelName) { void *function_pointer = nullptr; std::string missing_function = "aFakeFunctionName"; - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_FUNCTION_NAME, + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_KERNEL_NAME, urProgramGetFunctionPointer(device, program, missing_function.data(), &function_pointer));