Skip to content

Commit 7c38c28

Browse files
committed
Merge branch 'main' into num_compute_units
2 parents e5b48ce + 0125279 commit 7c38c28

File tree

190 files changed

+2360
-2494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+2360
-2494
lines changed

scripts/core/INTRO.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,13 @@ no valid platforms, then the tests will fail. Command line arguments take priori
430430

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

433+
.. envvar:: UR_CTS_ALSO_RUN_KNOWN_FAILURES
434+
435+
A boolean option to enable running tests which have been marked as known
436+
failures using the :c:macro:`UUR_KNOWN_FAILURE_ON` macro. Enabled when the
437+
environment variable is set to any of the following values: ``1``, ``on``,
438+
``ON``, ``yes``, ``YES``, ``true``, ``TRUE``.
439+
433440
Service identifiers
434441
---------------------
435442

source/adapters/hip/device.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
904904
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
905905
return ReturnValue(ur_bool_t{false});
906906
case UR_DEVICE_INFO_USM_POOL_SUPPORT:
907+
#ifdef UMF_ENABLE_POOL_TRACKING
907908
return ReturnValue(ur_bool_t{true});
909+
#else
910+
return ReturnValue(ur_bool_t{false});
911+
#endif
908912
case UR_DEVICE_INFO_BFLOAT16:
909913
return ReturnValue(true);
910914
case UR_DEVICE_INFO_ASYNC_BARRIER:

test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
#include "fixtures.h"
77

8-
using urCudaDeviceCreateWithNativeHandle = uur::urSelectedPlatformTest;
8+
using urCudaDeviceCreateWithNativeHandle = uur::urPlatformTest;
9+
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urCudaDeviceCreateWithNativeHandle);
910

10-
TEST_F(urCudaDeviceCreateWithNativeHandle, Success) {
11+
TEST_P(urCudaDeviceCreateWithNativeHandle, Success) {
1112
// get a device from cuda
1213
int nCudaDevices;
1314
ASSERT_SUCCESS_CUDA(cuDeviceGetCount(&nCudaDevices));
@@ -16,7 +17,12 @@ TEST_F(urCudaDeviceCreateWithNativeHandle, Success) {
1617
ASSERT_SUCCESS_CUDA(cuDeviceGet(&cudaDevice, 0));
1718

1819
ur_native_handle_t nativeCuda = static_cast<ur_native_handle_t>(cudaDevice);
19-
ur_device_handle_t urDevice;
20+
21+
ur_adapter_handle_t adapter = nullptr;
22+
ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_ADAPTER,
23+
sizeof(adapter), &adapter, nullptr));
24+
25+
ur_device_handle_t urDevice = nullptr;
2026
ASSERT_SUCCESS(urDeviceCreateWithNativeHandle(nativeCuda, adapter, nullptr,
2127
&urDevice));
2228
}

