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

Parameterize CTS tests across all available adapters and devices. #2479

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7cbdc3f
Initial attempt at parameterizing the cts over all available devices.
aarongreig Nov 21, 2024
d257511
Merge pull request #2404 from kbenzie/benie/adapter-version-query
kbenzie Dec 3, 2024
e401010
Add CTS macro for marking tests as known failures in code
kbenzie Nov 27, 2024
35124e1
Fix MultiQueueMultiDevice param tests.
aarongreig Dec 12, 2024
31b21d4
Fix logic error in isKnownFailureOn.
aarongreig Dec 12, 2024
fe3bfec
Port match files to new KNOWN_FAIL macro
aarongreig Dec 13, 2024
c2cf1ff
Temporarily disable adapter specific tests in CI.
aarongreig Dec 18, 2024
f8fc0b3
Fix formatting + build.
aarongreig Dec 18, 2024
872ba82
Address some CI fails.
aarongreig Dec 18, 2024
4a8329c
Fix more CI fails.
aarongreig Dec 19, 2024
7275013
Rework kernel environment, hopefully fixing some of the flakiness.
aarongreig Dec 19, 2024
21d5b57
Re-enable adapter specific tests, add config specific KNOWN_FAILUREs
aarongreig Dec 20, 2024
aa1dff9
Fix urEnqueueKernelLaunchMultiDeviceTest.
aarongreig Dec 20, 2024
5fc0da5
Fix rebase.
aarongreig Dec 20, 2024
6a1d9ad
Clean up environment stuff.
aarongreig Dec 20, 2024
43ec7b2
Consolidate INSTANTIATE_KERNEL_TEST into INSTANTIATE_DEVICE_TEST.
aarongreig Dec 20, 2024
8714bd7
Go back and include all {{opt}} matches for native cpu + l0
aarongreig Dec 20, 2024
15e2f9b
Address some review feedback.
aarongreig Dec 20, 2024
b5fedb8
Use << operator directly on GTEST_SKIP() wherever possible.
aarongreig Dec 23, 2024
8fd67a0
Add missing known fail to urMultiDeviceCommandBufferExpTest.
aarongreig Dec 23, 2024
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
7 changes: 7 additions & 0 deletions scripts/core/INTRO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,13 @@ no valid platforms, then the tests will fail. Command line arguments take priori

A (case insensitive) backend to force the test to use. For example, `opencl`, `level_zero`, `hip` and so on.

.. envvar:: UR_CTS_ALSO_RUN_KNOWN_FAILURES

A boolean option to enable running tests which have been marked as known
failures using the :c:macro:`UUR_KNOWN_FAILURE_ON` macro. Enabled when the
environment variable is set to any of the following values: ``1``, ``on``,
``ON``, ``yes``, ``YES``, ``true``, ``TRUE``.

Service identifiers
---------------------

Expand Down
4 changes: 4 additions & 0 deletions source/adapters/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
return ReturnValue(ur_bool_t{false});
case UR_DEVICE_INFO_USM_POOL_SUPPORT:
#ifdef UMF_ENABLE_POOL_TRACKING
return ReturnValue(ur_bool_t{true});
#else
return ReturnValue(ur_bool_t{false});
#endif
case UR_DEVICE_INFO_BFLOAT16:
return ReturnValue(true);
case UR_DEVICE_INFO_ASYNC_BARRIER:
Expand Down
4 changes: 4 additions & 0 deletions source/adapters/native_cpu/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,

case UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP:
return ReturnValue(false);

case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES:
return ReturnValue(ur_queue_flags_t{0});

default:
DIE_NO_IMPLEMENTATION;
}
Expand Down
12 changes: 9 additions & 3 deletions test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

#include "fixtures.h"

using urCudaDeviceCreateWithNativeHandle = uur::urSelectedPlatformTest;
using urCudaDeviceCreateWithNativeHandle = uur::urPlatformTest;
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urCudaDeviceCreateWithNativeHandle);

