diff --git a/include/ur_api.h b/include/ur_api.h index b1006853b1..79b732acdd 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -2984,6 +2984,7 @@ typedef struct ur_program_properties_t { /// + `NULL != pProperties && pProperties->count > 0 && NULL == pProperties->pMetadatas` /// - ::UR_RESULT_ERROR_INVALID_SIZE /// + `NULL != pProperties && NULL != pProperties->pMetadatas && pProperties->count == 0` +/// + `length == 0` /// - ::UR_RESULT_ERROR_INVALID_BINARY /// + If `pIL` is not a valid IL binary for devices in `hContext`. /// - ::UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE diff --git a/scripts/core/program.yml b/scripts/core/program.yml index 981fe18c33..99442df063 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -109,6 +109,8 @@ returns: - "If `pIL` is not a valid IL binary for devices in `hContext`." - $X_RESULT_ERROR_COMPILER_NOT_AVAILABLE: - "If devices in `hContext` don't have the capability to compile an IL binary at runtime." + - $X_RESULT_ERROR_INVALID_SIZE: + - "`length == 0`" --- #-------------------------------------------------------------------------- type: function desc: "Create a program object from device native binary." diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index e6f79c4410..fe9d22d3a7 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -1886,6 +1886,10 @@ __urdlllocal ur_result_t UR_APICALL urProgramCreateWithIL( pProperties->count == 0) { return UR_RESULT_ERROR_INVALID_SIZE; } + + if (length == 0) { + return UR_RESULT_ERROR_INVALID_SIZE; + } } ur_result_t result = diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index b0479f848f..5bbd16a6c2 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -2075,6 +2075,7 @@ ur_result_t UR_APICALL urUSMPoolGetInfo( /// + `NULL != pProperties && pProperties->count > 0 && NULL == pProperties->pMetadatas` /// - ::UR_RESULT_ERROR_INVALID_SIZE /// + `NULL != pProperties && NULL != pProperties->pMetadatas && pProperties->count == 0` +/// + `length == 0` /// - ::UR_RESULT_ERROR_INVALID_BINARY /// + If `pIL` is not a valid IL binary for devices in `hContext`. /// - ::UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 445fc19634..6584106e66 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -1737,6 +1737,7 @@ ur_result_t UR_APICALL urUSMPoolGetInfo( /// + `NULL != pProperties && pProperties->count > 0 && NULL == pProperties->pMetadatas` /// - ::UR_RESULT_ERROR_INVALID_SIZE /// + `NULL != pProperties && NULL != pProperties->pMetadatas && pProperties->count == 0` +/// + `length == 0` /// - ::UR_RESULT_ERROR_INVALID_BINARY /// + If `pIL` is not a valid IL binary for devices in `hContext`. /// - ::UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE diff --git a/test/conformance/kernel/urKernelCreate.cpp b/test/conformance/kernel/urKernelCreate.cpp index 70207ce82d..f89eb2a72a 100644 --- a/test/conformance/kernel/urKernelCreate.cpp +++ b/test/conformance/kernel/urKernelCreate.cpp @@ -47,7 +47,7 @@ TEST_P(urKernelCreateTest, InvalidNullPointerKernel) { } TEST_P(urKernelCreateTest, InvalidKernelName) { - std::string invalid_name = ""; + std::string invalid_name = "incorrect_kernel_name"; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_KERNEL_NAME, urKernelCreate(program, invalid_name.data(), &kernel)); } diff --git a/test/conformance/kernel/urKernelGetGroupInfo.cpp b/test/conformance/kernel/urKernelGetGroupInfo.cpp index 205c568198..7a6066b0b0 100644 --- a/test/conformance/kernel/urKernelGetGroupInfo.cpp +++ b/test/conformance/kernel/urKernelGetGroupInfo.cpp @@ -49,7 +49,7 @@ TEST_P(urKernelGetGroupInfoTest, InvalidNullHandleDevice) { TEST_P(urKernelGetGroupInfoTest, InvalidEnumeration) { size_t bad_enum_length = 0; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, - urKernelGetGroupInfo(nullptr, device, + urKernelGetGroupInfo(kernel, device, UR_KERNEL_GROUP_INFO_FORCE_UINT32, 0, nullptr, &bad_enum_length)); } diff --git a/test/conformance/kernel/urKernelGetSubGroupInfo.cpp b/test/conformance/kernel/urKernelGetSubGroupInfo.cpp index 8115b6864d..9a8e599510 100644 --- a/test/conformance/kernel/urKernelGetSubGroupInfo.cpp +++ b/test/conformance/kernel/urKernelGetSubGroupInfo.cpp @@ -50,6 +50,6 @@ TEST_P(urKernelGetSubGroupInfoTest, InvalidEnumeration) { size_t bad_enum_length = 0; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, urKernelGetSubGroupInfo( - nullptr, device, UR_KERNEL_SUB_GROUP_INFO_FORCE_UINT32, + kernel, device, UR_KERNEL_SUB_GROUP_INFO_FORCE_UINT32, 0, nullptr, &bad_enum_length)); } diff --git a/test/conformance/kernel/urKernelSetArgValue.cpp b/test/conformance/kernel/urKernelSetArgValue.cpp index f8cda4843c..cf0d22117a 100644 --- a/test/conformance/kernel/urKernelSetArgValue.cpp +++ b/test/conformance/kernel/urKernelSetArgValue.cpp @@ -28,7 +28,7 @@ TEST_P(urKernelSetArgValueTest, InvalidNullHandleKernel) { TEST_P(urKernelSetArgValueTest, InvalidNullPointerArgValue) { ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, + UR_RESULT_ERROR_INVALID_NULL_POINTER, urKernelSetArgValue(kernel, 2, sizeof(arg_value), nullptr)); } @@ -44,6 +44,6 @@ TEST_P(urKernelSetArgValueTest, InvalidKernelArgumentIndex) { } TEST_P(urKernelSetArgValueTest, InvalidKernelArgumentSize) { - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX, + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE, urKernelSetArgValue(kernel, 2, 0, &arg_value)); } diff --git a/test/conformance/kernel/urKernelSetExecInfo.cpp b/test/conformance/kernel/urKernelSetExecInfo.cpp index e3986893ce..cd7b6bd4cd 100644 --- a/test/conformance/kernel/urKernelSetExecInfo.cpp +++ b/test/conformance/kernel/urKernelSetExecInfo.cpp @@ -26,8 +26,8 @@ TEST_P(urKernelSetExecInfoTest, InvalidNullHandleKernel) { TEST_P(urKernelSetExecInfoTest, InvalidEnumeration) { bool property_value = false; ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urKernelSetExecInfo(nullptr, UR_KERNEL_EXEC_INFO_FORCE_UINT32, + UR_RESULT_ERROR_INVALID_ENUMERATION, + urKernelSetExecInfo(kernel, UR_KERNEL_EXEC_INFO_FORCE_UINT32, sizeof(property_value), &property_value)); } @@ -35,7 +35,7 @@ TEST_P(urKernelSetExecInfoTest, InvalidNullPointerPropValue) { bool property_value = false; ASSERT_EQ_RESULT( UR_RESULT_ERROR_INVALID_NULL_POINTER, - urKernelSetExecInfo(nullptr, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, + urKernelSetExecInfo(kernel, UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS, sizeof(property_value), nullptr)); } diff --git a/test/conformance/kernel/urKernelSetSpecializationConstants.cpp b/test/conformance/kernel/urKernelSetSpecializationConstants.cpp index dddfb15283..9b2bce7208 100644 --- a/test/conformance/kernel/urKernelSetSpecializationConstants.cpp +++ b/test/conformance/kernel/urKernelSetSpecializationConstants.cpp @@ -7,6 +7,8 @@ struct urKernelSetSpecializationConstantsTest : uur::urKernelExecutionTest { void SetUp() override { + program_name = "spec_constant"; + UUR_RETURN_ON_FATAL_FAILURE(urKernelExecutionTest::SetUp()); bool supports_kernel_spec_constant = false; ASSERT_SUCCESS(urDeviceGetInfo( device, UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS, @@ -16,8 +18,6 @@ struct urKernelSetSpecializationConstantsTest : uur::urKernelExecutionTest { GTEST_SKIP() << "Device does not support setting kernel spec constants."; } - program_name = "spec_constant"; - UUR_RETURN_ON_FATAL_FAILURE(urKernelExecutionTest::SetUp()); } uint32_t spec_value = 42; diff --git a/test/conformance/program/urProgramGetFunctionPointer.cpp b/test/conformance/program/urProgramGetFunctionPointer.cpp index 153df91d19..3eb00b991f 100644 --- a/test/conformance/program/urProgramGetFunctionPointer.cpp +++ b/test/conformance/program/urProgramGetFunctionPointer.cpp @@ -9,15 +9,10 @@ struct urProgramGetFunctionPointerTest : uur::urProgramTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urProgramTest::SetUp()); ASSERT_SUCCESS(urProgramBuild(context, program, nullptr)); - std::string kernel_list; - size_t kernel_list_size = 0; - ASSERT_SUCCESS(urProgramGetInfo(program, UR_PROGRAM_INFO_KERNEL_NAMES, - 0, nullptr, &kernel_list_size)); - kernel_list.resize(kernel_list_size); - ASSERT_SUCCESS(urProgramGetInfo(program, UR_PROGRAM_INFO_KERNEL_NAMES, - kernel_list_size, kernel_list.data(), - nullptr)); - function_name = kernel_list.substr(0, kernel_list.find(";")); + auto kernel_names = + uur::KernelsEnvironment::instance->GetEntryPointNames( + this->program_name); + function_name = kernel_names[0]; } std::string function_name; @@ -31,11 +26,13 @@ TEST_P(urProgramGetFunctionPointerTest, Success) { ASSERT_NE(function_pointer, nullptr); } -TEST_P(urProgramGetFunctionPointerTest, SuccessFunctionNotFound) { +TEST_P(urProgramGetFunctionPointerTest, InvalidFunctionName) { void *function_pointer = nullptr; std::string missing_function = "aFakeFunctionName"; - ASSERT_SUCCESS(urProgramGetFunctionPointer( - device, program, missing_function.data(), &function_pointer)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_FUNCTION_NAME, + urProgramGetFunctionPointer(device, program, + missing_function.data(), + &function_pointer)); ASSERT_EQ(function_pointer, nullptr); } diff --git a/test/conformance/program/urProgramLink.cpp b/test/conformance/program/urProgramLink.cpp index 355ae760cf..14bb9ef864 100644 --- a/test/conformance/program/urProgramLink.cpp +++ b/test/conformance/program/urProgramLink.cpp @@ -14,7 +14,7 @@ struct urProgramLinkTest : uur::urProgramTest { uur::KernelsEnvironment::instance->LoadSource("bar", 0, bar_binary); ASSERT_SUCCESS(urProgramCreateWithIL(context, bar_binary->data(), bar_binary->size(), nullptr, - &program)); + &bar_program)); ASSERT_SUCCESS(urProgramCompile(context, bar_program, nullptr)); programs.push_back(bar_program); } @@ -39,17 +39,10 @@ UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramLinkTest); TEST_P(urProgramLinkTest, Success) { ASSERT_SUCCESS(urProgramLink(context, programs.size(), programs.data(), nullptr, &linked_program)); - size_t original_kernel_count = 0; - ASSERT_SUCCESS(urProgramGetInfo(program, UR_PROGRAM_INFO_NUM_KERNELS, - sizeof(original_kernel_count), - &original_kernel_count, nullptr)); - - size_t linked_kernel_count = 0; - ASSERT_SUCCESS(urProgramGetInfo(linked_program, UR_PROGRAM_INFO_NUM_KERNELS, - sizeof(linked_kernel_count), - &linked_kernel_count, nullptr)); - - ASSERT_GT(linked_kernel_count, original_kernel_count); + ur_program_binary_type_t binary_type = UR_PROGRAM_BINARY_TYPE_NONE; + ASSERT_SUCCESS(urProgramGetBuildInfo( + program, device, UR_PROGRAM_BUILD_INFO_BINARY_TYPE, sizeof(binary_type), + &binary_type, nullptr)); } TEST_P(urProgramLinkTest, InvalidNullHandleContext) {