Skip to content

[UR] Improve testing for gfx1100 on OpenCL #17747

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

Merged
merged 1 commit into from
Apr 4, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE(urContextSetExtendedDeleterTest);

TEST_P(urContextSetExtendedDeleterTest, Success) {
UUR_KNOWN_FAILURE_ON(uur::LevelZero{}, uur::LevelZeroV2{}, uur::NativeCPU{});
// Segfault
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"gfx1100"});

bool called = false;
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void checkDevicesSupportSharedUSM(
uur::GetDeviceUSMSingleSharedSupport(device, shared_usm_single));
if (!shared_usm_single) {
GTEST_SKIP() << "Shared USM is not supported by the device.";
return;
}
}
}
Expand All @@ -31,7 +32,7 @@ struct urEnqueueEventsWaitMultiDeviceTest

UUR_RETURN_ON_FATAL_FAILURE(uur::urMultiQueueMultiDeviceTest<2>::SetUp());

checkDevicesSupportSharedUSM(devices);
UUR_RETURN_ON_FATAL_FAILURE(checkDevicesSupportSharedUSM(devices));

ptrs.resize(devices.size());
for (size_t i = 0; i < devices.size(); i++) {
Expand Down Expand Up @@ -129,7 +130,7 @@ struct urEnqueueEventsWaitMultiDeviceMTTest
UUR_RETURN_ON_FATAL_FAILURE(
uur::urMultiQueueMultiDeviceTestWithParam<8,
uur::BoolTestParam>::SetUp());
checkDevicesSupportSharedUSM(devices);
UUR_RETURN_ON_FATAL_FAILURE(checkDevicesSupportSharedUSM(devices));

ptrs.resize(devices.size());
for (size_t i = 0; i < devices.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,9 @@ struct urEnqueueKernelLaunchMultiDeviceTest

uur::KernelsEnvironment::instance->LoadSource("foo", platform, il_binary);

ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
platform, context, devices[0], *il_binary, nullptr, &program));
UUR_RETURN_ON_FATAL_FAILURE(
uur::KernelsEnvironment::instance->CreateProgram(
platform, context, devices[0], *il_binary, nullptr, &program));

ASSERT_SUCCESS(urProgramBuild(context, program, nullptr));
ASSERT_SUCCESS(urKernelCreate(program, kernelName.data(), &kernel));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ struct urMultiQueueLaunchMemcpyTest
metadatas.empty() ? nullptr : metadatas.data()};

uur::raii::Program program;
ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
platform, context, devices[i], *il_binary, &properties,
&programs[i]));
UUR_RETURN_ON_FATAL_FAILURE(
uur::KernelsEnvironment::instance->CreateProgram(
platform, context, devices[i], *il_binary, &properties,
&programs[i]));

UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
urProgramBuild(context, programs[i], nullptr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ struct TestKernel {
UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES, nullptr,
static_cast<uint32_t>(Metadatas.size()),
Metadatas.empty() ? nullptr : Metadatas.data()};
ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
Platform, Context, Device, *ILBinary, &Properties, &Program));
UUR_RETURN_ON_FATAL_FAILURE(
uur::KernelsEnvironment::instance->CreateProgram(
Platform, Context, Device, *ILBinary, &Properties, &Program));

auto KernelNames =
uur::KernelsEnvironment::instance->GetEntryPointNames(Name);
Expand Down
12 changes: 8 additions & 4 deletions unified-runtime/test/conformance/kernel/urKernelCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ TEST_P(urMultiDeviceKernelCreateTest, WithProgramBuild) {

const ur_program_properties_t properties = {
UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES, nullptr, 0, nullptr};
ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
platform, context, devices[i], *il_binary, &properties, program.ptr()));
UUR_RETURN_ON_FATAL_FAILURE(
uur::KernelsEnvironment::instance->CreateProgram(
platform, context, devices[i], *il_binary, &properties,
program.ptr()));

ASSERT_SUCCESS(urProgramBuild(context, program.get(), nullptr));
ASSERT_SUCCESS(
Expand Down Expand Up @@ -107,8 +109,10 @@ TEST_P(urMultiDeviceKernelCreateTest, WithProgramCompileAndLink) {

const ur_program_properties_t properties = {
UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES, nullptr, 0, nullptr};
ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
platform, context, devices[i], *il_binary, &properties, program.ptr()));
UUR_RETURN_ON_FATAL_FAILURE(
uur::KernelsEnvironment::instance->CreateProgram(
platform, context, devices[i], *il_binary, &properties,
program.ptr()));

