Skip to content

Commit 24eb531

Browse files
committed
Initial attempt at parameterizing the cts over all available devices.
1 parent 607e88d commit 24eb531

File tree

93 files changed

+1148
-1227
lines changed

Some content is hidden

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

93 files changed

+1148
-1227
lines changed

test/adapters/cuda/urDeviceCreateWithNativeHandle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "fixtures.h"
77

8-
using urCudaDeviceCreateWithNativeHandle = uur::urPlatformTest;
8+
using urCudaDeviceCreateWithNativeHandle = uur::urSelectedPlatformTest;
99

1010
TEST_F(urCudaDeviceCreateWithNativeHandle, Success) {
1111
// get a device from cuda

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/conformance/adapter/urAdapterGetInfo.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ TEST_P(urAdapterGetInfoTest, Backend) {
1616
size_t size = 0;
1717
ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
1818
urAdapterGetInfo(adapter, info_type, 0, nullptr, &size), info_type);
19-
ASSERT_NE(size, 0);
20-
2119
ASSERT_EQ(size, sizeof(ur_adapter_backend_t));
2220

2321
std::vector<char> info_data(size);

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;

test/conformance/context/urContextGetInfo.cpp

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ struct urContextGetInfoTestWithInfoParam
4848
ctx_info_mem_flags_map;
4949
};
5050

51-
UUR_TEST_SUITE_P(urContextGetInfoTestWithInfoParam,
52-
::testing::Values(
53-
54-
UR_CONTEXT_INFO_NUM_DEVICES, //
55-
UR_CONTEXT_INFO_DEVICES, //
56-
UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT, //
57-
UR_CONTEXT_INFO_USM_FILL2D_SUPPORT, //
58-
UR_CONTEXT_INFO_REFERENCE_COUNT, //
59-
UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES, //
60-
UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES, //
61-
UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES, //
62-
UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES //
63-
),
64-
uur::deviceTestWithParamPrinter<ur_context_info_t>);
51+
UUR_DEVICE_TEST_SUITE_P(urContextGetInfoTestWithInfoParam,
52+
::testing::Values(
53+
54+
UR_CONTEXT_INFO_NUM_DEVICES, //
55+
UR_CONTEXT_INFO_DEVICES, //
56+
UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT, //
57+
UR_CONTEXT_INFO_USM_FILL2D_SUPPORT, //
58+
UR_CONTEXT_INFO_REFERENCE_COUNT, //
59+
UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES, //
60+
UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES, //
61+
UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES, //
62+
UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES //
63+
),
64+
uur::deviceTestWithParamPrinter<ur_context_info_t>);
6565

