diff --git a/include/ur_api.h b/include/ur_api.h index 19ba599c7d..908f780449 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -492,6 +492,7 @@ typedef enum ur_result_t { UR_RESULT_ERROR_ADAPTER_SPECIFIC = 67, ///< An adapter specific warning/error has been reported and can be ///< retrieved via the urPlatformGetLastError entry point. UR_RESULT_ERROR_LAYER_NOT_PRESENT = 68, ///< A requested layer was not found by the loader. + UR_RESULT_ERROR_INVALID_SPEC_ID = 69, ///< A specialization constant identifier is not valid. UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP = 0x1000, ///< Invalid Command-Buffer UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP = 0x1001, ///< Sync point is not valid for the command-buffer UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP = 0x1002, ///< Sync point wait list is invalid @@ -4534,6 +4535,11 @@ typedef struct ur_specialization_constant_info_t { /// + `NULL == pSpecConstants` /// - ::UR_RESULT_ERROR_INVALID_SIZE /// + `count == 0` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// + Any size specified in a pSpecConstant entry does not match the specialization constant in the module. +/// + Any pValue specified in a pSpecConstant entry is nullptr. +/// - ::UR_RESULT_ERROR_INVALID_SPEC_ID +/// + Any id specified in a pSpecConstant entry is not a valid specialization constant identifier. UR_APIEXPORT ur_result_t UR_APICALL urProgramSetSpecializationConstants( ur_program_handle_t hProgram, ///< [in] handle of the Program object @@ -5118,6 +5124,11 @@ urKernelSetArgMemObj( /// + `count == 0` /// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE /// + If ::UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS query is false +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// + Any size specified in a pSpecConstant entry does not match the specialization constant in the module. +/// + Any pValue specified in a pSpecConstant entry is nullptr. +/// - ::UR_RESULT_ERROR_INVALID_SPEC_ID +/// + Any id specified in a pSpecConstant entry is not a valid specialization constant identifier. UR_APIEXPORT ur_result_t UR_APICALL urKernelSetSpecializationConstants( ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object diff --git a/include/ur_print.hpp b/include/ur_print.hpp index 649f9f63cb..792d05e082 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -1539,6 +1539,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) { case UR_RESULT_ERROR_LAYER_NOT_PRESENT: os << "UR_RESULT_ERROR_LAYER_NOT_PRESENT"; break; + case UR_RESULT_ERROR_INVALID_SPEC_ID: + os << "UR_RESULT_ERROR_INVALID_SPEC_ID"; + break; case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP: os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP"; break; diff --git a/scripts/core/common.yml b/scripts/core/common.yml index 1825461b78..9629b4e549 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -274,6 +274,8 @@ etors: via the urPlatformGetLastError entry point." - name: ERROR_LAYER_NOT_PRESENT desc: "A requested layer was not found by the loader." + - name: ERROR_INVALID_SPEC_ID + desc: "A specialization constant identifier is not valid." - name: ERROR_UNKNOWN value: "0x7ffffffe" desc: "Unknown or internal error" diff --git a/scripts/core/kernel.yml b/scripts/core/kernel.yml index 4ce4f9c70a..10eec8ed56 100644 --- a/scripts/core/kernel.yml +++ b/scripts/core/kernel.yml @@ -465,6 +465,11 @@ returns: - "`count == 0`" - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: - "If $X_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS query is false" + - $X_RESULT_ERROR_INVALID_VALUE: + - "Any size specified in a pSpecConstant entry does not match the specialization constant in the module." + - "Any pValue specified in a pSpecConstant entry is nullptr." + - $X_RESULT_ERROR_INVALID_SPEC_ID: + - "Any id specified in a pSpecConstant entry is not a valid specialization constant identifier." --- #-------------------------------------------------------------------------- type: function desc: "Return platform native kernel handle." diff --git a/scripts/core/program.yml b/scripts/core/program.yml index 98dcc1d267..f8e78d1740 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -533,6 +533,11 @@ params: returns: - $X_RESULT_ERROR_INVALID_SIZE: - "`count == 0`" + - $X_RESULT_ERROR_INVALID_VALUE: + - "Any size specified in a pSpecConstant entry does not match the specialization constant in the module." + - "Any pValue specified in a pSpecConstant entry is nullptr." + - $X_RESULT_ERROR_INVALID_SPEC_ID: + - "Any id specified in a pSpecConstant entry is not a valid specialization constant identifier." --- #-------------------------------------------------------------------------- type: function desc: "Return program native program handle." diff --git a/source/adapters/opencl/common.cpp b/source/adapters/opencl/common.cpp index 4fe8bed408..e9b49c8279 100644 --- a/source/adapters/opencl/common.cpp +++ b/source/adapters/opencl/common.cpp @@ -81,6 +81,8 @@ ur_result_t mapCLErrorToUR(cl_int Result) { return UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP; case CL_INVALID_SYNC_POINT_WAIT_LIST_KHR: return UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP; + case CL_INVALID_SPEC_ID: + return UR_RESULT_ERROR_INVALID_SPEC_ID; default: return UR_RESULT_ERROR_UNKNOWN; } diff --git a/source/adapters/opencl/device.cpp b/source/adapters/opencl/device.cpp index 115b9b2e09..5fb48f1e2c 100644 --- a/source/adapters/opencl/device.cpp +++ b/source/adapters/opencl/device.cpp @@ -820,7 +820,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_COMPILER_AVAILABLE: case UR_DEVICE_INFO_LINKER_AVAILABLE: case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC: - case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: { /* CL type: cl_bool * UR type: ur_bool_t */ @@ -969,6 +968,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP: { return ReturnValue(false); } + case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: { + return ReturnValue(false); + } default: { return UR_RESULT_ERROR_INVALID_ENUMERATION; } diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 2165065097..6f33a11064 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -3402,6 +3402,11 @@ ur_result_t UR_APICALL urProgramGetBuildInfo( /// + `NULL == pSpecConstants` /// - ::UR_RESULT_ERROR_INVALID_SIZE /// + `count == 0` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// + Any size specified in a pSpecConstant entry does not match the specialization constant in the module. +/// + Any pValue specified in a pSpecConstant entry is nullptr. +/// - ::UR_RESULT_ERROR_INVALID_SPEC_ID +/// + Any id specified in a pSpecConstant entry is not a valid specialization constant identifier. ur_result_t UR_APICALL urProgramSetSpecializationConstants( ur_program_handle_t hProgram, ///< [in] handle of the Program object uint32_t count, ///< [in] the number of elements in the pSpecConstants array @@ -3987,6 +3992,11 @@ ur_result_t UR_APICALL urKernelSetArgMemObj( /// + `count == 0` /// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE /// + If ::UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS query is false +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// + Any size specified in a pSpecConstant entry does not match the specialization constant in the module. +/// + Any pValue specified in a pSpecConstant entry is nullptr. +/// - ::UR_RESULT_ERROR_INVALID_SPEC_ID +/// + Any id specified in a pSpecConstant entry is not a valid specialization constant identifier. ur_result_t UR_APICALL urKernelSetSpecializationConstants( ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object uint32_t count, ///< [in] the number of elements in the pSpecConstants array diff --git a/source/ur_api.cpp b/source/ur_api.cpp index cbc51a437e..1b7884084b 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -2897,6 +2897,11 @@ ur_result_t UR_APICALL urProgramGetBuildInfo( /// + `NULL == pSpecConstants` /// - ::UR_RESULT_ERROR_INVALID_SIZE /// + `count == 0` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// + Any size specified in a pSpecConstant entry does not match the specialization constant in the module. +/// + Any pValue specified in a pSpecConstant entry is nullptr. +/// - ::UR_RESULT_ERROR_INVALID_SPEC_ID +/// + Any id specified in a pSpecConstant entry is not a valid specialization constant identifier. ur_result_t UR_APICALL urProgramSetSpecializationConstants( ur_program_handle_t hProgram, ///< [in] handle of the Program object uint32_t count, ///< [in] the number of elements in the pSpecConstants array @@ -3385,6 +3390,11 @@ ur_result_t UR_APICALL urKernelSetArgMemObj( /// + `count == 0` /// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE /// + If ::UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS query is false +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// + Any size specified in a pSpecConstant entry does not match the specialization constant in the module. +/// + Any pValue specified in a pSpecConstant entry is nullptr. +/// - ::UR_RESULT_ERROR_INVALID_SPEC_ID +/// + Any id specified in a pSpecConstant entry is not a valid specialization constant identifier. ur_result_t UR_APICALL urKernelSetSpecializationConstants( ur_kernel_handle_t hKernel, ///< [in] handle of the kernel object uint32_t count, ///< [in] the number of elements in the pSpecConstants array diff --git a/test/conformance/kernel/urKernelSetSpecializationConstants.cpp b/test/conformance/kernel/urKernelSetSpecializationConstants.cpp index 665a20de4a..480eab8e4f 100644 --- a/test/conformance/kernel/urKernelSetSpecializationConstants.cpp +++ b/test/conformance/kernel/urKernelSetSpecializationConstants.cpp @@ -51,3 +51,23 @@ TEST_P(urKernelSetSpecializationConstantsTest, InvalidSizeCount) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, urKernelSetSpecializationConstants(kernel, 0, &info)); } + +TEST_P(urKernelSetSpecializationConstantsTest, InvalidValueSize) { + ur_specialization_constant_info_t bad_info = {0, 0x1000, &spec_value}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_VALUE, + urKernelSetSpecializationConstants(kernel, 1, &bad_info)); +} + +TEST_P(urKernelSetSpecializationConstantsTest, InvalidValueId) { + ur_specialization_constant_info_t bad_info = {999, sizeof(spec_value), + &spec_value}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SPEC_ID, + urKernelSetSpecializationConstants(kernel, 1, &bad_info)); +} + +TEST_P(urKernelSetSpecializationConstantsTest, InvalidValuePtr) { + ur_specialization_constant_info_t bad_info = {0, sizeof(spec_value), + nullptr}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_VALUE, + urKernelSetSpecializationConstants(kernel, 1, &bad_info)); +} diff --git a/test/conformance/program/urProgramSetSpecializationConstants.cpp b/test/conformance/program/urProgramSetSpecializationConstants.cpp index 4149711889..2f43b3974c 100644 --- a/test/conformance/program/urProgramSetSpecializationConstants.cpp +++ b/test/conformance/program/urProgramSetSpecializationConstants.cpp @@ -46,3 +46,26 @@ TEST_P(urProgramSetSpecializationConstantsTest, InvalidSizeCount) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, urProgramSetSpecializationConstants(program, 0, &info)); } + +TEST_P(urProgramSetSpecializationConstantsTest, InvalidValueSize) { + ur_specialization_constant_info_t bad_info = {0, 0x1000, &spec_value}; + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_VALUE, + urProgramSetSpecializationConstants(program, 1, &bad_info)); +} + +TEST_P(urProgramSetSpecializationConstantsTest, InvalidValueId) { + ur_specialization_constant_info_t bad_info = {999, sizeof(spec_value), + &spec_value}; + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_SPEC_ID, + urProgramSetSpecializationConstants(program, 1, &bad_info)); +} + +TEST_P(urProgramSetSpecializationConstantsTest, InvalidValuePtr) { + ur_specialization_constant_info_t bad_info = {0, sizeof(spec_value), + nullptr}; + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_VALUE, + urProgramSetSpecializationConstants(program, 1, &bad_info)); +}