Skip to content

Commit 67d0e98

Browse files
authored
[SYCL] Construct context from first device in unit tests (#4142)
This is because multiple devices in a context is not supported with AOT compiling, which is always used for the CUDA and ROCm pluginis, and constructing the context from the platform may result in multiple devices in the context if there are multiple devices available on the system. These tests are run with a device filter so this will only happen when there is multiple devices of the same type. Which also means that it should always be fine to take the first device from the platform as it should still be of the expected device type.
1 parent dfa4f02 commit 67d0e98

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

sycl/unittests/kernel-and-program/DeviceInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ TEST_F(DeviceInfoTest, GetDeviceUUID) {
6464
return;
6565
}
6666

67-
context Ctx{Plt};
67+
context Ctx{Plt.get_devices()[0]};
6868
TestContext.reset(new TestCtx(Ctx));
6969

7070
device Dev = Ctx.get_devices()[0];

sycl/unittests/kernel-and-program/KernelInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ TEST_F(KernelInfoTest, GetPrivateMemUsage) {
123123
return;
124124
}
125125

126-
context Ctx{Plt};
126+
context Ctx{Plt.get_devices()[0]};
127127
program Prg{Ctx};
128128
TestContext.reset(new TestCtx(Ctx));
129129

sycl/unittests/kernel-and-program/KernelRelease.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ TEST(KernelReleaseTest, GetKernelRelease) {
103103
Mock.redefine<detail::PiApiKind::piKernelSetExecInfo>(
104104
redefinedKernelSetExecInfo);
105105

106-
context Ctx{Plt};
106+
context Ctx{Plt.get_devices()[0]};
107107
TestContext.reset(new TestCtx(Ctx));
108108

109109
program Prg{Ctx};

sycl/unittests/queue/EventClear.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ TEST(QueueEventClear, ClearOnQueueWait) {
108108
if (!preparePiMock(Plt))
109109
return;
110110

111-
context Ctx{Plt};
111+
context Ctx{Plt.get_devices()[0]};
112112
TestContext.reset(new TestCtx(Ctx));
113113
queue Q{Ctx, default_selector()};
114114

@@ -129,7 +129,7 @@ TEST(QueueEventClear, CleanupOnThreshold) {
129129
if (!preparePiMock(Plt))
130130
return;
131131

132-
context Ctx{Plt};
132+
context Ctx{Plt.get_devices()[0]};
133133
TestContext.reset(new TestCtx(Ctx));
134134
queue Q{Ctx, default_selector()};
135135

sycl/unittests/queue/Wait.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ TEST(QueueWait, QueueWaitTest) {
120120
platform Plt{default_selector()};
121121
if (!preparePiMock(Plt))
122122
return;
123-
context Ctx{Plt};
123+
context Ctx{Plt.get_devices()[0]};
124124
queue Q{Ctx, default_selector()};
125125

126126
unsigned char *HostAlloc = (unsigned char *)malloc_host(1, Ctx);

sycl/unittests/scheduler/CommandsWaitForEvents.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ TEST_F(SchedulerTest, CommandsWaitForEvents) {
7979
Mock.redefine<detail::PiApiKind::piEventRelease>(retainReleaseFunc);
8080
Mock.redefine<detail::PiApiKind::piEventGetInfo>(getEventInfoFunc);
8181

82-
context Ctx1{Plt};
82+
context Ctx1{Plt.get_devices()[0]};
8383
queue Q1{Ctx1, Selector};
84-
context Ctx2{Plt};
84+
context Ctx2{Plt.get_devices()[0]};
8585
queue Q2{Ctx2, Selector};
8686

8787
TestContext.reset(new TestCtx(Q1, Q2));

sycl/unittests/scheduler/InOrderQueueDeps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ TEST_F(SchedulerTest, InOrderQueueDeps) {
9797
Mock.redefine<detail::PiApiKind::piEventsWait>(redefinedEventsWait);
9898
Mock.redefine<detail::PiApiKind::piEventRelease>(redefinedEventRelease);
9999

100-
context Ctx{Plt};
100+
context Ctx{Plt.get_devices()[0]};
101101
queue InOrderQueue{Ctx, Selector, property::queue::in_order()};
102102
cl::sycl::detail::QueueImplPtr InOrderQueueImpl =
103103
detail::getSyclObjImpl(InOrderQueue);

0 commit comments

Comments
 (0)