6666
TEST_P(urContextGetInfoTestWithInfoParam, Success) {
6767
ur_context_info_t info = getParam();
@@ -83,22 +83,15 @@ TEST_P(urContextGetInfoTestWithInfoParam, Success) {
8383
case UR_CONTEXT_INFO_NUM_DEVICES: {
8484
auto returned_num_of_devices =
8585
reinterpret_cast<uint32_t *>(info_data.data());
86-
ASSERT_GE(uur::DevicesEnvironment::instance->devices.size(),
87-
*returned_num_of_devices);
86+
ASSERT_EQ(*returned_num_of_devices, 1);
8887
break;
8988
}
9089
case UR_CONTEXT_INFO_DEVICES: {
9190
auto returned_devices =
9291
reinterpret_cast<ur_device_handle_t *>(info_data.data());
9392
size_t devices_count = info_size / sizeof(ur_device_handle_t);
94-
ASSERT_GT(devices_count, 0);
95-
for (uint32_t i = 0; i < devices_count; i++) {
96-
auto &devices = uur::DevicesEnvironment::instance->devices;
97-
auto queried_device =
98-
std::find(devices.begin(), devices.end(), returned_devices[i]);
99-
EXPECT_TRUE(queried_device != devices.end())
100-
<< "device associated with the context is not valid";
101-
}
93+
ASSERT_EQ(devices_count, 1);
94+
ASSERT_EQ(returned_devices[0], device);
10295
break;
10396
}
10497
case UR_CONTEXT_INFO_REFERENCE_COUNT: {

test/conformance/device/CMakeLists.txt

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

6-
add_conformance_test_with_platform_environment(device
6+
add_conformance_test_with_devices_environment(device
77
urDeviceCreateWithNativeHandle.cpp
88
urDeviceGet.cpp
99
urDeviceGetGlobalTimestamps.cpp

test/conformance/device/urDeviceCreateWithNativeHandle.cpp

Lines changed: 50 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,72 @@
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
#include <uur/fixtures.h>
66

7-
using urDeviceCreateWithNativeHandleTest = uur::urAllDevicesTest;
7+
using urDeviceCreateWithNativeHandleTest = uur::urDeviceTest;
8+
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urDeviceCreateWithNativeHandleTest);
89

9-
TEST_F(urDeviceCreateWithNativeHandleTest, Success) {
10-
for (auto device : devices) {
11-
ur_native_handle_t native_handle = 0;
10+
TEST_P(urDeviceCreateWithNativeHandleTest, Success) {
11+
ur_native_handle_t native_handle = 0;
1212

13-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
14-
urDeviceGetNativeHandle(device, &native_handle));
13+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
14+
urDeviceGetNativeHandle(device, &native_handle));
1515

16-
// We cannot assume anything about a native_handle, not even if it's
17-
// `nullptr` since this could be a valid representation within a backend.
18-
// We can however convert the native_handle back into a unified-runtime handle
19-
// and perform some query on it to verify that it works.
20-
ur_device_handle_t dev = nullptr;
21-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urDeviceCreateWithNativeHandle(
22-
native_handle, adapter, nullptr, &dev));
23-
ASSERT_NE(dev, nullptr);
16+
// We cannot assume anything about a native_handle, not even if it's
17+
// `nullptr` since this could be a valid representation within a backend.
18+
// We can however convert the native_handle back into a unified-runtime handle
19+
// and perform some query on it to verify that it works.
20+
ur_device_handle_t dev = nullptr;
21+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
22+
urDeviceCreateWithNativeHandle(native_handle, adapter, nullptr, &dev));
23+
ASSERT_NE(dev, nullptr);
2424

25-
uint32_t dev_id = 0;
26-
ASSERT_SUCCESS(urDeviceGetInfo(dev, UR_DEVICE_INFO_TYPE,
27-
sizeof(uint32_t), &dev_id, nullptr));
28-
}
25+
uint32_t dev_id = 0;
26+
ASSERT_SUCCESS(urDeviceGetInfo(dev, UR_DEVICE_INFO_TYPE, sizeof(uint32_t),
27+
&dev_id, nullptr));
2928
}
3029

31-
TEST_F(urDeviceCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
32-
for (auto device : devices) {
33-
ur_native_handle_t native_handle = 0;
30+
TEST_P(urDeviceCreateWithNativeHandleTest, SuccessWithOwnedNativeHandle) {
31+
ur_native_handle_t native_handle = 0;
3432

35-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
36-
urDeviceGetNativeHandle(device, &native_handle));
33+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
34+
urDeviceGetNativeHandle(device, &native_handle));
3735

38-
ur_device_handle_t dev = nullptr;
39-
ur_device_native_properties_t props{
40-
UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES, nullptr, true};
41-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urDeviceCreateWithNativeHandle(
42-
native_handle, adapter, &props, &dev));
43-
ASSERT_NE(dev, nullptr);
44-
}
36+
ur_device_handle_t dev = nullptr;
37+
ur_device_native_properties_t props{
38+
UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES, nullptr, true};
39+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
40+
urDeviceCreateWithNativeHandle(native_handle, adapter, &props, &dev));
41+
ASSERT_NE(dev, nullptr);
4542
}
4643

