From 91fa6093989e7352f6d3459b91ef304cabb396ac Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Tue, 15 Jul 2025 15:46:42 -0700 Subject: [PATCH] [NFC][SYCL] Use raw `device_impl`/`devices_range` in misc places --- sycl/source/detail/context_impl.hpp | 4 ++-- sycl/source/detail/kernel_impl.cpp | 13 +++++++------ sycl/source/detail/kernel_impl.hpp | 4 ++-- sycl/source/detail/queue_impl.hpp | 2 +- sycl/source/detail/syclbin.cpp | 12 ++++++------ sycl/source/detail/syclbin.hpp | 4 ++-- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 4be6ee9ac60f8..461349691da80 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -347,9 +347,9 @@ class context_impl : public std::enable_shared_from_this { }; template -void GetCapabilitiesIntersectionSet(const std::vector &Devices, +void GetCapabilitiesIntersectionSet(devices_range Devices, std::vector &CapabilityList) { - for (const sycl::device &Device : Devices) { + for (device_impl &Device : Devices) { std::vector NewCapabilityList; std::vector DeviceCapabilities = Device.get_info(); std::set_intersection( diff --git a/sycl/source/detail/kernel_impl.cpp b/sycl/source/detail/kernel_impl.cpp index 3a8434f35f8d4..da22bb28c9922 100644 --- a/sycl/source/detail/kernel_impl.cpp +++ b/sycl/source/detail/kernel_impl.cpp @@ -103,7 +103,7 @@ std::string_view kernel_impl::getName() const { return MName; } -bool kernel_impl::isBuiltInKernel(const device &Device) const { +bool kernel_impl::isBuiltInKernel(device_impl &Device) const { auto BuiltInKernels = Device.get_info(); if (BuiltInKernels.empty()) return false; @@ -116,9 +116,10 @@ bool kernel_impl::isBuiltInKernel(const device &Device) const { void kernel_impl::checkIfValidForNumArgsInfoQuery() const { if (isInteropOrSourceBased()) return; - auto Devices = MKernelBundleImpl->get_devices(); - if (std::any_of(Devices.begin(), Devices.end(), - [this](device &Device) { return isBuiltInKernel(Device); })) + devices_range Devices = MKernelBundleImpl->get_devices(); + if (std::any_of(Devices.begin(), Devices.end(), [this](device_impl &Device) { + return isBuiltInKernel(Device); + })) return; throw sycl::exception( @@ -149,8 +150,8 @@ kernel_impl::get_backend_info() const { "the info::platform::version info descriptor can " "only be queried with an OpenCL backend"); } - auto Devices = MKernelBundleImpl->get_devices(); - return Devices[0].get_platform().get_info(); + devices_range Devices = MKernelBundleImpl->get_devices(); + return Devices.front().get_platform().get_info(); } #endif diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index 8fd82b32b0037..0c3c1ab0bf1e4 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -255,7 +255,7 @@ class kernel_impl { std::mutex *MCacheMutex = nullptr; mutable std::string MName; - bool isBuiltInKernel(const device &Device) const; + bool isBuiltInKernel(device_impl &Device) const; void checkIfValidForNumArgsInfoQuery() const; /// Check if the occupancy limits are exceeded for the given kernel launch @@ -327,7 +327,7 @@ kernel_impl::get_info(const device &Device) const { Param, info::kernel_device_specific::global_work_size>) { bool isDeviceCustom = Device.get_info() == info::device_type::custom; - if (!isDeviceCustom && !isBuiltInKernel(Device)) + if (!isDeviceCustom && !isBuiltInKernel(*getSyclObjImpl(Device))) throw exception( sycl::make_error_code(errc::invalid), "info::kernel_device_specific::global_work_size descriptor may only " diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index e39cf23d74dbd..839570553f3ce 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -135,7 +135,7 @@ class queue_impl : public std::enable_shared_from_this { int Idx = get_property() .get_index(); int NumIndices = - createSyclObjFromImpl(Device) + Device .get_info(); if (Idx < 0 || Idx >= NumIndices) throw sycl::exception( diff --git a/sycl/source/detail/syclbin.cpp b/sycl/source/detail/syclbin.cpp index 19a83157b162f..229c3eb375571 100644 --- a/sycl/source/detail/syclbin.cpp +++ b/sycl/source/detail/syclbin.cpp @@ -10,6 +10,7 @@ // LLVMObject. #include +#include #include #include @@ -389,14 +390,13 @@ SYCLBINBinaries::convertAbstractModuleProperties(SYCLBIN::AbstractModule &AM) { } std::vector -SYCLBINBinaries::getBestCompatibleImages(const device &Dev) { - detail::device_impl &DevImpl = *getSyclObjImpl(Dev); +SYCLBINBinaries::getBestCompatibleImages(device_impl &Dev) { auto SelectCompatibleImages = [&](const std::vector &Imgs) { std::vector CompatImgs; for (const RTDeviceBinaryImage &Img : Imgs) - if (doesDevSupportDeviceRequirements(DevImpl, Img) && - doesImageTargetMatchDevice(Img, DevImpl)) + if (doesDevSupportDeviceRequirements(Dev, Img) && + doesImageTargetMatchDevice(Img, Dev)) CompatImgs.push_back(&Img); return CompatImgs; }; @@ -412,9 +412,9 @@ SYCLBINBinaries::getBestCompatibleImages(const device &Dev) { } std::vector -SYCLBINBinaries::getBestCompatibleImages(const std::vector &Devs) { +SYCLBINBinaries::getBestCompatibleImages(devices_range Devs) { std::set Images; - for (const device &Dev : Devs) { + for (device_impl &Dev : Devs) { std::vector BestImagesForDev = getBestCompatibleImages(Dev); Images.insert(BestImagesForDev.cbegin(), BestImagesForDev.cend()); diff --git a/sycl/source/detail/syclbin.hpp b/sycl/source/detail/syclbin.hpp index 312162372938b..5d54cd1953a21 100644 --- a/sycl/source/detail/syclbin.hpp +++ b/sycl/source/detail/syclbin.hpp @@ -120,9 +120,9 @@ struct SYCLBINBinaries { SYCLBINBinaries(const char *SYCLBINContent, size_t SYCLBINSize); std::vector - getBestCompatibleImages(const device &Dev); + getBestCompatibleImages(device_impl &Dev); std::vector - getBestCompatibleImages(const std::vector &Dev); + getBestCompatibleImages(devices_range Dev); uint8_t getState() const noexcept { PropertySet &GlobalMetadata =