From 3726312188ae447660c64c682c7ce8ab6ea1ddbd Mon Sep 17 00:00:00 2001 From: Ross Brunton Date: Fri, 22 Mar 2024 17:18:22 +0000 Subject: [PATCH] [Spec Constants] Improved handling of invalid/unsupported spec. constants Two main changes to how `Kernel/ProgramSetSpecializationConstants` are handled: * They may now output either `INVALID_VALUE` or the new `INVALID_SPEC_ID` when the provided list is invalid. * The OpenCL and level 0 adapters now respond to `UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS` with `false` rather than erroring out. This fixes some tests that were incorrectly not being skipped. * `urKernelSetSpecializationConstants` now "implemented" (as a function that returns `UNSUPPORTED_FEATURE` for opencl and cuda. --- include/ur_api.h | 11 +++++ include/ur_print.hpp | 3 ++ scripts/core/common.yml | 2 + scripts/core/kernel.yml | 5 ++ scripts/core/program.yml | 5 ++ source/adapters/cuda/kernel.cpp | 5 ++ source/adapters/cuda/ur_interface_loader.cpp | 2 +- source/adapters/level_zero/device.cpp | 2 + source/adapters/opencl/common.cpp | 2 + source/adapters/opencl/device.cpp | 4 +- source/adapters/opencl/kernel.cpp | 5 ++ .../adapters/opencl/ur_interface_loader.cpp | 2 +- source/loader/ur_libapi.cpp | 10 ++++ source/ur_api.cpp | 10 ++++ .../kernel/kernel_adapter_level_zero.match | 4 -- .../kernel/kernel_adapter_opencl.match | 4 -- .../urKernelSetSpecializationConstants.cpp | 47 +++++++++++++++++++ .../program/program_adapter_cuda.match | 3 ++ .../program/program_adapter_hip.match | 3 ++ .../urProgramSetSpecializationConstants.cpp | 23 +++++++++ 20 files changed, 141 insertions(+), 11 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index ce47d528aa..2b8bb7d052 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -493,6 +493,7 @@ typedef enum ur_result_t { ///< 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_IN_EVENT_LIST_EXEC_STATUS = 69, ///< An event in the provided wait list has ::UR_EVENT_STATUS_ERROR. + UR_RESULT_ERROR_INVALID_SPEC_ID = 70, ///< 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 @@ -4535,6 +4536,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 @@ -5119,6 +5125,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 b2ba6ddcab..d40b02bbc6 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -1542,6 +1542,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) { case UR_RESULT_ERROR_IN_EVENT_LIST_EXEC_STATUS: os << "UR_RESULT_ERROR_IN_EVENT_LIST_EXEC_STATUS"; 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 be95b9aa45..57cf4b3e20 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -276,6 +276,8 @@ etors: desc: "A requested layer was not found by the loader." - name: ERROR_IN_EVENT_LIST_EXEC_STATUS desc: "An event in the provided wait list has $X_EVENT_STATUS_ERROR." + - 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/cuda/kernel.cpp b/source/adapters/cuda/kernel.cpp index c9334add15..be13276959 100644 --- a/source/adapters/cuda/kernel.cpp +++ b/source/adapters/cuda/kernel.cpp @@ -377,3 +377,8 @@ urKernelSetArgSampler(ur_kernel_handle_t hKernel, uint32_t argIndex, } return Result; } + +UR_APIEXPORT ur_result_t UR_APICALL urKernelSetSpecializationConstants( + ur_kernel_handle_t, uint32_t, const ur_specialization_constant_info_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/source/adapters/cuda/ur_interface_loader.cpp b/source/adapters/cuda/ur_interface_loader.cpp index 2ffc0755ee..30bc125476 100644 --- a/source/adapters/cuda/ur_interface_loader.cpp +++ b/source/adapters/cuda/ur_interface_loader.cpp @@ -124,7 +124,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelProcAddrTable( pDdiTable->pfnSetArgSampler = urKernelSetArgSampler; pDdiTable->pfnSetArgValue = urKernelSetArgValue; pDdiTable->pfnSetExecInfo = urKernelSetExecInfo; - pDdiTable->pfnSetSpecializationConstants = nullptr; + pDdiTable->pfnSetSpecializationConstants = urKernelSetSpecializationConstants; return UR_RESULT_SUCCESS; } diff --git a/source/adapters/level_zero/device.cpp b/source/adapters/level_zero/device.cpp index f4d7f95e0b..4d9e45d9f7 100644 --- a/source/adapters/level_zero/device.cpp +++ b/source/adapters/level_zero/device.cpp @@ -839,6 +839,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( return ReturnValue(uint32_t{false}); case UR_DEVICE_INFO_IMAGE_SRGB: return ReturnValue(uint32_t{false}); + case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: + return ReturnValue(uint32_t{false}); case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: { diff --git a/source/adapters/opencl/common.cpp b/source/adapters/opencl/common.cpp index acce51939b..08906d96bd 100644 --- a/source/adapters/opencl/common.cpp +++ b/source/adapters/opencl/common.cpp @@ -83,6 +83,8 @@ ur_result_t mapCLErrorToUR(cl_int Result) { return UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP; case CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST: return UR_RESULT_ERROR_IN_EVENT_LIST_EXEC_STATUS; + 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/adapters/opencl/kernel.cpp b/source/adapters/opencl/kernel.cpp index 4fcbdeefa5..e474ddadd0 100644 --- a/source/adapters/opencl/kernel.cpp +++ b/source/adapters/opencl/kernel.cpp @@ -419,3 +419,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgSampler( CL_RETURN_ON_FAILURE(RetErr); return UR_RESULT_SUCCESS; } + +UR_APIEXPORT ur_result_t UR_APICALL urKernelSetSpecializationConstants( + ur_kernel_handle_t, uint32_t, const ur_specialization_constant_info_t *) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/source/adapters/opencl/ur_interface_loader.cpp b/source/adapters/opencl/ur_interface_loader.cpp index 8c2c73d7c8..9885566a8d 100644 --- a/source/adapters/opencl/ur_interface_loader.cpp +++ b/source/adapters/opencl/ur_interface_loader.cpp @@ -124,7 +124,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetKernelProcAddrTable( pDdiTable->pfnSetArgSampler = urKernelSetArgSampler; pDdiTable->pfnSetArgValue = urKernelSetArgValue; pDdiTable->pfnSetExecInfo = urKernelSetExecInfo; - pDdiTable->pfnSetSpecializationConstants = nullptr; + pDdiTable->pfnSetSpecializationConstants = urKernelSetSpecializationConstants; return UR_RESULT_SUCCESS; } diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index d5092ffe1c..a4355b9fdd 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 b65a2627fe..2178ca0dee 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/kernel_adapter_level_zero.match b/test/conformance/kernel/kernel_adapter_level_zero.match index 2668b6821a..00f7017d65 100644 --- a/test/conformance/kernel/kernel_adapter_level_zero.match +++ b/test/conformance/kernel/kernel_adapter_level_zero.match @@ -19,7 +19,3 @@ urKernelSetExecInfoTest.SuccessIndirectAccess/Intel_R__oneAPI_Unified_Runtime_ov urKernelSetExecInfoUSMPointersTest.SuccessHost/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urKernelSetExecInfoUSMPointersTest.SuccessDevice/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urKernelSetExecInfoUSMPointersTest.SuccessShared/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ -urKernelSetSpecializationConstantsTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ -urKernelSetSpecializationConstantsTest.InvalidNullHandleKernel/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ -urKernelSetSpecializationConstantsTest.InvalidNullPointerSpecConstants/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ -urKernelSetSpecializationConstantsTest.InvalidSizeCount/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ diff --git a/test/conformance/kernel/kernel_adapter_opencl.match b/test/conformance/kernel/kernel_adapter_opencl.match index 9a71945c45..7ece0484df 100644 --- a/test/conformance/kernel/kernel_adapter_opencl.match +++ b/test/conformance/kernel/kernel_adapter_opencl.match @@ -1,5 +1 @@ urKernelSetArgValueTest.InvalidKernelArgumentSize/Intel_R__OpenCL___{{.*}} -urKernelSetSpecializationConstantsTest.Success/Intel_R__OpenCL___{{.*}} -urKernelSetSpecializationConstantsTest.InvalidNullHandleKernel/Intel_R__OpenCL___{{.*}} -urKernelSetSpecializationConstantsTest.InvalidNullPointerSpecConstants/Intel_R__OpenCL___{{.*}} -urKernelSetSpecializationConstantsTest.InvalidSizeCount/Intel_R__OpenCL___{{.*}} diff --git a/test/conformance/kernel/urKernelSetSpecializationConstants.cpp b/test/conformance/kernel/urKernelSetSpecializationConstants.cpp index 665a20de4a..e12df68db0 100644 --- a/test/conformance/kernel/urKernelSetSpecializationConstants.cpp +++ b/test/conformance/kernel/urKernelSetSpecializationConstants.cpp @@ -27,6 +27,28 @@ struct urKernelSetSpecializationConstantsTest : uur::urBaseKernelExecutionTest { }; UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelSetSpecializationConstantsTest); +struct urKernelSetSpecializationConstantsNegativeTest + : uur::urBaseKernelExecutionTest { + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(urBaseKernelExecutionTest::SetUp()); + bool supports_kernel_spec_constant = false; + ASSERT_SUCCESS(urDeviceGetInfo( + device, UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS, + sizeof(supports_kernel_spec_constant), + &supports_kernel_spec_constant, nullptr)); + if (supports_kernel_spec_constant) { + GTEST_SKIP() << "Device supports setting kernel spec constants."; + } + Build(); + } + + uint32_t spec_value = 42; + ur_specialization_constant_info_t info = {0, sizeof(spec_value), + &spec_value}; +}; +UUR_INSTANTIATE_KERNEL_TEST_SUITE_P( + urKernelSetSpecializationConstantsNegativeTest); + TEST_P(urKernelSetSpecializationConstantsTest, Success) { ASSERT_SUCCESS(urKernelSetSpecializationConstants(kernel, 1, &info)); @@ -36,6 +58,11 @@ TEST_P(urKernelSetSpecializationConstantsTest, Success) { ValidateBuffer(buffer, sizeof(spec_value), spec_value); } +TEST_P(urKernelSetSpecializationConstantsNegativeTest, Unsupported) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_UNSUPPORTED_FEATURE, + urKernelSetSpecializationConstants(kernel, 1, &info)); +} + TEST_P(urKernelSetSpecializationConstantsTest, InvalidNullHandleKernel) { ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urKernelSetSpecializationConstants(nullptr, 1, &info)); @@ -51,3 +78,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/program_adapter_cuda.match b/test/conformance/program/program_adapter_cuda.match index 77f14ed0bb..602f872cf8 100644 --- a/test/conformance/program/program_adapter_cuda.match +++ b/test/conformance/program/program_adapter_cuda.match @@ -22,3 +22,6 @@ {{OPT}}urProgramGetInfoTest.InvalidNullHandleProgram/NVIDIA_CUDA_BACKEND___{{.*}}___UR_PROGRAM_INFO_KERNEL_NAMES {{OPT}}urProgramLinkTest.Success/NVIDIA_CUDA_BACKEND___{{.*}}_ {{OPT}}urProgramSetSpecializationConstantsTest.Success/NVIDIA_CUDA_BACKEND___{{.*}}_ +{{OPT}}urProgramSetSpecializationConstantsTest.InvalidValueSize/NVIDIA_CUDA_BACKEND___{{.*}}_ +{{OPT}}urProgramSetSpecializationConstantsTest.InvalidValueId/NVIDIA_CUDA_BACKEND___{{.*}}_ +{{OPT}}urProgramSetSpecializationConstantsTest.InvalidValuePtr/NVIDIA_CUDA_BACKEND___{{.*}}_ diff --git a/test/conformance/program/program_adapter_hip.match b/test/conformance/program/program_adapter_hip.match index 9aa6e56ef6..417c2aae71 100644 --- a/test/conformance/program/program_adapter_hip.match +++ b/test/conformance/program/program_adapter_hip.match @@ -22,4 +22,7 @@ {{OPT}}urProgramGetInfoTest.InvalidNullHandleProgram/AMD_HIP_BACKEND___{{.*}}___UR_PROGRAM_INFO_KERNEL_NAMES {{OPT}}urProgramLinkTest.Success/AMD_HIP_BACKEND___{{.*}}_ {{OPT}}urProgramSetSpecializationConstantsTest.Success/AMD_HIP_BACKEND___{{.*}}_ +{{OPT}}urProgramSetSpecializationConstantsTest.InvalidValueSize/AMD_HIP_BACKEND___{{.*}}_ +{{OPT}}urProgramSetSpecializationConstantsTest.InvalidValueId/AMD_HIP_BACKEND___{{.*}}_ +{{OPT}}urProgramSetSpecializationConstantsTest.InvalidValuePtr/AMD_HIP_BACKEND___{{.*}}_ {{OPT}}{{Segmentation fault|Aborted}} 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)); +}