47-
TEST_F(urDeviceCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
48-
for (auto device : devices) {
49-
ur_native_handle_t native_handle = 0;
44+
TEST_P(urDeviceCreateWithNativeHandleTest, SuccessWithUnOwnedNativeHandle) {
45+
ur_native_handle_t native_handle = 0;
5046

51-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
52-
urDeviceGetNativeHandle(device, &native_handle));
47+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
48+
urDeviceGetNativeHandle(device, &native_handle));
5349

54-
ur_device_handle_t dev = nullptr;
55-
ur_device_native_properties_t props{
56-
UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES, nullptr, false};
57-
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(urDeviceCreateWithNativeHandle(
58-
native_handle, adapter, &props, &dev));
59-
ASSERT_NE(dev, nullptr);
60-
}
50+
ur_device_handle_t dev = nullptr;
51+
ur_device_native_properties_t props{
52+
UR_STRUCTURE_TYPE_DEVICE_NATIVE_PROPERTIES, nullptr, false};
53+
UUR_ASSERT_SUCCESS_OR_UNSUPPORTED(
54+
urDeviceCreateWithNativeHandle(native_handle, adapter, &props, &dev));
55+
ASSERT_NE(dev, nullptr);
6156
}
6257

63-
TEST_F(urDeviceCreateWithNativeHandleTest, InvalidNullHandlePlatform) {
64-
for (auto device : devices) {
65-
ur_native_handle_t native_handle = 0;
66-
ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle));
58+
TEST_P(urDeviceCreateWithNativeHandleTest, InvalidNullHandlePlatform) {
59+
ur_native_handle_t native_handle = 0;
60+
ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle));
6761

68-
ur_device_handle_t dev = nullptr;
69-
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
70-
urDeviceCreateWithNativeHandle(native_handle, nullptr,
71-
nullptr, &dev));
72-
}
62+
ur_device_handle_t dev = nullptr;
63+
ASSERT_EQ_RESULT(
64+
UR_RESULT_ERROR_INVALID_NULL_HANDLE,
65+
urDeviceCreateWithNativeHandle(native_handle, nullptr, nullptr, &dev));
7366
}
7467

75-
TEST_F(urDeviceCreateWithNativeHandleTest, InvalidNullPointerDevice) {
76-
for (auto device : devices) {
77-
ur_native_handle_t native_handle = 0;
78-
ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle));
68+
TEST_P(urDeviceCreateWithNativeHandleTest, InvalidNullPointerDevice) {
69+
ur_native_handle_t native_handle = 0;
70+
ASSERT_SUCCESS(urDeviceGetNativeHandle(device, &native_handle));
7971

80-
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
81-
urDeviceCreateWithNativeHandle(native_handle, adapter,
82-
nullptr, nullptr));
83-
}
72+
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
73+
urDeviceCreateWithNativeHandle(native_handle, adapter,
74+
nullptr, nullptr));
8475
}

test/conformance/device/urDeviceGet.cpp

Lines changed: 32 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#include <uur/fixtures.h>
77

88
using urDeviceGetTest = uur::urPlatformTest;
9+
UUR_INSTANTIATE_PLATFORM_TEST_SUITE_P(urDeviceGetTest);
910

