Skip to content

Commit 13e975e

Browse files
committed
Fix issues with kernel launch tests.
1 parent 2994564 commit 13e975e

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
lines changed

test/conformance/enqueue/helpers.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ struct urMultiQueueMultiDeviceTest : uur::urAllDevicesTest {
192192
std::vector<ur_queue_handle_t> queues;
193193
};
194194

195-
template <size_t minDevices, class T>
195+
template <size_t minDevices, class T, bool trueMultiDevice = true>
196196
struct urMultiQueueMultiDeviceTestWithParam
197197
: uur::urAllDevicesTestWithParam<T> {
198198
using uur::urAllDevicesTestWithParam<T>::devices;
@@ -203,7 +203,12 @@ struct urMultiQueueMultiDeviceTestWithParam
203203
urContextCreate(devices.size(), devices.data(), nullptr, &context));
204204

205205
// Duplicate our devices until we hit the minimum size specified.
206-
auto srcDevices = devices;
206+
std::vector<ur_device_handle_t> srcDevices;
207+
if (trueMultiDevice) {
208+
srcDevices = devices;
209+
} else {
210+
srcDevices.push_back(devices[0]);
211+
}
207212
while (devices.size() < minDevices) {
208213
devices.insert(devices.end(), srcDevices.begin(), srcDevices.end());
209214
}

