Skip to content

Commit f7583ca

Browse files
[SYCL] Do not count devices for banned platforms (#18878)
Call to `Platform.get_devices()` increments the device count for the adapter (in `Adapter->setLastDeviceId()`) and if a platform is banned (like OpenCL for AMD), it can cause incorrect device numbering, when used with ONEAPI_DEVICE_SELECTOR. This PR skips call to `Platform.get_devices()` if a platform is banned.
1 parent d8367cc commit f7583ca

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

sycl/source/detail/platform_impl.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,13 @@ std::vector<platform> platform_impl::getAdapterPlatforms(AdapterPtr &Adapter,
116116
platform Platform = detail::createSyclObjFromImpl<platform>(
117117
getOrMakePlatformImpl(UrPlatform, Adapter));
118118
const bool IsBanned = IsBannedPlatform(Platform);
119-
const bool HasAnyDevices =
120-
!Platform.get_devices(info::device_type::all).empty();
119+
bool HasAnyDevices = false;
120+
121+
// Platform.get_devices() increments the device count for the platform
122+
// and if the platform is banned (like OpenCL for AMD), it can cause
123+
// incorrect device numbering, when used with ONEAPI_DEVICE_SELECTOR.
124+
if (!IsBanned)
125+
HasAnyDevices = !Platform.get_devices(info::device_type::all).empty();
121126

122127
if (!Supported) {
123128
if (IsBanned || !HasAnyDevices) {

sycl/test-e2e/Regression/device_num.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// UNSUPPORTED: any-device-is-hip
2-
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/16805
3-
41
// RUN: %{build} -o %t.out
52
// RUN: env PRINT_FULL_DEVICE_INFO=1 %{run-unfiltered-devices} %t.out > %t1.conf
63
// RUN: env ONEAPI_DEVICE_SELECTOR="*:0" env TEST_DEV_CONFIG_FILE_NAME=%t1.conf %{run-unfiltered-devices} %t.out

0 commit comments

Comments
 (0)