Skip to content

Commit a52ca46

Browse files
committed
update context initialization.
Signed-off-by: rehana begam <[email protected]>
1 parent 0d9dfa6 commit a52ca46

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@ pi_result _pi_platform::populateDeviceCacheIfNeeded() {
15761576

15771577
for (uint32_t i = 0; i < numQueueGroups; i++) {
15781578
if (QueueProperties[i].flags &
1579-
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE) {
1579+
ZE_COMMAND_QUEUE_GROUP_PROPERTY_FLAG_COMPUTE && QueueProperties[i].numQueues > 1) {
15801580
Ordinals.push_back(i);
15811581
}
15821582
}
@@ -1833,29 +1833,25 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
18331833
case PI_DEVICE_INFO_VERSION:
18341834
return ReturnValue(Device->Platform->ZeDriverApiVersion.c_str());
18351835
case PI_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES: {
1836-
uint32_t ZeSubDeviceCount = 0;
1837-
if (Device->isSubDevice()) {
1838-
pi_result Res = Device->Platform->populateDeviceCacheIfNeeded();
1839-
if (Res != PI_SUCCESS) {
1840-
return Res;
1841-
}
1842-
1843-
return ReturnValue(pi_uint32{(unsigned int)(Device->SubDevices.size())});
1836+
pi_result Res = Device->Platform->populateDeviceCacheIfNeeded();
1837+
if (Res != PI_SUCCESS) {
1838+
return Res;
18441839
}
1845-
ZE_CALL(zeDeviceGetSubDevices, (ZeDevice, &ZeSubDeviceCount, nullptr));
1846-
return ReturnValue(pi_uint32{ZeSubDeviceCount});
1840+
return ReturnValue(pi_uint32{(unsigned int)(Device->SubDevices.size())});
18471841
}
18481842
case PI_DEVICE_INFO_REFERENCE_COUNT:
18491843
return ReturnValue(pi_uint32{Device->RefCount});
18501844
case PI_DEVICE_INFO_PARTITION_PROPERTIES: {
18511845
// SYCL spec says: if this SYCL device cannot be partitioned into at least
18521846
// two sub devices then the returned vector must be empty.
1853-
if (!Device->isSubDevice()) {
1854-
uint32_t ZeSubDeviceCount = 0;
1855-
ZE_CALL(zeDeviceGetSubDevices, (ZeDevice, &ZeSubDeviceCount, nullptr));
1856-
if (ZeSubDeviceCount < 2) {
1857-
return ReturnValue(pi_device_partition_property{0});
1858-
}
1847+
pi_result Res = Device->Platform->populateDeviceCacheIfNeeded();
1848+
if (Res != PI_SUCCESS) {
1849+
return Res;
1850+
}
1851+
1852+
uint32_t ZeSubDeviceCount = Device->SubDevices.size();
1853+
if (ZeSubDeviceCount < 2) {
1854+
return ReturnValue(pi_device_partition_property{0});
18591855
}
18601856
// It is debatable if SYCL sub-device and partitioning APIs sufficient to
18611857
// expose Level Zero sub-devices? We start with support of

sycl/plugins/level_zero/pi_level_zero.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ struct _pi_device : _pi_object {
291291
int32_t ZeComputeQueueGroupIndex;
292292
int32_t ZeCopyQueueGroupIndex;
293293

294-
// Keep the index of the compute engine
294+
// Keep the index of the compute engine
295295
int32_t ZeComputeEngineIndex = 0;
296296

297297
// Cache the properties of the compute/copy queue groups.
@@ -363,6 +363,14 @@ struct _pi_context : _pi_object {
363363
// include root device itself as well)
364364
SingleRootDevice =
365365
Devices[0]->RootDevice ? Devices[0]->RootDevice : Devices[0];
366+
367+
// For context with sub subdevices, the SingleRootDevice might still
368+
// not be the root device.
369+
// Check whether the SingleRootDevice is the subdevice or root device.
370+
if (SingleRootDevice->isSubDevice()) {
371+
SingleRootDevice = SingleRootDevice->RootDevice;
372+
}
373+
366374
for (auto &Device : Devices) {
367375
if ((!Device->RootDevice && Device != SingleRootDevice) ||
368376
(Device->RootDevice && Device->RootDevice != SingleRootDevice)) {

0 commit comments

Comments
 (0)