test/conformance/enqueue/urEnqueueKernelLaunch.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,8 @@ UUR_INSTANTIATE_PLATFORM_TEST_SUITE(urEnqueueKernelLaunchMultiDeviceTest);
565565
// TODO: rewrite this test, right now it only works for a single queue
566566
// (the context is only created for one device)
567567
TEST_P(urEnqueueKernelLaunchMultiDeviceTest, KernelLaunchReadDifferentQueues) {
568-
UUR_KNOWN_FAILURE_ON(uur::LevelZero{}, uur::LevelZeroV2{});
569-
if (devices.size() > 1) {
570-
UUR_KNOWN_FAILURE_ON(uur::CUDA{});
571-
}
568+
UUR_KNOWN_FAILURE_ON(uur::CUDA{}, uur::LevelZero{}, uur::LevelZeroV2{});
569+
572570
uur::KernelLaunchHelper helper =
573571
uur::KernelLaunchHelper{platform, context, kernel, queues[0]};
574572

test/conformance/enqueue/urEnqueueKernelLaunchAndMemcpyInOrder.cpp

+23-25
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
// There was a bug in previous L0 drivers that caused the test to fail
1717
std::tuple<size_t, size_t, size_t> minL0DriverVersion = {1, 3, 29534};
1818

19-
template <size_t minDevices, typename T>
19+
template <size_t minDevices, typename T, bool trueMultiDevice = true>
2020
struct urMultiQueueLaunchMemcpyTest
21-
: uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T> {
21+
: uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T,
22+
trueMultiDevice> {
2223
std::string KernelName;
2324
std::vector<ur_program_handle_t> programs;
2425
std::vector<ur_kernel_handle_t> kernels;
@@ -28,17 +29,22 @@ struct urMultiQueueLaunchMemcpyTest
2829
static constexpr size_t ArraySize = 100;
2930
static constexpr uint32_t InitialValue = 1;
3031

31-
using uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T>::devices;
32-
using uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T>::platform;
33-
using uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T>::context;
34-
using uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T>::queues;
32+
using uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T,
33+
trueMultiDevice>::devices;
34+
using uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T,
35+
trueMultiDevice>::platform;
36+
using uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T,
37+
trueMultiDevice>::context;
38+
using uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T,
39+
trueMultiDevice>::queues;
3540

3641
void SetUp() override {
3742
// We haven't got device code tests working on native cpu yet.
3843
UUR_KNOWN_FAILURE_ON(uur::NativeCPU{});
3944

4045
UUR_RETURN_ON_FATAL_FAILURE(
41-
uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T>::SetUp());
46+
uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T,
47+
trueMultiDevice>::SetUp());
4248

4349
for (auto &device : devices) {
4450
SKIP_IF_DRIVER_TOO_OLD("Level-Zero", minL0DriverVersion, platform,
@@ -100,7 +106,8 @@ struct urMultiQueueLaunchMemcpyTest
100106
urProgramRelease(program);
101107
}
102108
UUR_RETURN_ON_FATAL_FAILURE(
103-
uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T>::TearDown());
109+
uur::urMultiQueueMultiDeviceTestWithParam<minDevices, T,
110+
trueMultiDevice>::TearDown());
104111
}
105112

106113
void runBackgroundCheck(std::vector<uur::raii::Event> &Events) {
@@ -150,26 +157,24 @@ struct urEnqueueKernelLaunchIncrementMultiDeviceTestWithParam
150157
};
151158

152159
struct urEnqueueKernelLaunchIncrementTest
153-
: urMultiQueueLaunchMemcpyTest<50, uur::BoolTestParam> {
160+
: urMultiQueueLaunchMemcpyTest<50, uur::BoolTestParam, false> {
154161
static constexpr size_t numOps = 50;
155162

156163
using Param = uur::BoolTestParam;
157164

158-
using urMultiQueueLaunchMemcpyTest<numOps, Param>::context;
159-
using urMultiQueueLaunchMemcpyTest<numOps, Param>::queues;
160-
using urMultiQueueLaunchMemcpyTest<numOps, Param>::devices;
161-
using urMultiQueueLaunchMemcpyTest<numOps, Param>::kernels;
162-
using urMultiQueueLaunchMemcpyTest<numOps, Param>::SharedMem;
165+
using urMultiQueueLaunchMemcpyTest<numOps, Param, false>::queues;
166+
using urMultiQueueLaunchMemcpyTest<numOps, Param, false>::kernels;
167+
using urMultiQueueLaunchMemcpyTest<numOps, Param, false>::SharedMem;
163168

164169
void SetUp() override {
165170
UUR_RETURN_ON_FATAL_FAILURE(
166-
urMultiQueueLaunchMemcpyTest<numOps, Param>::
171+
urMultiQueueLaunchMemcpyTest<numOps, Param, false>::
167172
SetUp()); // Use single device, duplicated numOps times
168173
}
169174

170175
void TearDown() override {
171176
UUR_RETURN_ON_FATAL_FAILURE(
172-
urMultiQueueLaunchMemcpyTest<numOps, Param>::TearDown());
177+
urMultiQueueLaunchMemcpyTest<numOps, Param, false>::TearDown());
173178
}
174179
};
175180

@@ -180,9 +185,6 @@ UUR_PLATFORM_TEST_SUITE_WITH_PARAM(
180185

181186
TEST_P(urEnqueueKernelLaunchIncrementTest, Success) {
182187
UUR_KNOWN_FAILURE_ON(uur::LevelZeroV2{});
183-
if (devices.size() > 1) {
184-
UUR_KNOWN_FAILURE_ON(uur::CUDA{});
185-
}
186188

187189
constexpr size_t global_offset = 0;
188190
constexpr size_t n_dimensions = 1;
@@ -361,14 +363,10 @@ UUR_PLATFORM_TEST_SUITE_WITH_PARAM(
361363
// Enqueue kernelLaunch concurrently from multiple threads
362364
// With !queuePerThread this becomes a test on a single device
363365
TEST_P(urEnqueueKernelLaunchIncrementMultiDeviceMultiThreadTest, Success) {
364-
if (devices.size() > 1) {
365-
UUR_KNOWN_FAILURE_ON(uur::CUDA{});
366-
}
367366
auto useEvents = std::get<0>(getParam()).value;
368367
auto queuePerThread = std::get<1>(getParam()).value;
369-
370368
if (!queuePerThread) {
371-
UUR_KNOWN_FAILURE_ON(uur::LevelZero{}, uur::LevelZeroV2{});
369+
UUR_KNOWN_FAILURE_ON(uur::LevelZero{}, uur::LevelZeroV2{}, uur::CUDA{});
372370
}
373371

374372
size_t numThreads = devices.size();
@@ -382,7 +380,7 @@ TEST_P(urEnqueueKernelLaunchIncrementMultiDeviceMultiThreadTest, Success) {
382380
constexpr size_t n_dimensions = 1;
383381

384382
auto queue = queuePerThread ? queues[i] : queues.back();
385-
auto kernel = kernels[i];
383+
auto kernel = queuePerThread ? kernels[i] : kernels.back();
386384
auto sharedPtr = SharedMem[i];
387385

388386
std::vector<uur::raii::Event> Events(numOpsPerThread + 1);

test/conformance/testing/include/uur/fixtures.h

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ GetDevices(ur_platform_handle_t platform) {
6363
if (count == 0) {
6464
return {false, {}};
6565
}
66+
count = 1;
6667
std::vector<ur_device_handle_t> devices(count);
6768
if (urDeviceGet(platform, UR_DEVICE_TYPE_ALL, count, devices.data(),
6869
nullptr)) {

0 commit comments

Comments
 (0)