10-
TEST_F(urDeviceGetTest, Success) {
11+
TEST_P(urDeviceGetTest, Success) {
1112
uint32_t count = 0;
1213
ASSERT_SUCCESS(
1314
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
@@ -20,7 +21,7 @@ TEST_F(urDeviceGetTest, Success) {
2021
}
2122
}
2223

23-
TEST_F(urDeviceGetTest, SuccessSubsetOfDevices) {
24+
TEST_P(urDeviceGetTest, SuccessSubsetOfDevices) {
2425
uint32_t count;
2526
ASSERT_SUCCESS(
2627
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
@@ -35,57 +36,21 @@ TEST_F(urDeviceGetTest, SuccessSubsetOfDevices) {
3536
}
3637
}
3738

38-
struct urDeviceGetTestWithDeviceTypeParam
39-
: uur::urAllDevicesTest,
40-
::testing::WithParamInterface<ur_device_type_t> {
41-
42-
void SetUp() override {
43-
UUR_RETURN_ON_FATAL_FAILURE(uur::urAllDevicesTest::SetUp());
44-
}
45-
};
46-
47-
INSTANTIATE_TEST_SUITE_P(
48-
, urDeviceGetTestWithDeviceTypeParam,
49-
::testing::Values(UR_DEVICE_TYPE_DEFAULT, UR_DEVICE_TYPE_GPU,
50-
UR_DEVICE_TYPE_CPU, UR_DEVICE_TYPE_FPGA,
51-
UR_DEVICE_TYPE_MCA, UR_DEVICE_TYPE_VPU),
52-
[](const ::testing::TestParamInfo<ur_device_type_t> &info) {
53-
std::stringstream ss;
54-
ss << info.param;
55-
return ss.str();
56-
});
57-
58-
TEST_P(urDeviceGetTestWithDeviceTypeParam, Success) {
59-
ur_device_type_t device_type = GetParam();
60-
uint32_t count = 0;
61-
ASSERT_SUCCESS(urDeviceGet(platform, device_type, 0, nullptr, &count));
62-
ASSERT_GE(devices.size(), count);
63-
64-
if (count > 0) {
65-
std::vector<ur_device_handle_t> devices(count);
66-
ASSERT_SUCCESS(
67-
urDeviceGet(platform, device_type, count, devices.data(), nullptr));
68-
for (auto device : devices) {
69-
ASSERT_NE(nullptr, device);
70-
}
71-
}
72-
}
73-
74-
TEST_F(urDeviceGetTest, InvalidNullHandlePlatform) {
39+
TEST_P(urDeviceGetTest, InvalidNullHandlePlatform) {
7540
uint32_t count;
7641
ASSERT_EQ_RESULT(
7742
UR_RESULT_ERROR_INVALID_NULL_HANDLE,
7843
urDeviceGet(nullptr, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
7944
}
8045

81-
TEST_F(urDeviceGetTest, InvalidEnumerationDevicesType) {
46+
TEST_P(urDeviceGetTest, InvalidEnumerationDevicesType) {
8247
uint32_t count;
8348
ASSERT_EQ_RESULT(
8449
UR_RESULT_ERROR_INVALID_ENUMERATION,
8550
urDeviceGet(platform, UR_DEVICE_TYPE_FORCE_UINT32, 0, nullptr, &count));
8651
}
8752

88-
TEST_F(urDeviceGetTest, InvalidSizeNumEntries) {
53+
TEST_P(urDeviceGetTest, InvalidSizeNumEntries) {
8954
uint32_t count = 0;
9055
ASSERT_SUCCESS(
9156
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
@@ -96,7 +61,7 @@ TEST_F(urDeviceGetTest, InvalidSizeNumEntries) {
9661
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, devices.data(), nullptr));
9762
}
9863

99-
TEST_F(urDeviceGetTest, InvalidNullPointerDevices) {
64+
TEST_P(urDeviceGetTest, InvalidNullPointerDevices) {
10065
uint32_t count = 0;
10166
ASSERT_SUCCESS(
10267
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, 0, nullptr, &count));
@@ -105,3 +70,28 @@ TEST_F(urDeviceGetTest, InvalidNullPointerDevices) {
10570
UR_RESULT_ERROR_INVALID_NULL_POINTER,
10671
urDeviceGet(platform, UR_DEVICE_TYPE_ALL, count, nullptr, nullptr));
10772
}
73+
74+
using urDeviceGetTestWithDeviceTypeParam =
75+
uur::urPlatformTestWithParam<ur_device_type_t>;
76+
77+
UUR_PLATFORM_TEST_SUITE_P(
78+
urDeviceGetTestWithDeviceTypeParam,
79+
::testing::Values(UR_DEVICE_TYPE_DEFAULT, UR_DEVICE_TYPE_GPU,
80+
UR_DEVICE_TYPE_CPU, UR_DEVICE_TYPE_FPGA,
81+
UR_DEVICE_TYPE_MCA, UR_DEVICE_TYPE_VPU),
82+
uur::platformTestWithParamPrinter<ur_device_type_t>);
83+
84+
TEST_P(urDeviceGetTestWithDeviceTypeParam, Success) {
85+
ur_device_type_t device_type = getParam();
86+
uint32_t count = 0;
87+
ASSERT_SUCCESS(urDeviceGet(platform, device_type, 0, nullptr, &count));
88+
89+
if (count > 0) {
90+
std::vector<ur_device_handle_t> devices(count);
91+
ASSERT_SUCCESS(
92+
urDeviceGet(platform, device_type, count, devices.data(), nullptr));
93+
for (auto device : devices) {
94+
ASSERT_NE(nullptr, device);
95+
}
96+
}
97+
}

0 commit comments

Comments
 (0)