ASSERT_SUCCESS(urProgramCompile(context, program.get(), nullptr));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ struct urMultiDeviceContextMemBufferTest : urMultiDeviceContextTest {
static_cast<uint32_t>(metadatas.size()),
metadatas.empty() ? nullptr : metadatas.data()};
for (auto i = 0u; i < num_devices; ++i) {
ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
platform, context, devices[i], *il_binary, &properties,
&programs[i]));
UUR_RETURN_ON_FATAL_FAILURE(
uur::KernelsEnvironment::instance->CreateProgram(
platform, context, devices[i], *il_binary, &properties,
&programs[i]));
ASSERT_SUCCESS(urProgramBuild(context, programs[i], nullptr));
auto kernel_names =
uur::KernelsEnvironment::instance->GetEntryPointNames(program_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ TEST_P(urMemBufferPartitionTest, InvalidBufferSize) {

TEST_P(urMemBufferPartitionTest, InvalidValueCreateType) {
UUR_KNOWN_FAILURE_ON(uur::LevelZero{}, uur::NativeCPU{});
// Seems to report "success"
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"gfx1100"});

// create a read only buffer
uur::raii::Mem ro_buffer = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ TEST_P(urMemImageCreateTestWithImageFormatParam, Success) {
UUR_KNOWN_FAILURE_ON(uur::NativeCPU{});
// See https://github.com/oneapi-src/unified-runtime/issues/2638
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) UHD Graphics 770"});
// Reports INVALID_IMAGE_FORMAT_DESCRIPTOR rather than
// UNSUPPORTED_IMAGE_FORMAT
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"gfx1100"});

ur_image_channel_order_t channel_order = std::get<1>(GetParam()).channelOrder;
ur_image_channel_type_t channel_type = std::get<1>(GetParam()).channelType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ struct urProgramCreateWithILTest : uur::urContextTest {
UUR_INSTANTIATE_DEVICE_TEST_SUITE(urProgramCreateWithILTest);

TEST_P(urProgramCreateWithILTest, Success) {
UUR_KNOWN_FAILURE_ON(uur::CUDA{});
UUR_KNOWN_FAILURE_ON(uur::CUDA{}, uur::OpenCL{"gfx1100"});

ur_program_handle_t program = nullptr;
ASSERT_SUCCESS(urProgramCreateWithIL(context, il_binary->data(),
il_binary->size(), nullptr, &program));
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urProgramCreateWithIL(
context, il_binary->data(), il_binary->size(), nullptr, &program));
ASSERT_NE(nullptr, program);
ASSERT_SUCCESS(urProgramRelease(program));
}

TEST_P(urProgramCreateWithILTest, SuccessWithProperties) {
UUR_KNOWN_FAILURE_ON(uur::CUDA{});
UUR_KNOWN_FAILURE_ON(uur::CUDA{}, uur::OpenCL{"gfx1100"});

std::string string = "test metadata";
ur_program_metadata_value_t md_value_string;
Expand Down Expand Up @@ -80,7 +80,7 @@ TEST_P(urProgramCreateWithILTest, SuccessWithProperties) {
static_cast<uint32_t>(metadatas.size()), metadatas.data()};

ur_program_handle_t program = nullptr;
ASSERT_SUCCESS(urProgramCreateWithIL(
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urProgramCreateWithIL(
context, il_binary->data(), il_binary->size(), &properties, &program));
ASSERT_NE(nullptr, program);
ASSERT_SUCCESS(urProgramRelease(program));
Expand Down Expand Up @@ -140,7 +140,8 @@ TEST_P(urProgramCreateWithILTest, InvalidBinary) {
auto result = urProgramCreateWithIL(context, &binary, 5, nullptr, &program);
// The driver is not required to reject the binary
ASSERT_TRUE(result == UR_RESULT_ERROR_INVALID_BINARY ||
result == UR_RESULT_SUCCESS);
result == UR_RESULT_SUCCESS ||
result == UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE);
}

TEST_P(urProgramCreateWithILTest, CompilerNotAvailable) {
Expand Down
5 changes: 3 additions & 2 deletions unified-runtime/test/conformance/program/urProgramLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ struct urProgramLinkErrorTest : uur::urQueueTest {
std::shared_ptr<std::vector<char>> il_binary{};
UUR_RETURN_ON_FATAL_FAILURE(uur::KernelsEnvironment::instance->LoadSource(
linker_error_program_name, platform, il_binary));
ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
platform, context, device, *il_binary, nullptr, &program));
UUR_RETURN_ON_FATAL_FAILURE(
uur::KernelsEnvironment::instance->CreateProgram(
platform, context, device, *il_binary, nullptr, &program));
ASSERT_SUCCESS(urProgramCompile(context, program, nullptr));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ TEST_P(urSamplerCreateTestWithParam, Success) {
const auto addr_mode = std::get<1>(param);
const auto filter_mode = std::get<2>(param);

if (normalized == false &&
(addr_mode == UR_SAMPLER_ADDRESSING_MODE_REPEAT ||
addr_mode == UR_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT)) {
// Invalid value
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"gfx1100"});
}