TEST_F(urCudaDeviceCreateWithNativeHandle, Success) {
TEST_P(urCudaDeviceCreateWithNativeHandle, Success) {
// get a device from cuda
int nCudaDevices;
ASSERT_SUCCESS_CUDA(cuDeviceGetCount(&nCudaDevices));
Expand All @@ -16,7 +17,12 @@ TEST_F(urCudaDeviceCreateWithNativeHandle, Success) {
ASSERT_SUCCESS_CUDA(cuDeviceGet(&cudaDevice, 0));

ur_native_handle_t nativeCuda = static_cast<ur_native_handle_t>(cudaDevice);
ur_device_handle_t urDevice;

ur_adapter_handle_t adapter = nullptr;
ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_ADAPTER,
sizeof(adapter), &adapter, nullptr));

ur_device_handle_t urDevice = nullptr;
ASSERT_SUCCESS(urDeviceCreateWithNativeHandle(nativeCuda, adapter, nullptr,
&urDevice));
}
4 changes: 2 additions & 2 deletions test/adapters/level_zero/event_cache_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ TEST_P(urEventCacheTest, eventsReuseWithVisibleEventAndWait) {
template <typename T>
inline std::string
printFlags(const testing::TestParamInfo<typename T::ParamType> &info) {
const auto device_handle = std::get<0>(info.param);
const auto device_handle = std::get<0>(info.param).device;
const auto platform_device_name =
uur::GetPlatformAndDeviceName(device_handle);
auto flags = combineFlags(std::get<1>(info.param));
Expand All @@ -181,7 +181,7 @@ printFlags(const testing::TestParamInfo<typename T::ParamType> &info) {
return platform_device_name + "__" + str;
}

UUR_TEST_SUITE_P(
UUR_DEVICE_TEST_SUITE_P(
urEventCacheTest,
::testing::Combine(
testing::Values(0, UR_QUEUE_FLAG_DISCARD_EVENTS),
Expand Down
10 changes: 4 additions & 6 deletions test/adapters/level_zero/multi_device_event_cache_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
// See LICENSE.TXT
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "ur_print.hpp"
#include "uur/fixtures.h"
#include "uur/raii.h"

#include <map>
#include <string>

#include "ze_tracer_common.hpp"

size_t zeCommandListAppendWaitOnEventsCount = 0;
Expand All @@ -27,7 +23,9 @@ static std::shared_ptr<_zel_tracer_handle_t> tracer = [] {
}();

using urMultiQueueMultiDeviceEventCacheTest = uur::urAllDevicesTest;
TEST_F(urMultiQueueMultiDeviceEventCacheTest,
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urMultiQueueMultiDeviceEventCacheTest);

TEST_P(urMultiQueueMultiDeviceEventCacheTest,
GivenMultiSubDeviceWithQueuePerSubDeviceThenEventIsSharedBetweenQueues) {
uint32_t max_sub_devices = 0;
ASSERT_SUCCESS(
Expand Down Expand Up @@ -83,7 +81,7 @@ TEST_F(urMultiQueueMultiDeviceEventCacheTest,
ASSERT_SUCCESS(urQueueRelease(queue1));
}

TEST_F(urMultiQueueMultiDeviceEventCacheTest,
TEST_P(urMultiQueueMultiDeviceEventCacheTest,
GivenMultiDeviceWithQueuePerDeviceThenMultiDeviceEventIsCreated) {
if (devices.size() < 2) {
GTEST_SKIP();
Expand Down
4 changes: 2 additions & 2 deletions test/adapters/level_zero/urKernelCreateWithNativeHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TEST_P(urLevelZeroKernelNativeHandleTest, OwnedHandleRelease) {
urDeviceGetNativeHandle(device, (ur_native_handle_t *)&native_device);

std::shared_ptr<std::vector<char>> il_binary;
uur::KernelsEnvironment::instance->LoadSource("foo", il_binary);
uur::KernelsEnvironment::instance->LoadSource("foo", platform, il_binary);

auto kernel_name =
uur::KernelsEnvironment::instance->GetEntryPointNames("foo")[0];
Expand Down Expand Up @@ -79,7 +79,7 @@ TEST_P(urLevelZeroKernelNativeHandleTest, NullProgram) {
urDeviceGetNativeHandle(device, (ur_native_handle_t *)&native_device);

std::shared_ptr<std::vector<char>> il_binary;
uur::KernelsEnvironment::instance->LoadSource("foo", il_binary);
uur::KernelsEnvironment::instance->LoadSource("foo", platform, il_binary);

auto kernel_name =
uur::KernelsEnvironment::instance->GetEntryPointNames("foo")[0];
Expand Down
10 changes: 5 additions & 5 deletions test/adapters/level_zero/v2/event_pool_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct ProviderParams {
template <typename T>
inline std::string
printParams(const testing::TestParamInfo<typename T::ParamType> &info) {
const auto device_handle = std::get<0>(info.param);
const auto device_handle = std::get<0>(info.param).device;
const auto platform_device_name =
uur::GetPlatformAndDeviceName(device_handle);
auto params = std::get<1>(info.param);
Expand Down Expand Up @@ -144,8 +144,8 @@ static ProviderParams test_cases[] = {
//{TEST_PROVIDER_COUNTER, EVENT_COUNTER, QUEUE_IMMEDIATE},
};

UUR_TEST_SUITE_P(EventPoolTest, testing::ValuesIn(test_cases),
printParams<EventPoolTest>);
UUR_DEVICE_TEST_SUITE_P(EventPoolTest, testing::ValuesIn(test_cases),
printParams<EventPoolTest>);

TEST_P(EventPoolTest, InvalidDevice) {
auto pool = cache->borrow(MAX_DEVICES, getParam().flags);
Expand Down Expand Up @@ -237,8 +237,8 @@ TEST_P(EventPoolTest, ProviderNormalUseMostFreePool) {

using EventPoolTestWithQueue = uur::urQueueTestWithParam<ProviderParams>;

UUR_TEST_SUITE_P(EventPoolTestWithQueue, testing::ValuesIn(test_cases),
printParams<EventPoolTest>);
UUR_DEVICE_TEST_SUITE_P(EventPoolTestWithQueue, testing::ValuesIn(test_cases),
printParams<EventPoolTest>);

// TODO: actual min version is unknown, retest after drivers on CI are
// updated.
Expand Down
27 changes: 9 additions & 18 deletions test/adapters/level_zero/v2/memory_residency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,34 @@
// See LICENSE.TXT
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "ur_print.hpp"
#include "uur/fixtures.h"
#include "uur/raii.h"
#include "uur/utils.h"

#include <map>
#include <string>

using urMemoryResidencyTest = uur::urMultiDeviceContextTestTemplate<1>;
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urMemoryResidencyTest);

TEST_F(urMemoryResidencyTest, allocatingDeviceMemoryWillResultInOOM) {
TEST_P(urMemoryResidencyTest, allocatingDeviceMemoryWillResultInOOM) {
static constexpr size_t allocSize = 1024 * 1024;

if (!uur::isPVC(uur::DevicesEnvironment::instance->devices[0])) {
if (!uur::isPVC(devices[0])) {
GTEST_SKIP() << "Test requires a PVC device";
}

size_t initialMemFree = 0;
ASSERT_SUCCESS(
urDeviceGetInfo(uur::DevicesEnvironment::instance->devices[0],
UR_DEVICE_INFO_GLOBAL_MEM_FREE, sizeof(size_t),
&initialMemFree, nullptr));
ASSERT_SUCCESS(urDeviceGetInfo(devices[0], UR_DEVICE_INFO_GLOBAL_MEM_FREE,
sizeof(size_t), &initialMemFree, nullptr));

if (initialMemFree < allocSize) {
GTEST_SKIP() << "Not enough device memory available";
}

void *ptr = nullptr;
ASSERT_SUCCESS(
urUSMDeviceAlloc(context, uur::DevicesEnvironment::instance->devices[0],
nullptr, nullptr, allocSize, &ptr));
ASSERT_SUCCESS(urUSMDeviceAlloc(context, devices[0], nullptr, nullptr,
allocSize, &ptr));

size_t currentMemFree = 0;
ASSERT_SUCCESS(
urDeviceGetInfo(uur::DevicesEnvironment::instance->devices[0],
UR_DEVICE_INFO_GLOBAL_MEM_FREE, sizeof(size_t),
&currentMemFree, nullptr));
ASSERT_SUCCESS(urDeviceGetInfo(devices[0], UR_DEVICE_INFO_GLOBAL_MEM_FREE,
sizeof(size_t), &currentMemFree, nullptr));

// amount of free memory should decrease after making a memory allocation resident
ASSERT_LE(currentMemFree, initialMemFree);
Expand Down
30 changes: 9 additions & 21 deletions test/conformance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,12 @@ function(add_test_adapter name adapter backend)
set(MATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${name}_${adapter}.match")

function(do_add_test tname env)
if(${UR_CONFORMANCE_ENABLE_MATCH_FILES} AND EXISTS ${MATCH_FILE})
add_test(NAME ${tname}
COMMAND ${Python3_EXECUTABLE} ${UR_CONFORMANCE_TEST_DIR}/cts_exe.py
--failslist ${MATCH_FILE}
--test_command ${PROJECT_BINARY_DIR}/bin/${TEST_TARGET_NAME}
--
--backend=${backend}
--devices_count=${UR_TEST_DEVICES_COUNT}
--platforms_count=${UR_TEST_PLATFORMS_COUNT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
else()
separate_arguments(TEST_COMMAND)
add_test(NAME ${tname}
COMMAND ${TEST_COMMAND}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
separate_arguments(TEST_COMMAND)
add_test(NAME ${tname}
COMMAND ${TEST_COMMAND}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

if(UR_CONFORMANCE_ENABLE_MATCH_FILES)
list(APPEND env GTEST_COLOR=yes)
endif()
set_tests_properties(${tname} PROPERTIES
ENVIRONMENT "${env}"
LABELS "conformance;${adapter}")
Expand All @@ -67,6 +51,10 @@ function(add_conformance_test name)
GTest::gtest_main
unit_tests_helpers)

if(UR_USE_CFI)
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE UR_USE_CFI)
endif()

if(UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_ALL)
add_test_adapter(${name} adapter_cuda CUDA)
endif()
Expand Down
52 changes: 51 additions & 1 deletion test/conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,54 @@ all available devices/platforms, set 0. The default value is 1.
If you run binaries for the tests, you can use the parameter
`--platforms_count=COUNT` or `--devices_count=COUNT`.
To set test device/platform name you want to run the tests on, use
parameter `--platform=NAME` or `--device=NAME`.
parameter `--platform=NAME` or `--device=NAME`.

## Known failures

The `UUR_KNOWN_FAILURE_ON` macro can be used to skip tests on devices where the
test is known to fail. This can be done in the following situations.

For all devices in an adapter:

```cpp
UUR_KNOWN_FAILURE_ON(uur::LevelZero{});
```

By substring match of the device name within and adapter:

```cpp
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) UHD Graphics 770"});
```

In certain test suits, where there is no access to a device, the platform name
is used instead:

```cpp
UUR_KNOWN_FAILURE_ON(uur::CUDA{"NVIDIA CUDA BACKEND"});
```

When neither device or platform is available in a test suite, the name is
ignored and only the adapter backend is used to determine if the test is a
known failure.

The macro is variadic making it possible to specify known failures for multiple
adapters in a single place and multiple names can also be provided per adapter:

```cpp
UUR_KNOWN_FAILURE_ON(
uur::OpenCL{
"Intel(R) UHD Graphics 750",
"Intel(R) UHD Graphics 770",
},
uur::HIP{"Radeon RX 7700"},
uur::NativeCPU{});
```

The following adapter matcher objects are available:

* `uur::OpenCL`
* `uur::LevelZero`
* `uur::LevelZeroV2`
* `uur::CUDA`
* `uur::HIP`
* `uur::NativeCPU`
14 changes: 12 additions & 2 deletions test/conformance/adapter/urAdapterGetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ TEST_P(urAdapterGetInfoTest, Backend) {
size_t size = 0;
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
urAdapterGetInfo(adapter, info_type, 0, nullptr, &size), info_type);
ASSERT_NE(size, 0);

ASSERT_EQ(size, sizeof(ur_adapter_backend_t));

std::vector<char> info_data(size);
Expand All @@ -38,6 +36,18 @@ TEST_P(urAdapterGetInfoTest, ReferenceCount) {
ASSERT_GE(reference_count, 0);
}

TEST_P(urAdapterGetInfoTest, Version) {
auto info_type = UR_ADAPTER_INFO_VERSION;
size_t size = 0;
ASSERT_SUCCESS(urAdapterGetInfo(adapter, info_type, 0, nullptr, &size));
ASSERT_EQ(size, sizeof(uint32_t));

uint32_t version = 0;
ASSERT_SUCCESS(
urAdapterGetInfo(adapter, info_type, size, &version, nullptr));
ASSERT_GE(version, 1);
}

TEST_P(urAdapterGetInfoTest, InvalidNullHandleAdapter) {
size_t size = 0;
ASSERT_EQ_RESULT(
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 3 additions & 4 deletions test/conformance/context/urContextCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ TEST_P(urContextCreateTest, InvalidNullPointerDevices) {
}

TEST_P(urContextCreateTest, InvalidNullPointerContext) {
auto device = GetParam();
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
urContextCreate(1, &device, nullptr, nullptr));
}

TEST_P(urContextCreateTest, InvalidEnumeration) {
auto device = GetParam();

ur_context_properties_t properties{UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES,
nullptr, UR_CONTEXT_FLAGS_MASK};
uur::raii::Context context = nullptr;
Expand All @@ -48,7 +45,9 @@ TEST_P(urContextCreateTest, InvalidEnumeration) {
}

using urContextCreateMultiDeviceTest = uur::urAllDevicesTest;
TEST_F(urContextCreateMultiDeviceTest, Success) {
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urContextCreateMultiDeviceTest);

TEST_P(urContextCreateMultiDeviceTest, Success) {
if (devices.size() < 2) {
GTEST_SKIP();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See LICENSE.TXT
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "uur/environment.h"
#include <uur/fixtures.h>

using urContextCreateWithNativeHandleTest = uur::urContextTest;
Expand Down
Loading
Loading