Skip to content

Commit d2c811b

Browse files
[SYCL] Detach composite/component devices from L0 (#14270)
The current implementation of component and composite devices makes multiple checks for the backend in order to bind the behavior of the extension to L0. However, this should instead be done by the backends, having them report missing support when possible, and allowing backends to potentially support the extension in the future without needing to change the SYCL runtime. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 1b5c5a8 commit d2c811b

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed

sycl/source/detail/context_impl.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ class context_impl {
179179
/// it returns true if the device is either a member of the context or a
180180
/// descendant of a member.
181181
bool isDeviceValid(DeviceImplPtr Device) {
182-
// OpenCL does not support using descendants of context members within that
183-
// context yet.
184-
// TODO remove once this limitation is lifted
185-
if (!is_host() && Device->getBackend() == backend::opencl)
186-
return hasDevice(Device);
187-
188182
while (!hasDevice(Device)) {
189183
if (Device->isRootDevice()) {
190184
if (Device->has(aspect::ext_oneapi_is_component)) {
@@ -195,6 +189,12 @@ class context_impl {
195189
return hasDevice(detail::getSyclObjImpl(CompositeDevice));
196190
}
197191

192+
return false;
193+
} else if (!is_host() && Device->getBackend() == backend::opencl) {
194+
// OpenCL does not support using descendants of context members within
195+
// that context yet. We make the exception in case it supports
196+
// component/composite devices.
197+
// TODO remove once this limitation is lifted
198198
return false;
199199
}
200200
Device = detail::getSyclObjImpl(

sycl/source/detail/device_impl.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,6 @@ bool device_impl::has(aspect Aspect) const {
694694
return components.size() >= 2;
695695
}
696696
case aspect::ext_oneapi_is_component: {
697-
if (getBackend() != backend::ext_oneapi_level_zero)
698-
return false;
699-
700697
typename sycl_to_pi<device>::type Result = nullptr;
701698
bool CallSuccessful = getPlugin()->call_nocheck<PiApiKind::piDeviceGetInfo>(
702699
getHandleRef(),

sycl/source/detail/device_info.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,8 +1192,6 @@ struct get_device_info_impl<
11921192
std::vector<sycl::device>,
11931193
ext::oneapi::experimental::info::device::component_devices> {
11941194
static std::vector<sycl::device> get(const DeviceImplPtr &Dev) {
1195-
if (Dev->getBackend() != backend::ext_oneapi_level_zero)
1196-
return {};
11971195
size_t ResultSize = 0;
11981196
// First call to get DevCount.
11991197
pi_result Err = Dev->getPlugin()->call_nocheck<PiApiKind::piDeviceGetInfo>(

sycl/unittests/Extensions/CompositeDevice.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,14 @@ pi_result after_piContextCreate(const pi_context_properties *,
111111
} // namespace
112112

113113
TEST(CompositeDeviceTest, DescendentDeviceSupportInContext) {
114-
sycl::unittest::PiMock Mock(sycl::backend::ext_oneapi_level_zero);
114+
sycl::unittest::PiMock Mock;
115115
Mock.redefine<sycl::detail::PiApiKind::piDevicesGet>(redefine_piDevicesGet);
116116
Mock.redefineAfter<sycl::detail::PiApiKind::piDeviceGetInfo>(
117117
after_piDeviceGetInfo);
118118
Mock.redefineAfter<sycl::detail::PiApiKind::piContextCreate>(
119119
after_piContextCreate);
120120

121121
sycl::platform Plt = Mock.getPlatform();
122-
ASSERT_EQ(Plt.get_backend(), sycl::backend::ext_oneapi_level_zero);
123-
124122
sycl::device RootDevice = Plt.get_devices()[0];
125123
ASSERT_TRUE(RootDevice.has(sycl::aspect::ext_oneapi_is_component));
126124
sycl::context Ctx(RootDevice);
@@ -152,16 +150,14 @@ TEST(CompositeDeviceTest, DescendentDeviceSupportInContext) {
152150
}
153151

154152
TEST(CompositeDeviceTest, DescendentDeviceSupportInQueue) {
155-
sycl::unittest::PiMock Mock(sycl::backend::ext_oneapi_level_zero);
153+
sycl::unittest::PiMock Mock;
156154
Mock.redefine<sycl::detail::PiApiKind::piDevicesGet>(redefine_piDevicesGet);
157155
Mock.redefineAfter<sycl::detail::PiApiKind::piDeviceGetInfo>(
158156
after_piDeviceGetInfo);
159157
Mock.redefineAfter<sycl::detail::PiApiKind::piContextCreate>(
160158
after_piContextCreate);
161159

162160
sycl::platform Plt = Mock.getPlatform();
163-
ASSERT_EQ(Plt.get_backend(), sycl::backend::ext_oneapi_level_zero);
164-
165161
sycl::device ComponentDevice = Plt.get_devices()[0];
166162
ASSERT_TRUE(ComponentDevice.has(sycl::aspect::ext_oneapi_is_component));
167163

0 commit comments

Comments
 (0)