Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CTS] Don't use urProgramCreateWithIL on HIP adapter #1184

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/conformance/program/urProgramCreateWithIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
kbenzie marked this conversation as resolved.
Show resolved Hide resolved
// 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);
}

Expand Down
9 changes: 9 additions & 0 deletions test/conformance/program/urProgramLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
programs.push_back(program);

Expand Down
29 changes: 29 additions & 0 deletions test/conformance/source/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char> &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<const uint8_t *>(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<std::string> KernelsEnvironment::GetEntryPointNames(
[[maybe_unused]] std::string program_name) {
std::vector<std::string> entry_points;
Expand Down
6 changes: 6 additions & 0 deletions test/conformance/testing/include/uur/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ struct KernelsEnvironment : DevicesEnvironment {
void LoadSource(const std::string &kernel_name, uint32_t device_index,
std::shared_ptr<std::vector<char>> &binary_out);

ur_result_t CreateProgram(ur_platform_handle_t hPlatform,
ur_context_handle_t hContext,
ur_device_handle_t hDevice,
const std::vector<char> &binary,
ur_program_handle_t *phProgram);

std::vector<std::string> GetEntryPointNames(std::string program);

static KernelsEnvironment *instance;
Expand Down
13 changes: 6 additions & 7 deletions test/conformance/testing/include/uur/fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 {
Expand All @@ -1072,9 +1072,8 @@ template <class T> struct urProgramTestWithParam : urContextTestWithParam<T> {
void SetUp() override {
UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam<T>::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 {
Expand Down