test/adapters/level_zero/event_cache_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ TEST_P(urEventCacheTest, eventsReuseWithVisibleEventAndWait) {
167167
template <typename T>
168168
inline std::string
169169
printFlags(const testing::TestParamInfo<typename T::ParamType> &info) {
170-
const auto device_handle = std::get<0>(info.param);
170+
const auto device_handle = std::get<0>(info.param).device;
171171
const auto platform_device_name =
172172
uur::GetPlatformAndDeviceName(device_handle);
173173
auto flags = combineFlags(std::get<1>(info.param));
@@ -181,7 +181,7 @@ printFlags(const testing::TestParamInfo<typename T::ParamType> &info) {
181181
return platform_device_name + "__" + str;
182182
}
183183

184-
UUR_TEST_SUITE_P(
184+
UUR_DEVICE_TEST_SUITE_P(
185185
urEventCacheTest,
186186
::testing::Combine(
187187
testing::Values(0, UR_QUEUE_FLAG_DISCARD_EVENTS),

test/adapters/level_zero/multi_device_event_cache_tests.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
// See LICENSE.TXT
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6-
#include "ur_print.hpp"
76
#include "uur/fixtures.h"
87
#include "uur/raii.h"
98

10-
#include <map>
11-
#include <string>
12-
139
#include "ze_tracer_common.hpp"
1410

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

2925
using urMultiQueueMultiDeviceEventCacheTest = uur::urAllDevicesTest;
30-
TEST_F(urMultiQueueMultiDeviceEventCacheTest,
26+
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urMultiQueueMultiDeviceEventCacheTest);
27+
28+
TEST_P(urMultiQueueMultiDeviceEventCacheTest,
3129
GivenMultiSubDeviceWithQueuePerSubDeviceThenEventIsSharedBetweenQueues) {
3230
uint32_t max_sub_devices = 0;
3331
ASSERT_SUCCESS(
@@ -83,7 +81,7 @@ TEST_F(urMultiQueueMultiDeviceEventCacheTest,
8381
ASSERT_SUCCESS(urQueueRelease(queue1));
8482
}
8583

86-
TEST_F(urMultiQueueMultiDeviceEventCacheTest,
84+
TEST_P(urMultiQueueMultiDeviceEventCacheTest,
8785
GivenMultiDeviceWithQueuePerDeviceThenMultiDeviceEventIsCreated) {
8886
if (devices.size() < 2) {
8987
GTEST_SKIP();

test/adapters/level_zero/urKernelCreateWithNativeHandle.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ TEST_P(urLevelZeroKernelNativeHandleTest, OwnedHandleRelease) {
1919
urDeviceGetNativeHandle(device, (ur_native_handle_t *)&native_device);
2020

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

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

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

8484
auto kernel_name =
8585
uur::KernelsEnvironment::instance->GetEntryPointNames("foo")[0];

test/adapters/level_zero/v2/event_pool_test.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct ProviderParams {
8888
template <typename T>
8989
inline std::string
9090
printParams(const testing::TestParamInfo<typename T::ParamType> &info) {
91-
const auto device_handle = std::get<0>(info.param);
91+
const auto device_handle = std::get<0>(info.param).device;
9292
const auto platform_device_name =
9393
uur::GetPlatformAndDeviceName(device_handle);
9494
auto params = std::get<1>(info.param);
@@ -144,8 +144,8 @@ static ProviderParams test_cases[] = {
144144
//{TEST_PROVIDER_COUNTER, EVENT_COUNTER, QUEUE_IMMEDIATE},
145145
};
146146

147-
UUR_TEST_SUITE_P(EventPoolTest, testing::ValuesIn(test_cases),
148-
printParams<EventPoolTest>);
147+
UUR_DEVICE_TEST_SUITE_P(EventPoolTest, testing::ValuesIn(test_cases),
148+
printParams<EventPoolTest>);
149149

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

238238
using EventPoolTestWithQueue = uur::urQueueTestWithParam<ProviderParams>;
239239

240-
UUR_TEST_SUITE_P(EventPoolTestWithQueue, testing::ValuesIn(test_cases),
241-
printParams<EventPoolTest>);
240+
UUR_DEVICE_TEST_SUITE_P(EventPoolTestWithQueue, testing::ValuesIn(test_cases),
241+
printParams<EventPoolTest>);
242242

243243
// TODO: actual min version is unknown, retest after drivers on CI are
244244
// updated.

test/adapters/level_zero/v2/memory_residency.cpp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,34 @@
33
// See LICENSE.TXT
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6-
#include "ur_print.hpp"
76
#include "uur/fixtures.h"
8-
#include "uur/raii.h"
97
#include "uur/utils.h"
108

11-
#include <map>
12-
#include <string>
13-
149
using urMemoryResidencyTest = uur::urMultiDeviceContextTestTemplate<1>;
10+
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urMemoryResidencyTest);
1511

16-
TEST_F(urMemoryResidencyTest, allocatingDeviceMemoryWillResultInOOM) {
12+
TEST_P(urMemoryResidencyTest, allocatingDeviceMemoryWillResultInOOM) {
1713
static constexpr size_t allocSize = 1024 * 1024;
1814

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

2319
size_t initialMemFree = 0;
24-
ASSERT_SUCCESS(
25-
urDeviceGetInfo(uur::DevicesEnvironment::instance->devices[0],
26-
UR_DEVICE_INFO_GLOBAL_MEM_FREE, sizeof(size_t),
27-
&initialMemFree, nullptr));
20+
ASSERT_SUCCESS(urDeviceGetInfo(devices[0], UR_DEVICE_INFO_GLOBAL_MEM_FREE,
21+
sizeof(size_t), &initialMemFree, nullptr));
2822

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

3327
void *ptr = nullptr;
34-
ASSERT_SUCCESS(
35-
urUSMDeviceAlloc(context, uur::DevicesEnvironment::instance->devices[0],
36-
nullptr, nullptr, allocSize, &ptr));
28+
ASSERT_SUCCESS(urUSMDeviceAlloc(context, devices[0], nullptr, nullptr,
29+
allocSize, &ptr));
3730

3831
size_t currentMemFree = 0;
39-
ASSERT_SUCCESS(
40-
urDeviceGetInfo(uur::DevicesEnvironment::instance->devices[0],
41-
UR_DEVICE_INFO_GLOBAL_MEM_FREE, sizeof(size_t),
42-
&currentMemFree, nullptr));
32+
ASSERT_SUCCESS(urDeviceGetInfo(devices[0], UR_DEVICE_INFO_GLOBAL_MEM_FREE,
33+
sizeof(size_t), &currentMemFree, nullptr));
4334

4435
// amount of free memory should decrease after making a memory allocation resident
4536
ASSERT_LE(currentMemFree, initialMemFree);

test/conformance/CMakeLists.txt

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,16 @@ function(add_test_adapter name adapter backend)
1414
set(TEST_NAME ${name}-${adapter})
1515

1616
set(TEST_COMMAND
17-
"${PROJECT_BINARY_DIR}/bin/${TEST_TARGET_NAME} --backend=${backend} --devices_count=${UR_TEST_DEVICES_COUNT} --platforms_count=${UR_TEST_PLATFORMS_COUNT}"
17+
"${PROJECT_BINARY_DIR}/bin/${TEST_TARGET_NAME} --gtest_filter=*${backend}*"
1818
)
19-
set(MATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${name}_${adapter}.match")
2019

2120
function(do_add_test tname env)
22-
if(${UR_CONFORMANCE_ENABLE_MATCH_FILES} AND EXISTS ${MATCH_FILE})
23-
add_test(NAME ${tname}
24-
COMMAND ${Python3_EXECUTABLE} ${UR_CONFORMANCE_TEST_DIR}/cts_exe.py
25-
--failslist ${MATCH_FILE}
26-
--test_command ${PROJECT_BINARY_DIR}/bin/${TEST_TARGET_NAME}
27-
--
28-
--backend=${backend}
29-
--devices_count=${UR_TEST_DEVICES_COUNT}
30-
--platforms_count=${UR_TEST_PLATFORMS_COUNT}
31-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
32-
)
33-
else()
34-
separate_arguments(TEST_COMMAND)
35-
add_test(NAME ${tname}
36-
COMMAND ${TEST_COMMAND}
37-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
38-
)
39-
endif()
21+
separate_arguments(TEST_COMMAND)
22+
add_test(NAME ${tname}
23+
COMMAND ${TEST_COMMAND}
24+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
25+
)
4026

41-
if(UR_CONFORMANCE_ENABLE_MATCH_FILES)
42-
list(APPEND env GTEST_COLOR=yes)
43-
endif()
4427
set_tests_properties(${tname} PROPERTIES
4528
ENVIRONMENT "${env}"
4629
LABELS "conformance;${adapter}")
@@ -67,20 +50,24 @@ function(add_conformance_test name)
6750
GTest::gtest_main
6851
unit_tests_helpers)
6952

53+
if(UR_USE_CFI)
54+
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE UR_USE_CFI)
55+
endif()
56+
7057
if(UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_ALL)
7158
add_test_adapter(${name} adapter_cuda CUDA)
7259
endif()
7360
if(UR_BUILD_ADAPTER_HIP OR UR_BUILD_ADAPTER_ALL)
7461
add_test_adapter(${name} adapter_hip HIP)
7562
endif()
7663
if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_ALL)
77-
add_test_adapter(${name} adapter_level_zero LEVEL_ZERO)
64+
add_test_adapter(${name} adapter_level_zero Level_Zero)
7865
endif()
7966
if(UR_BUILD_ADAPTER_L0_V2)
80-
add_test_adapter(${name} adapter_level_zero_v2 LEVEL_ZERO)
67+
add_test_adapter(${name} adapter_level_zero_v2 Level_Zero)
8168
endif()
8269
if(UR_BUILD_ADAPTER_OPENCL OR UR_BUILD_ADAPTER_ALL)
83-
add_test_adapter(${name} adapter_opencl OPENCL)
70+
add_test_adapter(${name} adapter_opencl OpenCL)
8471
endif()
8572
if(UR_BUILD_ADAPTER_NATIVE_CPU OR UR_BUILD_ADAPTER_ALL)
8673
add_test_adapter(${name} adapter_native_cpu NATIVE_CPU)

test/conformance/README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,54 @@ all available devices/platforms, set 0. The default value is 1.
1919
If you run binaries for the tests, you can use the parameter
2020
`--platforms_count=COUNT` or `--devices_count=COUNT`.
2121
To set test device/platform name you want to run the tests on, use
22-
parameter `--platform=NAME` or `--device=NAME`.
22+
parameter `--platform=NAME` or `--device=NAME`.
23+
24+
## Known failures
25+
26+
The `UUR_KNOWN_FAILURE_ON` macro can be used to skip tests on devices where the
27+
test is known to fail. This can be done in the following situations.
28+
29+
For all devices in an adapter:
30+
31+
```cpp
32+
UUR_KNOWN_FAILURE_ON(uur::LevelZero{});
33+
```
34+
35+
By substring match of the device name within and adapter:
36+
37+
```cpp
38+
UUR_KNOWN_FAILURE_ON(uur::OpenCL{"Intel(R) UHD Graphics 770"});
39+
```
40+
41+
In certain test suits, where there is no access to a device, the platform name
42+
is used instead:
43+
44+
```cpp
45+
UUR_KNOWN_FAILURE_ON(uur::CUDA{"NVIDIA CUDA BACKEND"});
46+
```
47+
48+
When neither device or platform is available in a test suite, the name is
49+
ignored and only the adapter backend is used to determine if the test is a
50+
known failure.
51+
52+
The macro is variadic making it possible to specify known failures for multiple
53+
adapters in a single place and multiple names can also be provided per adapter:
54+
55+
```cpp
56+
UUR_KNOWN_FAILURE_ON(
57+
uur::OpenCL{
58+
"Intel(R) UHD Graphics 750",
59+
"Intel(R) UHD Graphics 770",
60+
},
61+
uur::HIP{"Radeon RX 7700"},
62+
uur::NativeCPU{});
63+
```
64+
65+
The following adapter matcher objects are available:
66+
67+
* `uur::OpenCL`
68+
* `uur::LevelZero`
69+
* `uur::LevelZeroV2`
70+
* `uur::CUDA`
71+
* `uur::HIP`
72+
* `uur::NativeCPU`

test/conformance/context/context_adapter_level_zero.match

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/conformance/context/context_adapter_level_zero_v2.match

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/conformance/context/context_adapter_native_cpu.match

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/conformance/context/urContextCreate.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,11 @@ TEST_P(urContextCreateTest, InvalidNullPointerDevices) {
3131
}
3232

3333
TEST_P(urContextCreateTest, InvalidNullPointerContext) {
34-
auto device = GetParam();
3534
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
3635
urContextCreate(1, &device, nullptr, nullptr));
3736
}
3837

3938
TEST_P(urContextCreateTest, InvalidEnumeration) {
40-
auto device = GetParam();
41-
4239
ur_context_properties_t properties{UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES,
4340
nullptr, UR_CONTEXT_FLAGS_MASK};
4441
uur::raii::Context context = nullptr;
@@ -48,7 +45,9 @@ TEST_P(urContextCreateTest, InvalidEnumeration) {
4845
}
4946

5047
using urContextCreateMultiDeviceTest = uur::urAllDevicesTest;
51-
TEST_F(urContextCreateMultiDeviceTest, Success) {
48+
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urContextCreateMultiDeviceTest);
49+
50+
TEST_P(urContextCreateMultiDeviceTest, Success) {
5251
if (devices.size() < 2) {
5352
GTEST_SKIP();
5453
}

test/conformance/context/urContextCreateWithNativeHandle.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See LICENSE.TXT
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6-
#include "uur/environment.h"
76
#include <uur/fixtures.h>
87

98
using urContextCreateWithNativeHandleTest = uur::urContextTest;

0 commit comments

Comments
 (0)