diff --git a/sycl/source/detail/platform_impl.cpp b/sycl/source/detail/platform_impl.cpp index e386240bd3bd8..ef6e57c764e55 100644 --- a/sycl/source/detail/platform_impl.cpp +++ b/sycl/source/detail/platform_impl.cpp @@ -116,8 +116,13 @@ std::vector platform_impl::getAdapterPlatforms(AdapterPtr &Adapter, platform Platform = detail::createSyclObjFromImpl( getOrMakePlatformImpl(UrPlatform, Adapter)); const bool IsBanned = IsBannedPlatform(Platform); - const bool HasAnyDevices = - !Platform.get_devices(info::device_type::all).empty(); + bool HasAnyDevices = false; + + // Platform.get_devices() increments the device count for the platform + // and if the platform is banned (like OpenCL for AMD), it can cause + // incorrect device numbering, when used with ONEAPI_DEVICE_SELECTOR. + if (!IsBanned) + HasAnyDevices = !Platform.get_devices(info::device_type::all).empty(); if (!Supported) { if (IsBanned || !HasAnyDevices) { diff --git a/sycl/test-e2e/Regression/device_num.cpp b/sycl/test-e2e/Regression/device_num.cpp index 6479c906041d5..35bb192be55f7 100644 --- a/sycl/test-e2e/Regression/device_num.cpp +++ b/sycl/test-e2e/Regression/device_num.cpp @@ -1,6 +1,3 @@ -// UNSUPPORTED: any-device-is-hip -// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/16805 - // RUN: %{build} -o %t.out // RUN: env PRINT_FULL_DEVICE_INFO=1 %{run-unfiltered-devices} %t.out > %t1.conf // RUN: env ONEAPI_DEVICE_SELECTOR="*:0" env TEST_DEV_CONFIG_FILE_NAME=%t1.conf %{run-unfiltered-devices} %t.out