Skip to content

Commit bce0f24

Browse files
committed
[CTS] Don't use urProgramCreateWithIL on HIP adapter
Since 5dc6e46 CTS tests which execute kernels have been failing to create programs. This has been hidden due to the match files containing expected failures in combination with an bug in the match file script found while debugging #1029 check failures. This patch adds `uur::KernelsEnvironment::CreateProgram()` which automatically handles the differences between the HIP adapter and others. On the hip path `urProgramCreateWithIL` is not longer called because it is not supported by the adatper and `urProgramCreateWithBinary` is used instead. The non-HIP path continues to use `urProgramCreateWithIL`.
1 parent 95f9092 commit bce0f24

File tree

5 files changed

+59
-7
lines changed

5 files changed

+59
-7
lines changed

test/conformance/program/urProgramCreateWithIL.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
struct urProgramCreateWithILTest : uur::urContextTest {
99
void SetUp() override {
1010
UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp());
11+
// TODO: This should use a query for urProgramCreateWithIL support or
12+
// rely on UR_RESULT_ERROR_UNSUPPORTED_FEATURE being returned.
13+
ur_platform_backend_t backend;
14+
ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND,
15+
sizeof(ur_platform_backend_t),
16+
&backend, nullptr));
17+
if (backend == UR_PLATFORM_BACKEND_HIP) {
18+
GTEST_SKIP();
19+
}
1120
uur::KernelsEnvironment::instance->LoadSource("foo", 0, il_binary);
1221
}
1322

test/conformance/program/urProgramLink.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
struct urProgramLinkTest : uur::urProgramTest {
99
void SetUp() override {
1010
UUR_RETURN_ON_FATAL_FAILURE(urProgramTest::SetUp());
11+
// TODO: This should use a query for urProgramCreateWithIL support or
12+
// rely on UR_RESULT_ERROR_UNSUPPORTED_FEATURE being returned.
13+
ur_platform_backend_t backend;
14+
ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND,
15+
sizeof(ur_platform_backend_t),
16+
&backend, nullptr));
17+
if (backend == UR_PLATFORM_BACKEND_HIP) {
18+
GTEST_SKIP();
19+
}
1120
ASSERT_SUCCESS(urProgramCompile(context, program, nullptr));
1221
programs.push_back(program);
1322

test/conformance/source/environment.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,35 @@ void KernelsEnvironment::LoadSource(
477477
binary_out = binary_ptr;
478478
}
479479

480+
ur_result_t KernelsEnvironment::CreateProgram(ur_platform_handle_t hPlatform,
481+
ur_context_handle_t hContext,
482+
ur_device_handle_t hDevice,
483+
const std::vector<char> &binary,
484+
ur_program_handle_t *phProgram) {
485+
ur_platform_backend_t backend;
486+
if (auto error = urPlatformGetInfo(hPlatform, UR_PLATFORM_INFO_BACKEND,
487+
sizeof(ur_platform_backend_t), &backend,
488+
nullptr)) {
489+
return error;
490+
}
491+
if (backend == UR_PLATFORM_BACKEND_HIP) {
492+
// The HIP adapter does not support urProgramCreateWithIL so we need to
493+
// use urProgramCreateWithBinary instead.
494+
if (auto error = urProgramCreateWithBinary(
495+
hContext, hDevice, binary.size(),
496+
reinterpret_cast<const uint8_t *>(binary.data()), nullptr,
497+
phProgram)) {
498+
return error;
499+
}
500+
} else {
501+
if (auto error = urProgramCreateWithIL(
502+
hContext, binary.data(), binary.size(), nullptr, phProgram)) {
503+
return error;
504+
}
505+
}
506+
return UR_RESULT_SUCCESS;
507+
}
508+
480509
std::vector<std::string> KernelsEnvironment::GetEntryPointNames(
481510
[[maybe_unused]] std::string program_name) {
482511
std::vector<std::string> entry_points;

test/conformance/testing/include/uur/environment.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ struct KernelsEnvironment : DevicesEnvironment {
7575
void LoadSource(const std::string &kernel_name, uint32_t device_index,
7676
std::shared_ptr<std::vector<char>> &binary_out);
7777

78+
ur_result_t CreateProgram(ur_platform_handle_t hPlatform,
79+
ur_context_handle_t hContext,
80+
ur_device_handle_t hDevice,
81+
const std::vector<char> &binary,
82+
ur_program_handle_t *phProgram);
83+
7884
std::vector<std::string> GetEntryPointNames(std::string program);
7985

8086
static KernelsEnvironment *instance;

test/conformance/testing/include/uur/fixtures.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ struct urHostPipeTest : urQueueTest {
324324
void SetUp() override {
325325
UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::SetUp());
326326
uur::KernelsEnvironment::instance->LoadSource("foo", 0, il_binary);
327-
ASSERT_SUCCESS(urProgramCreateWithIL(
328-
context, il_binary->data(), il_binary->size(), nullptr, &program));
327+
ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
328+
platform, context, device, *il_binary, &program));
329329

330330
size_t size = 0;
331331
ASSERT_SUCCESS(urDeviceGetInfo(
@@ -1052,8 +1052,8 @@ struct urProgramTest : urQueueTest {
10521052
UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::SetUp());
10531053
uur::KernelsEnvironment::instance->LoadSource(program_name, 0,
10541054
il_binary);
1055-
ASSERT_SUCCESS(urProgramCreateWithIL(
1056-
context, il_binary->data(), il_binary->size(), nullptr, &program));
1055+
ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
1056+
platform, context, device, *il_binary, &program));
10571057
}
10581058

10591059
void TearDown() override {
@@ -1072,9 +1072,8 @@ template <class T> struct urProgramTestWithParam : urContextTestWithParam<T> {
10721072
void SetUp() override {
10731073
UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam<T>::SetUp());
10741074
uur::KernelsEnvironment::instance->LoadSource("foo", 0, il_binary);
1075-
ASSERT_SUCCESS(urProgramCreateWithIL(this->context, il_binary->data(),
1076-
il_binary->size(), nullptr,
1077-
&program));
1075+
ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
1076+
this->platform, this->context, this->device, *il_binary, &program));
10781077
}
10791078

10801079
void TearDown() override {

0 commit comments

Comments
 (0)