From a97a9358a1460865cead0c51711997a55552ea2d Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Fri, 11 Jul 2025 07:40:52 -0700 Subject: [PATCH] [NFC][SYCL] Add `devices_range` helper to cleanup `persistent_device_code_cache` Same idea as with `nodes_range` from https://github.com/intel/llvm/pull/19295, this PR generalizes the approach and makes both `nodes_|devices_range` use the same common utility. `persistent_device_code_cache` was chosen randomly to apply simplifications by using the new helper. Subsequent PRs will likely make wider usage of it. --- sycl/source/detail/device_impl.hpp | 28 +++++ sycl/source/detail/graph/node_impl.hpp | 112 ++++++------------ sycl/source/detail/helpers.hpp | 60 ++++++++++ .../detail/persistent_device_code_cache.cpp | 96 ++++++++------- .../detail/persistent_device_code_cache.hpp | 18 +-- .../PersistentDeviceCodeCache.cpp | 16 +-- .../MultipleDevsKernelBundle.cpp | 2 +- 7 files changed, 194 insertions(+), 138 deletions(-) diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 306411cc7e3b6..834420360f01c 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -8,6 +8,7 @@ #pragma once +#include #include #include #include @@ -2281,6 +2282,33 @@ class device_impl : public std::enable_shared_from_this { }; // class device_impl +struct devices_deref_impl { + template static device_impl &dereference(T &Elem) { + using Ty = std::decay_t; + if constexpr (std::is_same_v) { + return *getSyclObjImpl(Elem); + } else if constexpr (std::is_same_v) { + return Elem; + } else { + return *Elem; + } + } +}; +using devices_iterator = + variadic_iterator>::const_iterator, + std::vector::const_iterator, device_impl *>; + +class devices_range : public iterator_range { +private: + using Base = iterator_range; + +public: + using Base::Base; + devices_range(const device &Dev) + : devices_range(&*getSyclObjImpl(Dev), (&*getSyclObjImpl(Dev) + 1), 1) {} +}; + #ifndef __INTEL_PREVIEW_BREAKING_CHANGES template typename Param::return_type device_impl::get_info() const { diff --git a/sycl/source/detail/graph/node_impl.hpp b/sycl/source/detail/graph/node_impl.hpp index a08a2ca4308f7..ea5482db3c60b 100644 --- a/sycl/source/detail/graph/node_impl.hpp +++ b/sycl/source/detail/graph/node_impl.hpp @@ -10,8 +10,9 @@ #include // for AccessorImplHost #include // for CGExecKernel, CGHostTask, ArgDesc... -#include // for HostTask -#include // for CGType +#include +#include // for HostTask +#include // for CGType #include // for kernel_param_kind_t #include @@ -761,82 +762,43 @@ class node_impl : public std::enable_shared_from_this { } }; -// Non-owning! -class nodes_range { - template - using storage_iter_impl = - std::variant; - - using storage_iter = storage_iter_impl< - std::vector>, std::vector, - // Next one is temporary. It looks like `weak_ptr`s aren't - // used for the actual lifetime management and the objects are - // always guaranteed to be alive. Once the code is cleaned - // from `weak_ptr`s this alternative should be removed too. - std::vector>, - // - std::set>, std::set, - // - std::list>; - - storage_iter Begin; - storage_iter End; - const size_t Size; - -public: - nodes_range(const nodes_range &Other) = default; - - template < - typename ContainerTy, - typename = std::enable_if_t>> - nodes_range(ContainerTy &Container) - : Begin{Container.begin()}, End{Container.end()}, Size{Container.size()} { +struct nodes_deref_impl { + template static node_impl &dereference(T &Elem) { + if constexpr (std::is_same_v, + std::weak_ptr>) { + // This assumes that weak_ptr doesn't actually manage lifetime and + // the object is guaranteed to be alive (which seems to be the + // assumption across all graph code). + return *Elem.lock(); + } else { + return *Elem; + } } +}; - class iterator { - storage_iter It; - - iterator(storage_iter It) : It(It) {} - friend class nodes_range; - - public: - iterator &operator++() { - It = std::visit( - [](auto &&It) { - ++It; - return storage_iter{It}; - }, - It); - return *this; - } - bool operator!=(const iterator &Other) const { return It != Other.It; } - - node_impl &operator*() { - return std::visit( - [](auto &&It) -> node_impl & { - auto &Elem = *It; - if constexpr (std::is_same_v, - std::weak_ptr>) { - // This assumes that weak_ptr doesn't actually manage lifetime and - // the object is guaranteed to be alive (which seems to be the - // assumption across all graph code). - return *Elem.lock(); - } else { - return *Elem; - } - }, - It); - } - }; +template +using nodes_iterator_impl = + variadic_iterator; + +using nodes_iterator = nodes_iterator_impl< + std::vector>, std::vector, + // Next one is temporary. It looks like `weak_ptr`s aren't + // used for the actual lifetime management and the objects are + // always guaranteed to be alive. Once the code is cleaned + // from `weak_ptr`s this alternative should be removed too. + std::vector>, + // + std::set>, std::set, + // + std::list>; + +class nodes_range : public iterator_range { +private: + using Base = iterator_range; - iterator begin() const { - return {std::visit([](auto &&It) { return storage_iter{It}; }, Begin)}; - } - iterator end() const { - return {std::visit([](auto &&It) { return storage_iter{It}; }, End)}; - } - size_t size() const { return Size; } - bool empty() const { return Size == 0; } +public: + using Base::Base; }; inline nodes_range node_impl::successors() const { return MSuccessors; } diff --git a/sycl/source/detail/helpers.hpp b/sycl/source/detail/helpers.hpp index dba0cbd607515..13e0bc787d1da 100644 --- a/sycl/source/detail/helpers.hpp +++ b/sycl/source/detail/helpers.hpp @@ -6,12 +6,15 @@ // //===----------------------------------------------------------------------===// +#pragma once + #include #include #include #include +#include #include namespace sycl { @@ -26,6 +29,63 @@ class RTDeviceBinaryImage; std::tuple retrieveKernelBinary(queue_impl &Queue, KernelNameStrRefT KernelName, CGExecKernel *CGKernel = nullptr); + +template +class variadic_iterator { + using storage_iter = std::variant; + + storage_iter It; + +public: + template + variadic_iterator(IterTy &&It) : It(std::forward(It)) {} + + variadic_iterator &operator++() { + It = std::visit( + [](auto &&It) { + ++It; + return storage_iter{It}; + }, + It); + return *this; + } + bool operator!=(const variadic_iterator &Other) const { + return It != Other.It; + } + + decltype(auto) operator*() { + return std::visit( + [](auto &&It) -> decltype(auto) { + return DereferenceImpl::dereference(*It); + }, + It); + } +}; + +// Non-owning! +template class iterator_range { +public: + iterator_range(const iterator_range &Other) = default; + + template + iterator_range(IterTy Begin, IterTy End, size_t Size) + : Begin(Begin), End(End), Size(Size) {} + + template + iterator_range(const ContainerTy &Container) + : iterator_range(Container.begin(), Container.end(), Container.size()) {} + + iterator begin() const { return Begin; } + iterator end() const { return End; } + size_t size() const { return Size; } + bool empty() const { return Size == 0; } + decltype(auto) front() const { return *begin(); } + +private: + iterator Begin; + iterator End; + const size_t Size; +}; } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/persistent_device_code_cache.cpp b/sycl/source/detail/persistent_device_code_cache.cpp index 51f4570b26477..8f48f34247ccc 100644 --- a/sycl/source/detail/persistent_device_code_cache.cpp +++ b/sycl/source/detail/persistent_device_code_cache.cpp @@ -126,10 +126,10 @@ std::string getUniqueFilename(const std::string &base_name) { */ std::vector> getProgramBinaryData(const ur_program_handle_t &NativePrg, - const std::vector &Devices) { + devices_range Devices) { assert(!Devices.empty() && "At least one device is expected"); // We expect all devices to be from the same platform/adpater. - adapter_impl &Adapter = detail::getSyclObjImpl(Devices[0])->getAdapter(); + adapter_impl &Adapter = Devices.front().getAdapter(); unsigned int DeviceNum = 0; Adapter.call( NativePrg, UR_PROGRAM_INFO_NUM_DEVICES, sizeof(DeviceNum), &DeviceNum, @@ -159,17 +159,17 @@ getProgramBinaryData(const ur_program_handle_t &NativePrg, // Select only binaries for the input devices preserving one to one // correpsondence. std::vector> Result(Devices.size()); - for (size_t DeviceIndex = 0; DeviceIndex < Devices.size(); DeviceIndex++) { - auto DeviceIt = std::find_if( - URDevices.begin(), URDevices.end(), - [&Devices, &DeviceIndex](const ur_device_handle_t &URDevice) { - return URDevice == - detail::getSyclObjImpl(Devices[DeviceIndex])->getHandleRef(); - }); + auto ResultIt = Result.begin(); + for (device_impl &Device : Devices) { + auto DeviceIt = std::find_if(URDevices.begin(), URDevices.end(), + [&Device](const ur_device_handle_t &URDevice) { + return URDevice == Device.getHandleRef(); + }); assert(DeviceIt != URDevices.end() && "Device is not associated with the program"); auto URDeviceIndex = std::distance(URDevices.begin(), DeviceIt); - Result[DeviceIndex] = std::move(Binaries[URDeviceIndex]); + *ResultIt = std::move(Binaries[URDeviceIndex]); + ++ResultIt; } // Return binaries correpsonding to the input devices. @@ -433,8 +433,7 @@ void PersistentDeviceCodeCache::updateCacheFileSizeAndTriggerEviction( * device in the list to a separate file. */ void PersistentDeviceCodeCache::putItemToDisc( - const std::vector &Devices, - const std::vector &Imgs, + devices_range Devices, const std::vector &Imgs, const SerializedObj &SpecConsts, const std::string &BuildOptionsString, const ur_program_handle_t &NativePrg) { @@ -456,12 +455,13 @@ void PersistentDeviceCodeCache::putItemToDisc( // Total size of the item that we just wrote to the cache. size_t TotalSize = 0; - for (size_t DeviceIndex = 0; DeviceIndex < Devices.size(); DeviceIndex++) { + auto BinaryDataIt = BinaryData.begin(); + for (device_impl &Device : Devices) { // If we don't have binary for the device, skip it. - if (BinaryData[DeviceIndex].empty()) + if (BinaryDataIt->empty()) continue; - std::string DirName = getCacheItemPath(Devices[DeviceIndex], SortedImgs, - SpecConsts, BuildOptionsString); + std::string DirName = + getCacheItemPath(Device, SortedImgs, SpecConsts, BuildOptionsString); if (DirName.empty()) return; @@ -473,10 +473,10 @@ void PersistentDeviceCodeCache::putItemToDisc( LockCacheItem Lock{FileName}; if (Lock.isOwned()) { std::string FullFileName = FileName + ".bin"; - writeBinaryDataToFile(FullFileName, BinaryData[DeviceIndex]); + writeBinaryDataToFile(FullFileName, *BinaryDataIt); trace("device binary has been cached: ", FullFileName); - writeSourceItem(FileName + ".src", Devices[DeviceIndex], SortedImgs, - SpecConsts, BuildOptionsString); + writeSourceItem(FileName + ".src", Device, SortedImgs, SpecConsts, + BuildOptionsString); // Update Total cache size after adding the new items. TotalSize += getFileSize(FileName + ".src"); @@ -495,6 +495,7 @@ void PersistentDeviceCodeCache::putItemToDisc( std::string("error outputting persistent cache: ") + std::strerror(errno)); } + ++BinaryDataIt; } // Update the cache size file and trigger cache eviction if needed. @@ -503,7 +504,7 @@ void PersistentDeviceCodeCache::putItemToDisc( } void PersistentDeviceCodeCache::putCompiledKernelToDisc( - const std::vector &Devices, const std::string &BuildOptionsString, + devices_range Devices, const std::string &BuildOptionsString, const std::string &SourceStr, const ur_program_handle_t &NativePrg) { repopulateCacheSizeFile(getRootDir()); @@ -520,12 +521,13 @@ void PersistentDeviceCodeCache::putCompiledKernelToDisc( // Total size of the item that we are writing to the cache. size_t TotalSize = 0; - for (size_t DeviceIndex = 0; DeviceIndex < Devices.size(); DeviceIndex++) { + auto BinaryDataIt = BinaryData.begin(); + for (device_impl &Device : Devices) { // If we don't have binary for the device, skip it. - if (BinaryData[DeviceIndex].empty()) + if (BinaryDataIt->empty()) continue; - std::string DirName = getCompiledKernelItemPath( - Devices[DeviceIndex], BuildOptionsString, SourceStr); + std::string DirName = + getCompiledKernelItemPath(Device, BuildOptionsString, SourceStr); try { OSUtil::makeDir(DirName.c_str()); @@ -533,7 +535,7 @@ void PersistentDeviceCodeCache::putCompiledKernelToDisc( LockCacheItem Lock{FileName}; if (Lock.isOwned()) { std::string FullFileName = FileName + ".bin"; - writeBinaryDataToFile(FullFileName, BinaryData[DeviceIndex]); + writeBinaryDataToFile(FullFileName, *BinaryDataIt); PersistentDeviceCodeCache::trace_KernelCompiler( "binary has been cached: ", FullFileName); @@ -550,6 +552,7 @@ void PersistentDeviceCodeCache::putCompiledKernelToDisc( PersistentDeviceCodeCache::trace_KernelCompiler( std::string("error outputting cache: ") + std::strerror(errno)); } + ++BinaryDataIt; } // Update the cache size file and trigger cache eviction if needed. @@ -611,8 +614,7 @@ void PersistentDeviceCodeCache::putDeviceCodeIRToDisc( * devices. */ std::vector> PersistentDeviceCodeCache::getItemFromDisc( - const std::vector &Devices, - const std::vector &Imgs, + devices_range Devices, const std::vector &Imgs, const SerializedObj &SpecConsts, const std::string &BuildOptionsString) { assert(!Devices.empty()); if (!areImagesCacheable(Imgs)) @@ -621,9 +623,10 @@ std::vector> PersistentDeviceCodeCache::getItemFromDisc( std::vector SortedImgs = getSortedImages(Imgs); std::vector> Binaries(Devices.size()); std::string FileNames; - for (size_t DeviceIndex = 0; DeviceIndex < Devices.size(); DeviceIndex++) { - std::string Path = getCacheItemPath(Devices[DeviceIndex], SortedImgs, - SpecConsts, BuildOptionsString); + auto BinariesIt = Binaries.begin(); + for (device_impl &Device : Devices) { + std::string Path = + getCacheItemPath(Device, SortedImgs, SpecConsts, BuildOptionsString); if (Path.empty() || !OSUtil::isPathPresent(Path)) return {}; @@ -635,11 +638,11 @@ std::vector> PersistentDeviceCodeCache::getItemFromDisc( OSUtil::isPathPresent(FileName + ".src")) { if (!LockCacheItem::isLocked(FileName) && - isCacheItemSrcEqual(FileName + ".src", Devices[DeviceIndex], - SortedImgs, SpecConsts, BuildOptionsString)) { + isCacheItemSrcEqual(FileName + ".src", Device, SortedImgs, SpecConsts, + BuildOptionsString)) { try { std::string FullFileName = FileName + ".bin"; - Binaries[DeviceIndex] = readBinaryDataFromFile(FullFileName); + *BinariesIt = readBinaryDataFromFile(FullFileName); // Explicitly update the access time of the file. This is required for // eviction. @@ -655,8 +658,9 @@ std::vector> PersistentDeviceCodeCache::getItemFromDisc( FileName = Path + "/" + std::to_string(++i); } // If there is no binary for any device, return empty vector. - if (Binaries[DeviceIndex].empty()) + if (BinariesIt->empty()) return {}; + ++BinariesIt; } PersistentDeviceCodeCache::trace("using cached device binary: ", FileNames); return Binaries; @@ -667,14 +671,15 @@ std::vector> PersistentDeviceCodeCache::getItemFromDisc( */ std::vector> PersistentDeviceCodeCache::getCompiledKernelFromDisc( - const std::vector &Devices, const std::string &BuildOptionsString, + devices_range Devices, const std::string &BuildOptionsString, const std::string &SourceStr) { assert(!Devices.empty()); std::vector> Binaries(Devices.size()); std::string FileNames; - for (size_t DeviceIndex = 0; DeviceIndex < Devices.size(); DeviceIndex++) { - std::string DirName = getCompiledKernelItemPath( - Devices[DeviceIndex], BuildOptionsString, SourceStr); + auto BinariesIt = Binaries.begin(); + for (device_impl &Device : Devices) { + std::string DirName = + getCompiledKernelItemPath(Device, BuildOptionsString, SourceStr); if (DirName.empty() || !OSUtil::isPathPresent(DirName)) return {}; @@ -687,7 +692,7 @@ PersistentDeviceCodeCache::getCompiledKernelFromDisc( if (!LockCacheItem::isLocked(FileName)) { try { std::string FullFileName = FileName + ".bin"; - Binaries[DeviceIndex] = readBinaryDataFromFile(FullFileName); + *BinariesIt = readBinaryDataFromFile(FullFileName); // Explicitly update the access time of the file. This is required for // eviction. @@ -703,8 +708,9 @@ PersistentDeviceCodeCache::getCompiledKernelFromDisc( FileName = DirName + "/" + std::to_string(++i); } // If there is no binary for any device, return empty vector. - if (Binaries[DeviceIndex].empty()) + if (BinariesIt->empty()) return {}; + ++BinariesIt; } PersistentDeviceCodeCache::trace_KernelCompiler("using cached binary: ", FileNames); @@ -746,7 +752,7 @@ PersistentDeviceCodeCache::getDeviceCodeIRFromDisc(const std::string &Key) { /* Returns string value which can be used to identify different device */ -std::string PersistentDeviceCodeCache::getDeviceIDString(const device &Device) { +std::string PersistentDeviceCodeCache::getDeviceIDString(device_impl &Device) { return Device.get_platform().get_info() + "/" + Device.get_info() + "/" + Device.get_info() + "/" + @@ -814,7 +820,7 @@ PersistentDeviceCodeCache::readBinaryDataFromFile(const std::string &FileName) { * specialization constant values, device code SPIR-V images. */ void PersistentDeviceCodeCache::writeSourceItem( - const std::string &FileName, const device &Device, + const std::string &FileName, device_impl &Device, const std::vector &SortedImgs, const SerializedObj &SpecConsts, const std::string &BuildOptionsString) { std::ofstream FileStream{FileName, std::ios::binary}; @@ -850,7 +856,7 @@ void PersistentDeviceCodeCache::writeSourceItem( * If file read operations fail cache item is treated as not equal. */ bool PersistentDeviceCodeCache::isCacheItemSrcEqual( - const std::string &FileName, const device &Device, + const std::string &FileName, device_impl &Device, const std::vector &SortedImgs, const SerializedObj &SpecConsts, const std::string &BuildOptionsString) { std::ifstream FileStream{FileName, std::ios::binary}; @@ -900,7 +906,7 @@ bool PersistentDeviceCodeCache::isCacheItemSrcEqual( * device, build options and specialization constants values. */ std::string PersistentDeviceCodeCache::getCacheItemPath( - const device &Device, const std::vector &Imgs, + device_impl &Device, const std::vector &Imgs, const SerializedObj &SpecConsts, const std::string &BuildOptionsString) { std::string cache_root{getRootDir()}; if (cache_root.empty()) { @@ -926,7 +932,7 @@ std::string PersistentDeviceCodeCache::getCacheItemPath( } std::string PersistentDeviceCodeCache::getCompiledKernelItemPath( - const device &Device, const std::string &BuildOptionsString, + device_impl &Device, const std::string &BuildOptionsString, const std::string &SourceString) { std::string cache_root{getRootDir()}; diff --git a/sycl/source/detail/persistent_device_code_cache.hpp b/sycl/source/detail/persistent_device_code_cache.hpp index 0d712ec2cbe67..5d73db711d0cc 100644 --- a/sycl/source/detail/persistent_device_code_cache.hpp +++ b/sycl/source/detail/persistent_device_code_cache.hpp @@ -112,7 +112,7 @@ class PersistentDeviceCodeCache { * specialization constant values, device code SPIR-V images. */ static void - writeSourceItem(const std::string &FileName, const device &Device, + writeSourceItem(const std::string &FileName, device_impl &Device, const std::vector &SortedImgs, const SerializedObj &SpecConsts, const std::string &BuildOptionsString); @@ -120,12 +120,12 @@ class PersistentDeviceCodeCache { /* Check that cache item key sources are equal to the current program */ static bool isCacheItemSrcEqual( - const std::string &FileName, const device &Device, + const std::string &FileName, device_impl &Device, const std::vector &SortedImgs, const SerializedObj &SpecConsts, const std::string &BuildOptionsString); /* Form string representing device version */ - static std::string getDeviceIDString(const device &Device); + static std::string getDeviceIDString(device_impl &Device); /* Returns true if specified images should be cached on disk. It checks if * cache is enabled, images have SPIRV type and match thresholds. */ @@ -165,7 +165,7 @@ class PersistentDeviceCodeCache { /* Get directory name for storing current cache item */ static std::string - getCacheItemPath(const device &Device, + getCacheItemPath(device_impl &Device, const std::vector &SortedImgs, const SerializedObj &SpecConsts, const std::string &BuildOptionsString); @@ -174,7 +174,7 @@ class PersistentDeviceCodeCache { * kernel_compiler ). */ static std::string - getCompiledKernelItemPath(const device &Device, + getCompiledKernelItemPath(device_impl &Device, const std::string &BuildOptionsString, const std::string &SourceString); @@ -191,13 +191,13 @@ class PersistentDeviceCodeCache { * stored in vector of chars. */ static std::vector> - getItemFromDisc(const std::vector &Devices, + getItemFromDisc(devices_range Devices, const std::vector &Imgs, const SerializedObj &SpecConsts, const std::string &BuildOptionsString); static std::vector> - getCompiledKernelFromDisc(const std::vector &Devices, + getCompiledKernelFromDisc(devices_range Devices, const std::string &BuildOptionsString, const std::string &SourceStr); @@ -206,13 +206,13 @@ class PersistentDeviceCodeCache { /* Stores build program in persistent cache */ static void - putItemToDisc(const std::vector &Devices, + putItemToDisc(devices_range Devices, const std::vector &Imgs, const SerializedObj &SpecConsts, const std::string &BuildOptionsString, const ur_program_handle_t &NativePrg); - static void putCompiledKernelToDisc(const std::vector &Devices, + static void putCompiledKernelToDisc(devices_range Devices, const std::string &BuildOptionsString, const std::string &SourceStr, const ur_program_handle_t &NativePrg); diff --git a/sycl/unittests/kernel-and-program/PersistentDeviceCodeCache.cpp b/sycl/unittests/kernel-and-program/PersistentDeviceCodeCache.cpp index 5d75b63875fda..1ef47e28c0872 100644 --- a/sycl/unittests/kernel-and-program/PersistentDeviceCodeCache.cpp +++ b/sycl/unittests/kernel-and-program/PersistentDeviceCodeCache.cpp @@ -224,8 +224,8 @@ class PersistentDeviceCodeCache std::to_string(ThreadCount)}; DeviceCodeID = ProgramID; std::string ItemDir = detail::PersistentDeviceCodeCache::getCacheItemPath( - {Dev}, {&Img}, {'S', 'p', 'e', 'c', 'C', 'o', 'n', 's', 't', ProgramID}, - BuildOptions); + *getSyclObjImpl(Dev), {&Img}, + {'S', 'p', 'e', 'c', 'C', 'o', 'n', 's', 't', ProgramID}, BuildOptions); ASSERT_NO_ERROR(llvm::sys::fs::remove_directories(ItemDir)); Barrier b(ThreadCount); @@ -288,7 +288,7 @@ TEST_P(PersistentDeviceCodeCache, KeysWithNullTermSymbol) { std::string Key{'1', '\0', '3', '4', '\0'}; std::vector SpecConst(Key.begin(), Key.end()); std::string ItemDir = detail::PersistentDeviceCodeCache::getCacheItemPath( - Dev, {&Img}, SpecConst, Key); + *getSyclObjImpl(Dev), {&Img}, SpecConst, Key); ASSERT_NO_ERROR(llvm::sys::fs::remove_directories(ItemDir)); detail::PersistentDeviceCodeCache::putItemToDisc({Dev}, {&Img}, SpecConst, @@ -340,7 +340,7 @@ TEST_P(PersistentDeviceCodeCache, MultipleImages) { B->getRawData().EntriesBegin->GetName()) < 0; }); std::string ItemDir = detail::PersistentDeviceCodeCache::getCacheItemPath( - Dev, Imgs, {}, BuildOptions); + *getSyclObjImpl(Dev), Imgs, {}, BuildOptions); ASSERT_NO_ERROR(llvm::sys::fs::remove_directories(ItemDir)); detail::PersistentDeviceCodeCache::putItemToDisc({Dev}, Imgs, {}, @@ -393,7 +393,7 @@ TEST_P(PersistentDeviceCodeCache, ConcurentReadWriteCacheBigItem) { TEST_P(PersistentDeviceCodeCache, CorruptedCacheFiles) { std::string BuildOptions{"--corrupted-file"}; std::string ItemDir = detail::PersistentDeviceCodeCache::getCacheItemPath( - Dev, {&Img}, {}, BuildOptions); + *getSyclObjImpl(Dev), {&Img}, {}, BuildOptions); ASSERT_NO_ERROR(llvm::sys::fs::remove_directories(ItemDir)); // Only source file is present @@ -478,7 +478,7 @@ TEST_P(PersistentDeviceCodeCache, CorruptedCacheFiles) { TEST_P(PersistentDeviceCodeCache, LockFile) { std::string BuildOptions{"--obsolete-lock"}; std::string ItemDir = detail::PersistentDeviceCodeCache::getCacheItemPath( - Dev, {&Img}, {}, BuildOptions); + *getSyclObjImpl(Dev), {&Img}, {}, BuildOptions); ASSERT_NO_ERROR(llvm::sys::fs::remove_directories(ItemDir)); // Create 1st cahe item @@ -528,7 +528,7 @@ TEST_P(PersistentDeviceCodeCache, LockFile) { TEST_P(PersistentDeviceCodeCache, AccessDeniedForCacheDir) { std::string BuildOptions{"--build-options"}; std::string ItemDir = detail::PersistentDeviceCodeCache::getCacheItemPath( - Dev, {&Img}, {}, BuildOptions); + *getSyclObjImpl(Dev), {&Img}, {}, BuildOptions); ASSERT_NO_ERROR(llvm::sys::fs::remove_directories(ItemDir)); detail::PersistentDeviceCodeCache::putItemToDisc({Dev}, {&Img}, {}, BuildOptions, NativeProg); @@ -584,7 +584,7 @@ TEST_P(PersistentDeviceCodeCache, BasicEviction) { BuildOptions, NativeProg); std::string ItemDir = detail::PersistentDeviceCodeCache::getCacheItemPath( - Dev, {&Img}, {}, BuildOptions); + *getSyclObjImpl(Dev), {&Img}, {}, BuildOptions); size_t SizeOfOneEntry = (size_t)(detail::getDirectorySize(ItemDir)); detail::PersistentDeviceCodeCache::putItemToDisc({Dev}, {&Img}, {}, diff --git a/sycl/unittests/program_manager/MultipleDevsKernelBundle.cpp b/sycl/unittests/program_manager/MultipleDevsKernelBundle.cpp index 9ed055662167d..81ddb0af61454 100644 --- a/sycl/unittests/program_manager/MultipleDevsKernelBundle.cpp +++ b/sycl/unittests/program_manager/MultipleDevsKernelBundle.cpp @@ -574,7 +574,7 @@ TEST_P(MultipleDevsKernelBundleTest, DISABLED_PersistentCache) { sycl_device_binary Bin = &BinStruct; detail::RTDeviceBinaryImage RTBinImg{Bin}; auto Res = detail::PersistentDeviceCodeCache::getItemFromDisc( - {Devices[0], Devices[2]}, {&RTBinImg}, {}, {}); + std::vector{Devices[0], Devices[2]}, {&RTBinImg}, {}, {}); EXPECT_EQ(Res.size(), static_cast(2)) << "Expected cache items to be loaded";