From 136890b98b0a6d5dee0064058a7211f22aa85854 Mon Sep 17 00:00:00 2001 From: Zheming Jin Date: Sat, 18 Jul 2026 13:29:51 -0700 Subject: [PATCH] [SYCL] Fix AMD GPU architecture detection get_architecture() stripped the feature-suffix (e.g. ":sramecc+:xnack-") from the device version string using string_view::substr, but then passed the view's .data() to a helper taking a const char*. Since .data() points into the original, non-truncated buffer, the lookup compared against the full "gfx942:sramecc+:xnack-" string and never matched, yielding architecture::unknown for AMD GPUs whose gcnArchName carries feature flags. NVIDIA is unaffected because its version string ("7.5" style) has no ':' to truncate. Take a std::string_view in the helper and pass the bounded substring so the comparison respects the truncation. Co-authored-by: Cursor --- sycl/source/detail/device_impl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 3715e0c0ae1ce..2496b327a9430 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -1979,7 +1979,7 @@ class device_impl { .value_or(ext::oneapi::experimental::architecture::unknown); } else if (is_gpu() && (backend::ext_oneapi_cuda == CurrentBackend || backend::ext_oneapi_hip == CurrentBackend)) { - auto MapArchIDToArchName = [&](const char *arch) { + auto MapArchIDToArchName = [&](std::string_view arch) { for (const auto &Item : NvidiaAmdGPUArchitectures) { if (std::string_view(Item.first) == arch) return Item.second; @@ -1990,7 +1990,7 @@ class device_impl { get_info_impl::value>(); std::string_view DeviceArchSubstr = std::string_view{DeviceArch}.substr(0, DeviceArch.find(":")); - return MapArchIDToArchName(DeviceArchSubstr.data()); + return MapArchIDToArchName(DeviceArchSubstr); } else if (is_cpu() && backend::opencl == CurrentBackend) { return LookupIPVersion(IntelCPUArchitectures) .value_or(ext::oneapi::experimental::architecture::x86_64);