From ba9d47499256a158d0056f1fb3d07edc2e19d259 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 a number of adapters. --- 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/native_cpu/kernel.cpp | 2 +- source/adapters/opencl/common.cpp | 2 + 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_v2.match | 5 ++ .../kernel/kernel_adapter_native_cpu.match | 4 ++ .../urKernelSetSpecializationConstants.cpp | 47 +++++++++++++++++++ .../program/program_adapter_cuda.match | 7 ++- .../program/program_adapter_hip.match | 4 ++ .../program/program_adapter_level_zero.match | 5 +- .../program_adapter_level_zero_v2.match | 4 ++ .../program/program_adapter_native_cpu.match | 3 ++ .../urProgramSetSpecializationConstants.cpp | 23 +++++++++ 22 files changed, 160 insertions(+), 6 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index cc693c50f6..13d6ca2608 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -502,6 +502,7 @@ typedef enum ur_result_t { UR_RESULT_ERROR_LAYER_NOT_PRESENT = 67, ///< A requested layer was not found by the loader. UR_RESULT_ERROR_IN_EVENT_LIST_EXEC_STATUS = 68, ///< An event in the provided wait list has ::UR_EVENT_STATUS_ERROR. UR_RESULT_ERROR_DEVICE_NOT_AVAILABLE = 69, ///< Device in question has `::UR_DEVICE_INFO_AVAILABLE == false` + 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 @@ -4640,6 +4641,11 @@ typedef struct ur_specialization_constant_info_t { /// + `NULL == pSpecConstants` /// - ::UR_RESULT_ERROR_INVALID_SIZE /// + `count == 0` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// + A pSpecConstant entry contains a size that does not match that of the specialization constant in the module. +/// + A pSpecConstant entry contains a nullptr pValue. +/// - ::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 @@ -5227,6 +5233,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 +/// + A pSpecConstant entry contains a size that does not match that of the specialization constant in the module. +/// + A pSpecConstant entry contains a nullptr pValue. +/// - ::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 9aeb5e3341..0a709eb0c0 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -1588,6 +1588,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) { case UR_RESULT_ERROR_DEVICE_NOT_AVAILABLE: os << "UR_RESULT_ERROR_DEVICE_NOT_AVAILABLE"; 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 d06333eb07..b4a1bf9963 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -276,6 +276,8 @@ etors: desc: "An event in the provided wait list has $X_EVENT_STATUS_ERROR." - name: ERROR_DEVICE_NOT_AVAILABLE desc: "Device in question has `$X_DEVICE_INFO_AVAILABLE == false`" + - 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 8585cffe6f..5118555737 100644 --- a/scripts/core/kernel.yml +++ b/scripts/core/kernel.yml @@ -467,6 +467,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: + - "A pSpecConstant entry contains a size that does not match that of the specialization constant in the module." + - "A pSpecConstant entry contains a nullptr pValue." + - $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 b7da9d62e7..e725b6339e 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -542,6 +542,11 @@ params: returns: - $X_RESULT_ERROR_INVALID_SIZE: - "`count == 0`" + - $X_RESULT_ERROR_INVALID_VALUE: + - "A pSpecConstant entry contains a size that does not match that of the specialization constant in the module." + - "A pSpecConstant entry contains a nullptr pValue." + - $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 d43bd046dc..714dae46a0 100644 --- a/source/adapters/cuda/kernel.cpp +++ b/source/adapters/cuda/kernel.cpp @@ -410,3 +410,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize( pSuggestedLocalWorkSize); 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 bb3fb9aee5..2bcf35c380 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; pDdiTable->pfnGetSuggestedLocalWorkSize = urKernelGetSuggestedLocalWorkSize; return UR_RESULT_SUCCESS; } diff --git a/source/adapters/native_cpu/kernel.cpp b/source/adapters/native_cpu/kernel.cpp index 23a65eb03b..3bb093bd7d 100644 --- a/source/adapters/native_cpu/kernel.cpp +++ b/source/adapters/native_cpu/kernel.cpp @@ -271,7 +271,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetSpecializationConstants( std::ignore = count; std::ignore = pSpecConstants; - DIE_NO_IMPLEMENTATION + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } UR_APIEXPORT ur_result_t UR_APICALL urKernelGetNativeHandle( diff --git a/source/adapters/opencl/common.cpp b/source/adapters/opencl/common.cpp index 03775fb87d..abdfba4753 100644 --- a/source/adapters/opencl/common.cpp +++ b/source/adapters/opencl/common.cpp @@ -95,6 +95,8 @@ ur_result_t mapCLErrorToUR(cl_int Result) { return UR_RESULT_ERROR_INVALID_QUEUE; case CL_INVALID_ARG_SIZE: return UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE; + case CL_INVALID_SPEC_ID: + return UR_RESULT_ERROR_INVALID_SPEC_ID; default: return UR_RESULT_ERROR_UNKNOWN; } diff --git a/source/adapters/opencl/kernel.cpp b/source/adapters/opencl/kernel.cpp index 9735abefbf..0348c60168 100644 --- a/source/adapters/opencl/kernel.cpp +++ b/source/adapters/opencl/kernel.cpp @@ -425,3 +425,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize( pGlobalWorkSize, pSuggestedLocalWorkSize)); 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 100bb888cf..cbdab6e003 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; pDdiTable->pfnGetSuggestedLocalWorkSize = urKernelGetSuggestedLocalWorkSize; return UR_RESULT_SUCCESS; } diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 05b0c71995..091120740b 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -3487,6 +3487,11 @@ ur_result_t UR_APICALL urProgramGetBuildInfo( /// + `NULL == pSpecConstants` /// - ::UR_RESULT_ERROR_INVALID_SIZE /// + `count == 0` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// + A pSpecConstant entry contains a size that does not match that of the specialization constant in the module. +/// + A pSpecConstant entry contains a nullptr pValue. +/// - ::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 @@ -4081,6 +4086,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 +/// + A pSpecConstant entry contains a size that does not match that of the specialization constant in the module. +/// + A pSpecConstant entry contains a nullptr pValue. +/// - ::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 a9f47a0c92..2229693843 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -2982,6 +2982,11 @@ ur_result_t UR_APICALL urProgramGetBuildInfo( /// + `NULL == pSpecConstants` /// - ::UR_RESULT_ERROR_INVALID_SIZE /// + `count == 0` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// + A pSpecConstant entry contains a size that does not match that of the specialization constant in the module. +/// + A pSpecConstant entry contains a nullptr pValue. +/// - ::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 @@ -3472,6 +3477,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 +/// + A pSpecConstant entry contains a size that does not match that of the specialization constant in the module. +/// + A pSpecConstant entry contains a nullptr pValue. +/// - ::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_v2.match b/test/conformance/kernel/kernel_adapter_level_zero_v2.match index dca885cc4d..c46f536b88 100644 --- a/test/conformance/kernel/kernel_adapter_level_zero_v2.match +++ b/test/conformance/kernel/kernel_adapter_level_zero_v2.match @@ -83,3 +83,8 @@ urKernelSetExecInfoUSMPointersTest.SuccessShared/Intel_R__oneAPI_Unified_Runtime urKernelSetExecInfoCacheConfigTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}____UR_KERNEL_CACHE_CONFIG_DEFAULT urKernelSetExecInfoCacheConfigTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}____UR_KERNEL_CACHE_CONFIG_LARGE_SLM urKernelSetExecInfoCacheConfigTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}____UR_KERNEL_CACHE_CONFIG_LARGE_DATA +urKernelSetSpecializationConstantsTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ +urKernelSetSpecializationConstantsTest.InvalidValueSize/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ +urKernelSetSpecializationConstantsTest.InvalidValueId/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ +urKernelSetSpecializationConstantsTest.InvalidValuePtr/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ +urKernelSetSpecializationConstantsNegativeTest.Unsupported/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ \ No newline at end of file diff --git a/test/conformance/kernel/kernel_adapter_native_cpu.match b/test/conformance/kernel/kernel_adapter_native_cpu.match index 4d3b506fcf..78f9dc9da1 100644 --- a/test/conformance/kernel/kernel_adapter_native_cpu.match +++ b/test/conformance/kernel/kernel_adapter_native_cpu.match @@ -161,6 +161,10 @@ urKernelSetSpecializationConstantsTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU urKernelSetSpecializationConstantsTest.InvalidNullHandleKernel/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} urKernelSetSpecializationConstantsTest.InvalidNullPointerSpecConstants/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} urKernelSetSpecializationConstantsTest.InvalidSizeCount/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +urKernelSetSpecializationConstantsTest.InvalidValueSize/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +urKernelSetSpecializationConstantsTest.InvalidValueId/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +urKernelSetSpecializationConstantsTest.InvalidValuePtr/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +urKernelSetSpecializationConstantsNegativeTest.Unsupported/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} urKernelGetSuggestedLocalWorkSizeTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} urKernelGetSuggestedLocalWorkSizeTest.Success2D/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} urKernelGetSuggestedLocalWorkSizeTest.Success3D/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} 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 5ffc32bb03..2035b26208 100644 --- a/test/conformance/program/program_adapter_cuda.match +++ b/test/conformance/program/program_adapter_cuda.match @@ -9,5 +9,8 @@ urProgramGetInfoTest.Success/NVIDIA_CUDA_BACKEND___{{.*}}___UR_PROGRAM_INFO_NUM_ urProgramGetInfoTest.Success/NVIDIA_CUDA_BACKEND___{{.*}}___UR_PROGRAM_INFO_KERNEL_NAMES {{OPT}}urProgramSetSpecializationConstantsTest.Success/NVIDIA_CUDA_BACKEND___{{.*}} {{OPT}}urProgramSetSpecializationConstantsTest.UseDefaultValue/NVIDIA_CUDA_BACKEND___{{.*}} -urProgramSetMultipleSpecializationConstantsTest.MultipleCalls/NVIDIA_CUDA_BACKEND___{{.*}} -urProgramSetMultipleSpecializationConstantsTest.SingleCall/NVIDIA_CUDA_BACKEND___{{.*}} +urProgramSetSpecializationConstantsTest.InvalidValueSize/NVIDIA_CUDA_BACKEND___{{.*}}_ +urProgramSetSpecializationConstantsTest.InvalidValueId/NVIDIA_CUDA_BACKEND___{{.*}}_ +urProgramSetSpecializationConstantsTest.InvalidValuePtr/NVIDIA_CUDA_BACKEND___{{.*}}_ +urProgramSetMultipleSpecializationConstantsTest.MultipleCalls/NVIDIA_CUDA_BACKEND___{{.*}}_ +urProgramSetMultipleSpecializationConstantsTest.SingleCall/NVIDIA_CUDA_BACKEND___{{.*}}_ diff --git a/test/conformance/program/program_adapter_hip.match b/test/conformance/program/program_adapter_hip.match index 183d88342d..072f508482 100644 --- a/test/conformance/program/program_adapter_hip.match +++ b/test/conformance/program/program_adapter_hip.match @@ -8,7 +8,11 @@ urProgramGetInfoTest.Success/AMD_HIP_BACKEND___{{.*}}___UR_PROGRAM_INFO_KERNEL_N # HIP hasn't implemented urProgramLink {{OPT}}urProgramLinkTest.Success/AMD_HIP_BACKEND___{{.*}}_ +# Hip doesn't support specialization constants urProgramSetSpecializationConstantsTest.Success/AMD_HIP_BACKEND___{{.*}}_ urProgramSetSpecializationConstantsTest.UseDefaultValue/AMD_HIP_BACKEND___{{.*}}_ +urProgramSetSpecializationConstantsTest.InvalidValueSize/AMD_HIP_BACKEND___{{.*}}_ +urProgramSetSpecializationConstantsTest.InvalidValueId/AMD_HIP_BACKEND___{{.*}}_ +urProgramSetSpecializationConstantsTest.InvalidValuePtr/AMD_HIP_BACKEND___{{.*}}_ urProgramSetMultipleSpecializationConstantsTest.MultipleCalls/AMD_HIP_BACKEND___{{.*}}_ urProgramSetMultipleSpecializationConstantsTest.SingleCall/AMD_HIP_BACKEND___{{.*}}_ diff --git a/test/conformance/program/program_adapter_level_zero.match b/test/conformance/program/program_adapter_level_zero.match index f8d65b426e..4bec341d11 100644 --- a/test/conformance/program/program_adapter_level_zero.match +++ b/test/conformance/program/program_adapter_level_zero.match @@ -5,4 +5,7 @@ urProgramGetBuildInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zer urProgramGetFunctionPointerTest.InvalidKernelName/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urProgramGetNativeHandleTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ {{OPT}}urProgramLinkErrorTest.LinkFailure/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ -{{OPT}}urProgramLinkErrorTest.SetOutputOnLinkError/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ \ No newline at end of file +{{OPT}}urProgramLinkErrorTest.SetOutputOnLinkError/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ +urProgramSetSpecializationConstantsTest.InvalidValueSize/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}} +urProgramSetSpecializationConstantsTest.InvalidValueId/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}} +urProgramSetSpecializationConstantsTest.InvalidValuePtr/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}} diff --git a/test/conformance/program/program_adapter_level_zero_v2.match b/test/conformance/program/program_adapter_level_zero_v2.match index 7c53e24502..ad80a2c8ac 100644 --- a/test/conformance/program/program_adapter_level_zero_v2.match +++ b/test/conformance/program/program_adapter_level_zero_v2.match @@ -8,5 +8,9 @@ urProgramGetNativeHandleTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_ {{OPT}}urProgramLinkErrorTest.SetOutputOnLinkError/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urProgramSetSpecializationConstantsTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}__ urProgramSetSpecializationConstantsTest.UseDefaultValue/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}__ +urProgramSetSpecializationConstantsTest.InvalidValueSize/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}} +urProgramSetSpecializationConstantsTest.InvalidValueId/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ +urProgramSetSpecializationConstantsTest.InvalidValuePtr/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ +urKernelSetSpecializationConstantsNegativeTest.Unsupported/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urProgramSetMultipleSpecializationConstantsTest.MultipleCalls/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}__ urProgramSetMultipleSpecializationConstantsTest.SingleCall/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}__ diff --git a/test/conformance/program/program_adapter_native_cpu.match b/test/conformance/program/program_adapter_native_cpu.match index cf3fa7062d..9e2587219d 100644 --- a/test/conformance/program/program_adapter_native_cpu.match +++ b/test/conformance/program/program_adapter_native_cpu.match @@ -139,6 +139,9 @@ {{OPT}}urProgramSetSpecializationConstantsTest.InvalidNullHandleProgram/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramSetSpecializationConstantsTest.InvalidNullPointerSpecConstants/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramSetSpecializationConstantsTest.InvalidSizeCount/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +{{OPT}}urProgramSetSpecializationConstantsTest.InvalidValueSize/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +{{OPT}}urProgramSetSpecializationConstantsTest.InvalidValueId/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} +{{OPT}}urProgramSetSpecializationConstantsTest.InvalidValuePtr/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramSetMultipleSpecializationConstantsTest.MultipleCalls/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}urProgramSetMultipleSpecializationConstantsTest.SingleCall/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}} {{OPT}}{{Segmentation fault|Aborted}} diff --git a/test/conformance/program/urProgramSetSpecializationConstants.cpp b/test/conformance/program/urProgramSetSpecializationConstants.cpp index 6d5b70322f..949c5c323e 100644 --- a/test/conformance/program/urProgramSetSpecializationConstants.cpp +++ b/test/conformance/program/urProgramSetSpecializationConstants.cpp @@ -141,3 +141,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)); +}