diff --git a/test/conformance/program/urProgramCreateWithIL.cpp b/test/conformance/program/urProgramCreateWithIL.cpp index 182d6ff34e..b439850bac 100644 --- a/test/conformance/program/urProgramCreateWithIL.cpp +++ b/test/conformance/program/urProgramCreateWithIL.cpp @@ -8,6 +8,15 @@ struct urProgramCreateWithILTest : uur::urContextTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); + // TODO: This should use a query for urProgramCreateWithIL support or + // rely on UR_RESULT_ERROR_UNSUPPORTED_FEATURE being returned. + ur_platform_backend_t backend; + ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND, + sizeof(ur_platform_backend_t), + &backend, nullptr)); + if (backend == UR_PLATFORM_BACKEND_HIP) { + GTEST_SKIP(); + } uur::KernelsEnvironment::instance->LoadSource("foo", 0, il_binary); } diff --git a/test/conformance/program/urProgramLink.cpp b/test/conformance/program/urProgramLink.cpp index 72e2678df1..ec2fb36073 100644 --- a/test/conformance/program/urProgramLink.cpp +++ b/test/conformance/program/urProgramLink.cpp @@ -8,6 +8,15 @@ struct urProgramLinkTest : uur::urProgramTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urProgramTest::SetUp()); + // TODO: This should use a query for urProgramCreateWithIL support or + // rely on UR_RESULT_ERROR_UNSUPPORTED_FEATURE being returned. + ur_platform_backend_t backend; + ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND, + sizeof(ur_platform_backend_t), + &backend, nullptr)); + if (backend == UR_PLATFORM_BACKEND_HIP) { + GTEST_SKIP(); + } ASSERT_SUCCESS(urProgramCompile(context, program, nullptr)); } diff --git a/test/conformance/source/environment.cpp b/test/conformance/source/environment.cpp index 11a8b501a8..f8f399b547 100644 --- a/test/conformance/source/environment.cpp +++ b/test/conformance/source/environment.cpp @@ -477,6 +477,35 @@ void KernelsEnvironment::LoadSource( binary_out = binary_ptr; } +ur_result_t KernelsEnvironment::CreateProgram(ur_platform_handle_t hPlatform, + ur_context_handle_t hContext, + ur_device_handle_t hDevice, + const std::vector &binary, + ur_program_handle_t *phProgram) { + ur_platform_backend_t backend; + if (auto error = urPlatformGetInfo(hPlatform, UR_PLATFORM_INFO_BACKEND, + sizeof(ur_platform_backend_t), &backend, + nullptr)) { + return error; + } + if (backend == UR_PLATFORM_BACKEND_HIP) { + // The HIP adapter does not support urProgramCreateWithIL so we need to + // use urProgramCreateWithBinary instead. + if (auto error = urProgramCreateWithBinary( + hContext, hDevice, binary.size(), + reinterpret_cast(binary.data()), nullptr, + phProgram)) { + return error; + } + } else { + if (auto error = urProgramCreateWithIL( + hContext, binary.data(), binary.size(), nullptr, phProgram)) { + return error; + } + } + return UR_RESULT_SUCCESS; +} + std::vector KernelsEnvironment::GetEntryPointNames( [[maybe_unused]] std::string program_name) { std::vector entry_points; diff --git a/test/conformance/testing/include/uur/environment.h b/test/conformance/testing/include/uur/environment.h index 551be76e17..cd2d72cfe4 100644 --- a/test/conformance/testing/include/uur/environment.h +++ b/test/conformance/testing/include/uur/environment.h @@ -75,6 +75,12 @@ struct KernelsEnvironment : DevicesEnvironment { void LoadSource(const std::string &kernel_name, uint32_t device_index, std::shared_ptr> &binary_out); + ur_result_t CreateProgram(ur_platform_handle_t hPlatform, + ur_context_handle_t hContext, + ur_device_handle_t hDevice, + const std::vector &binary, + ur_program_handle_t *phProgram); + std::vector GetEntryPointNames(std::string program); static KernelsEnvironment *instance; diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 2ede84d135..a3eb90cde9 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -324,8 +324,8 @@ struct urHostPipeTest : urQueueTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::SetUp()); uur::KernelsEnvironment::instance->LoadSource("foo", 0, il_binary); - ASSERT_SUCCESS(urProgramCreateWithIL( - context, il_binary->data(), il_binary->size(), nullptr, &program)); + ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram( + platform, context, device, *il_binary, &program)); size_t size = 0; ASSERT_SUCCESS(urDeviceGetInfo( @@ -1052,8 +1052,8 @@ struct urProgramTest : urQueueTest { UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::SetUp()); uur::KernelsEnvironment::instance->LoadSource(program_name, 0, il_binary); - ASSERT_SUCCESS(urProgramCreateWithIL( - context, il_binary->data(), il_binary->size(), nullptr, &program)); + ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram( + platform, context, device, *il_binary, &program)); } void TearDown() override { @@ -1072,9 +1072,8 @@ template struct urProgramTestWithParam : urContextTestWithParam { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); uur::KernelsEnvironment::instance->LoadSource("foo", 0, il_binary); - ASSERT_SUCCESS(urProgramCreateWithIL(this->context, il_binary->data(), - il_binary->size(), nullptr, - &program)); + ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram( + this->platform, this->context, this->device, *il_binary, &program)); } void TearDown() override {