ur_sampler_desc_t sampler_desc{
UR_STRUCTURE_TYPE_SAMPLER_DESC, /* stype */
nullptr, /* pNext */
Expand Down
31 changes: 15 additions & 16 deletions unified-runtime/test/conformance/source/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "ur_api.h"
#include "ur_filesystem_resolved.hpp"
#include "uur/checks.h"
#include "uur/known_failure.h"

#ifdef KERNELS_ENVIRONMENT
#include "kernel_entry_points.h"
Expand Down Expand Up @@ -279,34 +280,32 @@ void KernelsEnvironment::LoadSource(
binary_out = std::move(binary_ptr);
}

ur_result_t KernelsEnvironment::CreateProgram(
void KernelsEnvironment::CreateProgram(
ur_platform_handle_t hPlatform, ur_context_handle_t hContext,
ur_device_handle_t hDevice, const std::vector<char> &binary,
const ur_program_properties_t *properties, ur_program_handle_t *phProgram) {
// Seems to not support an IR compiler
std::tuple<ur_platform_handle_t, ur_device_handle_t> tuple{hPlatform,
hDevice};
UUR_KNOWN_FAILURE_ON_PARAM(tuple, uur::OpenCL{"gfx1100"});

ur_platform_backend_t backend;
if (auto error =
urPlatformGetInfo(hPlatform, UR_PLATFORM_INFO_BACKEND,
sizeof(ur_platform_backend_t), &backend, nullptr)) {
return error;
}
ASSERT_SUCCESS(urPlatformGetInfo(hPlatform, UR_PLATFORM_INFO_BACKEND,
sizeof(ur_platform_backend_t), &backend,
nullptr));
if (backend == UR_PLATFORM_BACKEND_HIP ||
backend == UR_PLATFORM_BACKEND_CUDA) {
// The CUDA and HIP adapters do not support urProgramCreateWithIL so we
// need to use urProgramCreateWithBinary instead.
auto size = binary.size();
auto data = binary.data();
if (auto error = urProgramCreateWithBinary(
hContext, 1, &hDevice, &size,
reinterpret_cast<const uint8_t **>(&data), properties, phProgram)) {
return error;
}
ASSERT_SUCCESS(urProgramCreateWithBinary(
hContext, 1, &hDevice, &size, reinterpret_cast<const uint8_t **>(&data),
properties, phProgram));
} else {
if (auto error = urProgramCreateWithIL(
hContext, binary.data(), binary.size(), properties, phProgram)) {
return error;
}
ASSERT_SUCCESS(urProgramCreateWithIL(hContext, binary.data(), binary.size(),
properties, phProgram));
}
return UR_RESULT_SUCCESS;
}

std::vector<std::string> KernelsEnvironment::GetEntryPointNames(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ inline std::ostream &operator<<(std::ostream &out, const Result &result) {

#define UUR_RETURN_ON_FATAL_FAILURE(...) \
__VA_ARGS__; \
if (this->HasFatalFailure() || this->IsSkipped()) { \
if (::testing::Test::HasFatalFailure() || ::testing::Test::IsSkipped()) { \
return; \
} \
(void)0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ struct KernelsEnvironment : DevicesEnvironment {
void LoadSource(const std::string &kernel_name, ur_platform_handle_t platform,
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,
const ur_program_properties_t *properties,
ur_program_handle_t *phProgram);
void CreateProgram(ur_platform_handle_t hPlatform,
ur_context_handle_t hContext, ur_device_handle_t hDevice,
const std::vector<char> &binary,
const ur_program_properties_t *properties,
ur_program_handle_t *phProgram);

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

Expand Down
17 changes: 10 additions & 7 deletions unified-runtime/test/conformance/testing/include/uur/fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,9 @@ struct urHostPipeTest : urQueueTest {

UUR_RETURN_ON_FATAL_FAILURE(uur::KernelsEnvironment::instance->LoadSource(
"foo", platform, il_binary));
ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
platform, context, device, *il_binary, nullptr, &program));
UUR_RETURN_ON_FATAL_FAILURE(
uur::KernelsEnvironment::instance->CreateProgram(
platform, context, device, *il_binary, nullptr, &program));
}

void TearDown() override {
Expand Down Expand Up @@ -1233,8 +1234,9 @@ struct urProgramTest : urQueueTest {
UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES, nullptr,
static_cast<uint32_t>(metadatas.size()),
metadatas.empty() ? nullptr : metadatas.data()};
ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
platform, context, device, *il_binary, &properties, &program));
UUR_RETURN_ON_FATAL_FAILURE(
uur::KernelsEnvironment::instance->CreateProgram(
platform, context, device, *il_binary, &properties, &program));
}

void TearDown() override {
Expand Down Expand Up @@ -1273,9 +1275,10 @@ template <class T> struct urProgramTestWithParam : urQueueTestWithParam<T> {
static_cast<uint32_t>(metadatas.size()),
metadatas.empty() ? nullptr : metadatas.data()};

ASSERT_SUCCESS(uur::KernelsEnvironment::instance->CreateProgram(
this->platform, this->context, this->device, *il_binary, &properties,
&program));
UUR_RETURN_ON_FATAL_FAILURE(
uur::KernelsEnvironment::instance->CreateProgram(
this->platform, this->context, this->device, *il_binary,
&properties, &program));
}

void TearDown() override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ inline bool isKnownFailureOn(const DeviceTuple &param,
return false;
}

inline bool
isKnownFailureOn(std::tuple<ur_platform_handle_t, ur_device_handle_t> param,
const std::vector<Matcher> &matchers) {
ur_adapter_handle_t adapter = nullptr;
uur::GetPlatformInfo<ur_adapter_handle_t>(std::get<0>(param),
UR_PLATFORM_INFO_ADAPTER, adapter);
auto adapterInfo = detail::getAdapterInfo(adapter);
std::string name;
uur::GetDeviceInfo<std::string>(std::get<1>(param), UR_DEVICE_INFO_NAME,
name);
for (const auto &matcher : matchers) {
if (matcher.matches(adapterInfo, name)) {
return true;
}
}
return false;
}

template <class Param>
inline bool isKnownFailureOn(const std::tuple<DeviceTuple, Param> &param,
const std::vector<Matcher> &matchers) {
Expand Down Expand Up @@ -197,9 +215,9 @@ inline bool alsoRunKnownFailures() {
}
} // namespace uur

#define UUR_KNOWN_FAILURE_ON(...) \
if (uur::isKnownFailureOn(this->GetParam(), {__VA_ARGS__})) { \
auto message = uur::knownFailureMessage(this->GetParam()); \
#define UUR_KNOWN_FAILURE_ON_PARAM(param, ...) \
if (uur::isKnownFailureOn(param, {__VA_ARGS__})) { \
auto message = uur::knownFailureMessage(param); \
if (uur::alsoRunKnownFailures()) { \
std::cerr << message << "\n"; \
} else { \
Expand All @@ -208,4 +226,7 @@ inline bool alsoRunKnownFailures() {
} \
(void)0

#define UUR_KNOWN_FAILURE_ON(...) \
UUR_KNOWN_FAILURE_ON_PARAM(this->GetParam(), __VA_ARGS__)

#endif // UR_CONFORMANCE_INCLUDE_KNOWN_FAILURE_H_INCLUDED