-
Notifications
You must be signed in to change notification settings - Fork 125
Add CTS macro for marking tests as known failures in code #2392
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See LICENSE.TXT | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef UR_CONFORMANCE_INCLUDE_KNOWN_FAILURE_H_INCLUDED | ||
#define UR_CONFORMANCE_INCLUDE_KNOWN_FAILURE_H_INCLUDED | ||
|
||
#include "uur/utils.h" | ||
#include <string> | ||
#include <string_view> | ||
#include <vector> | ||
|
||
namespace uur { | ||
struct DeviceMatcher { | ||
DeviceMatcher(uint32_t adapterVersion, ur_platform_backend_t backend, | ||
std::vector<std::string> deviceNames) | ||
: adapterVersion(adapterVersion), backend(backend), | ||
deviceNames(deviceNames) {} | ||
|
||
uint32_t adapterVersion; | ||
ur_platform_backend_t backend; | ||
std::vector<std::string> deviceNames; | ||
}; | ||
|
||
struct OpenCL : DeviceMatcher { | ||
OpenCL(std::initializer_list<std::string> il) | ||
: DeviceMatcher(1, UR_PLATFORM_BACKEND_OPENCL, {il.begin(), il.end()}) { | ||
} | ||
}; | ||
|
||
struct LevelZero : DeviceMatcher { | ||
LevelZero(std::initializer_list<std::string> il) | ||
: DeviceMatcher(1, UR_PLATFORM_BACKEND_LEVEL_ZERO, | ||
{il.begin(), il.end()}) {} | ||
}; | ||
|
||
struct LevelZeroV2 : DeviceMatcher { | ||
LevelZeroV2(std::initializer_list<std::string> il) | ||
: DeviceMatcher(2, UR_PLATFORM_BACKEND_LEVEL_ZERO, | ||
{il.begin(), il.end()}) {} | ||
}; | ||
|
||
struct CUDA : DeviceMatcher { | ||
CUDA(std::initializer_list<std::string> il) | ||
: DeviceMatcher(1, UR_PLATFORM_BACKEND_CUDA, {il.begin(), il.end()}) {} | ||
}; | ||
|
||
struct HIP : DeviceMatcher { | ||
HIP(std::initializer_list<std::string> il) | ||
: DeviceMatcher(1, UR_PLATFORM_BACKEND_HIP, {il.begin(), il.end()}) {} | ||
}; | ||
|
||
struct NativeCPU : DeviceMatcher { | ||
NativeCPU(std::initializer_list<std::string> il) | ||
: DeviceMatcher(1, UR_PLATFORM_BACKEND_NATIVE_CPU, | ||
{il.begin(), il.end()}) {} | ||
}; | ||
|
||
inline bool isKnownFailureOn(ur_adapter_handle_t adapter, | ||
ur_platform_handle_t platform, | ||
ur_device_handle_t device, | ||
std::vector<DeviceMatcher> deviceMatchers) { | ||
for (const auto &deviceMatcher : deviceMatchers) { | ||
uint32_t adapterVersion = 0; | ||
urAdapterGetInfo(adapter, UR_ADAPTER_INFO_VERSION, | ||
sizeof(adapterVersion), &adapterVersion, nullptr); | ||
ur_platform_backend_t backend = UR_PLATFORM_BACKEND_UNKNOWN; | ||
uur::GetPlatformInfo<ur_platform_backend_t>( | ||
platform, UR_PLATFORM_INFO_BACKEND, backend); | ||
if (deviceMatcher.adapterVersion != adapterVersion && | ||
deviceMatcher.backend != backend) { | ||
continue; | ||
} | ||
if (deviceMatcher.deviceNames.empty()) { | ||
return true; | ||
} | ||
std::string deviceName; | ||
uur::GetDeviceInfo<std::string>(device, UR_DEVICE_INFO_NAME, | ||
deviceName); | ||
for (const auto &unsupportedDeviceName : deviceMatcher.deviceNames) { | ||
if (deviceName.find(unsupportedDeviceName) != std::string::npos) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
} // namespace uur | ||
|
||
#define UUR_KNOWN_FAILURE_ON(...) \ | ||
if (uur::isKnownFailureOn(adapter, platform, device, {__VA_ARGS__})) { \ | ||
using namespace std::literals; \ | ||
std::string platformName; \ | ||
uur::GetPlatformInfo<std::string>(platform, UR_PLATFORM_INFO_NAME, \ | ||
platformName); \ | ||
std::string deviceName; \ | ||
uur::GetDeviceInfo<std::string>(device, UR_DEVICE_INFO_NAME, \ | ||
deviceName); \ | ||
const char *alsoRunKnownFailures = \ | ||
std::getenv("UR_CTS_ALSO_RUN_KNOWN_FAILURES"); \ | ||
if (alsoRunKnownFailures && (alsoRunKnownFailures == "1"sv || \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could getting and checking the environment variable be done in a separate function? Just to avoid having a huge macro in each failing test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've done this in another branch which is based on top of the work to support multiple adapters/paltforms/devices at once. This work will likely get rolled into those changes. |
||
alsoRunKnownFailures == "yes"sv || \ | ||
alsoRunKnownFailures == "YES"sv || \ | ||
alsoRunKnownFailures == "on"sv || \ | ||
alsoRunKnownFailures == "ON"sv || \ | ||
alsoRunKnownFailures == "true"sv || \ | ||
alsoRunKnownFailures == "TRUE"sv)) { \ | ||
std::cerr << "Known failure on: " << platformName << ", " \ | ||
<< deviceName << "\n"; \ | ||
} else { \ | ||
GTEST_SKIP() << "Known failure on: " << platformName << ", " \ | ||
<< deviceName; \ | ||
} \ | ||
} | ||
|
||
#endif // UR_CONFORMANCE_INCLUDE_KNOWN_FAILURE_H_INCLUDED |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,12 +43,12 @@ ur_result_t GetInfo(ObjectTy object, InfoTy info, Callable cb, T &out_value) { | |
|
||
// special case for strings | ||
if constexpr (std::is_same_v<std::string, T>) { | ||
std::vector<char> data(size); | ||
result = cb(object, info, size, data.data(), nullptr); | ||
std::string value(size, '\0'); | ||
result = cb(object, info, size, value.data(), nullptr); | ||
if (result != UR_RESULT_SUCCESS) { | ||
return result; | ||
} | ||
out_value = std::string(data.data(), data.size()); | ||
out_value = value.substr(0, value.find_last_of('\0')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A malfunctioning adapter could return a string that isn't null terminated, resulting in a crash here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll chuck a |
||
return UR_RESULT_SUCCESS; | ||
} else { | ||
if (size != sizeof(T)) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.