diff --git a/sycl/include/sycl/detail/kernel_name_str_t.hpp b/sycl/include/sycl/detail/kernel_name_str_t.hpp deleted file mode 100644 index e0079ffb09c7e..0000000000000 --- a/sycl/include/sycl/detail/kernel_name_str_t.hpp +++ /dev/null @@ -1,37 +0,0 @@ -//==---------- kernel_name_str_t.hpp ----- Kernel name type aliases --------==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -#pragma once - -#include -#include - -namespace sycl { -inline namespace _V1 { -namespace detail { - -#ifdef __INTEL_PREVIEW_BREAKING_CHANGES -using KernelNameStrT = std::string_view; -using KernelNameStrRefT = std::string_view; -using ABINeutralKernelNameStrT = detail::string_view; -#else -using KernelNameStrT = std::string; -using KernelNameStrRefT = const std::string &; -using ABINeutralKernelNameStrT = detail::string; -#endif - -inline KernelNameStrT toKernelNameStrT(const ABINeutralKernelNameStrT &str) { -#ifdef __INTEL_PREVIEW_BREAKING_CHANGES - return std::string_view(str); -#else - return str.data(); -#endif -} - -} // namespace detail -} // namespace _V1 -} // namespace sycl diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index d8d46d2a27814..b2d34d005a980 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -530,7 +529,7 @@ class __SYCL_EXPORT handler { #ifndef __INTEL_PREVIEW_BREAKING_CHANGES /// \return a string containing name of SYCL kernel. - detail::ABINeutralKernelNameStrT getKernelName(); + detail::string_view getKernelName(); template bool lambdaAndKernelHaveEqualName() { // TODO It is unclear a kernel and a lambda/functor must to be equal or not @@ -541,7 +540,7 @@ class __SYCL_EXPORT handler { assert(MKernel && "MKernel is not initialized"); constexpr std::string_view LambdaName = detail::CompileTimeKernelInfo.Name; - detail::ABINeutralKernelNameStrT KernelName = getKernelName(); + detail::string_view KernelName = getKernelName(); return KernelName == LambdaName; } #endif @@ -3151,7 +3150,9 @@ class __SYCL_EXPORT handler { #endif std::vector MLocalAccStorage; std::vector> MStreamStorage; - detail::ABINeutralKernelNameStrT MKernelName; + // std::string_view ABI differs under `-D_GLIBCXX_USE_CXX11_ABI=0`, + // use our implementation instead. + detail::string_view MKernelName; /// Storage for a sycl::kernel object. std::shared_ptr MKernel; /// Pointer to the source host memory or accessor(depending on command type). diff --git a/sycl/source/detail/device_global_map.hpp b/sycl/source/detail/device_global_map.hpp index 7dac09df41653..ea255bacda6ba 100644 --- a/sycl/source/detail/device_global_map.hpp +++ b/sycl/source/detail/device_global_map.hpp @@ -9,13 +9,13 @@ #pragma once #include +#include #include #include #include #include #include -#include #include namespace sycl { @@ -161,7 +161,7 @@ class DeviceGlobalMap { size_t size() const { return MDeviceGlobals.size(); } - size_t count(const KernelNameStrT &UniqueId) const { + size_t count(std::string_view UniqueId) const { return MDeviceGlobals.count(UniqueId); } @@ -173,7 +173,7 @@ class DeviceGlobalMap { bool MOwnerControlledCleanup = true; // Maps between device_global identifiers and associated information. - std::unordered_map> + std::unordered_map> MDeviceGlobals; std::unordered_map MPtr2DeviceGlobal; diff --git a/sycl/source/detail/device_image_impl.cpp b/sycl/source/detail/device_image_impl.cpp index e7a1319f98f27..2871f836f6aa3 100644 --- a/sycl/source/detail/device_image_impl.cpp +++ b/sycl/source/detail/device_image_impl.cpp @@ -32,7 +32,7 @@ std::shared_ptr device_image_impl::tryGetExtensionKernel( auto UrProgram = get_ur_program(); auto [UrKernel, CacheMutex, ArgMask] = - PM.getOrCreateKernel(Context, KernelNameStrT(AdjustedName), + PM.getOrCreateKernel(Context, AdjustedName, /*PropList=*/{}, UrProgram); return std::make_shared( std::move(UrKernel), *getSyclObjImpl(Context), shared_from_this(), diff --git a/sycl/source/detail/device_kernel_info.cpp b/sycl/source/detail/device_kernel_info.cpp index 790a7c9cbaafa..209a18cd7f96b 100644 --- a/sycl/source/detail/device_kernel_info.cpp +++ b/sycl/source/detail/device_kernel_info.cpp @@ -13,16 +13,11 @@ inline namespace _V1 { namespace detail { DeviceKernelInfo::DeviceKernelInfo(const CompileTimeKernelInfoTy &Info) - : CompileTimeKernelInfoTy(Info) -#ifndef __INTEL_PREVIEW_BREAKING_CHANGES - , - Name(Info.Name.data()) -#endif -{ + : CompileTimeKernelInfoTy(Info) { init(Name.data()); } -void DeviceKernelInfo::init(KernelNameStrRefT KernelName) { +void DeviceKernelInfo::init(std::string_view KernelName) { auto &PM = detail::ProgramManager::getInstance(); MImplicitLocalArgPos = PM.kernelImplicitLocalArgPos(KernelName); #ifndef __INTEL_PREVIEW_BREAKING_CHANGES diff --git a/sycl/source/detail/device_kernel_info.hpp b/sycl/source/detail/device_kernel_info.hpp index a91420ab5bc13..50f60e12be741 100644 --- a/sycl/source/detail/device_kernel_info.hpp +++ b/sycl/source/detail/device_kernel_info.hpp @@ -11,12 +11,12 @@ #include #include #include -#include #include #include #include #include +#include namespace sycl { inline namespace _V1 { @@ -89,18 +89,12 @@ struct FastKernelSubcacheT { // into this structure and get rid of the other KernelName -> * maps. class DeviceKernelInfo : public CompileTimeKernelInfoTy { public: -#ifndef __INTEL_PREVIEW_BREAKING_CHANGES - // Needs to own the kernel name string in non-preview builds since we pass it - // using a temporary string instead of a string view there. - std::string Name; -#endif - #ifndef __INTEL_PREVIEW_BREAKING_CHANGES DeviceKernelInfo() = default; #endif DeviceKernelInfo(const CompileTimeKernelInfoTy &Info); - void init(KernelNameStrRefT KernelName); + void init(std::string_view KernelName); #ifndef __INTEL_PREVIEW_BREAKING_CHANGES // Initialize default-created entry that has no data recorded: void initIfEmpty(const CompileTimeKernelInfoTy &Info); diff --git a/sycl/source/detail/handler_impl.hpp b/sycl/source/detail/handler_impl.hpp index d18dc7236790b..102dbf0f8776c 100644 --- a/sycl/source/detail/handler_impl.hpp +++ b/sycl/source/detail/handler_impl.hpp @@ -61,9 +61,7 @@ class handler_impl { HandlerSubmissionState::EXPLICIT_KERNEL_BUNDLE_STATE; } - KernelNameStrRefT getKernelName() const { - return MKernelData.getKernelName(); - } + std::string_view getKernelName() const { return MKernelData.getKernelName(); } /// Registers mutually exclusive submission states. HandlerSubmissionState MSubmissionState = HandlerSubmissionState::NO_STATE; diff --git a/sycl/source/detail/helpers.cpp b/sycl/source/detail/helpers.cpp index 0282ac28a0a79..680cd01c6305d 100644 --- a/sycl/source/detail/helpers.cpp +++ b/sycl/source/detail/helpers.cpp @@ -35,7 +35,7 @@ __SYCL_EXPORT void waitEvents(std::vector DepEvents) { #endif const RTDeviceBinaryImage *retrieveKernelBinary(queue_impl &Queue, - KernelNameStrRefT KernelName, + std::string_view KernelName, CGExecKernel *KernelCG) { device_impl &Dev = Queue.getDeviceImpl(); bool isNvidia = Dev.getBackend() == backend::ext_oneapi_cuda; diff --git a/sycl/source/detail/helpers.hpp b/sycl/source/detail/helpers.hpp index 3ad3645748339..23e7e1be54276 100644 --- a/sycl/source/detail/helpers.hpp +++ b/sycl/source/detail/helpers.hpp @@ -9,7 +9,6 @@ #pragma once #include -#include #include #include @@ -18,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -32,7 +32,7 @@ class queue_impl; class RTDeviceBinaryImage; const RTDeviceBinaryImage * -retrieveKernelBinary(queue_impl &Queue, KernelNameStrRefT KernelName, +retrieveKernelBinary(queue_impl &Queue, std::string_view KernelName, CGExecKernel *CGKernel = nullptr); template class variadic_iterator { diff --git a/sycl/source/detail/jit_compiler.cpp b/sycl/source/detail/jit_compiler.cpp index 2884e25399e5f..4da53bba6a18b 100644 --- a/sycl/source/detail/jit_compiler.cpp +++ b/sycl/source/detail/jit_compiler.cpp @@ -144,7 +144,7 @@ static ::jit_compiler::BinaryFormat getTargetFormat(queue_impl &Queue) { ur_kernel_handle_t jit_compiler::materializeSpecConstants( queue_impl &Queue, const RTDeviceBinaryImage *BinImage, - KernelNameStrRefT KernelName, + std::string_view KernelName, const std::vector &SpecConstBlob) { #ifndef _WIN32 if (!BinImage) { diff --git a/sycl/source/detail/jit_compiler.hpp b/sycl/source/detail/jit_compiler.hpp index ac3ebf7d73fa4..e37c9e4beb20a 100644 --- a/sycl/source/detail/jit_compiler.hpp +++ b/sycl/source/detail/jit_compiler.hpp @@ -10,7 +10,6 @@ #include #include -#include #include #if SYCL_EXT_JIT_ENABLE #include @@ -21,6 +20,7 @@ #include #include #include +#include #include namespace jit_compiler { @@ -41,7 +41,7 @@ class jit_compiler { ur_kernel_handle_t materializeSpecConstants(queue_impl &Queue, const RTDeviceBinaryImage *BinImage, - KernelNameStrRefT KernelName, + std::string_view KernelName, const std::vector &SpecConstBlob); std::pair compileSYCL( diff --git a/sycl/source/detail/kernel_bundle_impl.hpp b/sycl/source/detail/kernel_bundle_impl.hpp index 0c9222e9fa47b..76d478ec0ed72 100644 --- a/sycl/source/detail/kernel_bundle_impl.hpp +++ b/sycl/source/detail/kernel_bundle_impl.hpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include @@ -27,6 +26,7 @@ #include #include #include +#include #include #include @@ -987,8 +987,7 @@ class kernel_bundle_impl std::move(SelectedImage), *this, ArgMask, UrProgram, CacheMutex); } - std::shared_ptr - tryGetKernel(detail::KernelNameStrRefT Name) const { + std::shared_ptr tryGetKernel(std::string_view Name) const { // TODO: For source-based kernels, it may be faster to keep a map between // {kernel_name, device} and their corresponding image. // First look through the kernels registered in source-based images. diff --git a/sycl/source/detail/kernel_data.hpp b/sycl/source/detail/kernel_data.hpp index aebf7e245c1a3..b0ed3db0dface 100644 --- a/sycl/source/detail/kernel_data.hpp +++ b/sycl/source/detail/kernel_data.hpp @@ -306,9 +306,9 @@ class KernelData { Kprop.get>()->MProperty); } - KernelNameStrRefT getKernelName() const { + std::string_view getKernelName() const { assert(MDeviceKernelInfoPtr); - return static_cast(MDeviceKernelInfoPtr->Name); + return MDeviceKernelInfoPtr->Name; } void processArg(void *Ptr, const detail::kernel_param_kind_t &Kind, diff --git a/sycl/source/detail/kernel_id_impl.hpp b/sycl/source/detail/kernel_id_impl.hpp index 29ebfdc2aa85b..b75330fe23f82 100644 --- a/sycl/source/detail/kernel_id_impl.hpp +++ b/sycl/source/detail/kernel_id_impl.hpp @@ -8,7 +8,11 @@ #pragma once -#include +#include + +#include +#include +#include namespace sycl { inline namespace _V1 { @@ -33,7 +37,7 @@ struct EqualByNameComp { // identificator class kernel_id_impl { public: - kernel_id_impl(KernelNameStrT Name) : MName(std::move(Name)) {} + kernel_id_impl(std::string_view Name) : MName(std::move(Name)) {} kernel_id_impl(){}; const char *get_name() { return MName.data(); } diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index 7d83d4ecf68cc..1fda7c147cdf5 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -243,7 +243,7 @@ class kernel_impl { return MIsInterop ? MInteropDeviceKernelInfo : ProgramManager::getInstance().getOrCreateDeviceKernelInfo( - KernelNameStrT(getName())); + std::string_view(getName())); } private: diff --git a/sycl/source/detail/kernel_program_cache.hpp b/sycl/source/detail/kernel_program_cache.hpp index d0a6b398528c4..228d2e84d7cab 100644 --- a/sycl/source/detail/kernel_program_cache.hpp +++ b/sycl/source/detail/kernel_program_cache.hpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -215,7 +214,7 @@ class KernelProgramCache { using KernelCacheT = emhash8::HashMap< ur_program_handle_t, - emhash8::HashMap>>; + emhash8::HashMap>>; class FastKernelSubcacheWrapper { public: @@ -260,7 +259,7 @@ class KernelProgramCache { }; using FastKernelCacheT = - emhash8::HashMap; + emhash8::HashMap; // DS to hold data and functions related to Program cache eviction. struct EvictionList { @@ -365,7 +364,7 @@ class KernelProgramCache { // set. template static inline void traceKernel(const MsgType &Msg, - KernelNameStrRefT KernelName, + std::string_view KernelName, bool IsFastKernelCache = false) { if (!SYCLConfig::isTraceInMemCache()) return; @@ -430,7 +429,7 @@ class KernelProgramCache { } std::pair, bool> - getOrInsertKernel(ur_program_handle_t Program, KernelNameStrRefT KernelName) { + getOrInsertKernel(ur_program_handle_t Program, std::string_view KernelName) { auto LockedCache = acquireKernelsPerProgramCache(); auto &Cache = LockedCache.get()[Program]; auto [It, DidInsert] = Cache.try_emplace(KernelName, nullptr); @@ -443,7 +442,7 @@ class KernelProgramCache { } FastKernelCacheValPtr - tryToGetKernelFast(KernelNameStrRefT KernelName, ur_device_handle_t Device, + tryToGetKernelFast(std::string_view KernelName, ur_device_handle_t Device, FastKernelSubcacheT &KernelSubcache) { const FastKernelSubcacheEntriesT &SubcacheEntries = KernelSubcache.Entries; FastKernelSubcacheReadLockT SubcacheLock{KernelSubcache.Mutex}; @@ -462,7 +461,7 @@ class KernelProgramCache { return FastKernelCacheValPtr(); } - void saveKernel(KernelNameStrRefT KernelName, ur_device_handle_t Device, + void saveKernel(std::string_view KernelName, ur_device_handle_t Device, const FastKernelCacheValPtr &CacheVal, FastKernelSubcacheT &KernelSubcache) { if (SYCLConfig:: @@ -842,8 +841,9 @@ class KernelProgramCache { // Map between fast kernel cache keys and program handle. // MFastKernelCacheMutex will be used for synchronization. - std::unordered_map>> + std::unordered_map< + ur_program_handle_t, + std::vector>> MProgramToFastKernelCacheKeyMap; EvictionList MEvictionList; diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 24d0aef5754f1..9d81d07275685 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -838,7 +838,7 @@ static void setSpecializationConstants(device_image_impl &InputImpl, // its ref count incremented. Managed ProgramManager::getBuiltURProgram( context_impl &ContextImpl, device_impl &DeviceImpl, - KernelNameStrRefT KernelName, const NDRDescT &NDRDesc) { + std::string_view KernelName, const NDRDescT &NDRDesc) { device_impl *BuildDev = &DeviceImpl; // Check if we can optimize program builds for sub-devices by using a program // built for the root device @@ -1094,13 +1094,7 @@ FastKernelCacheValPtr ProgramManager::getOrCreateKernel( Managed Program = getBuiltURProgram( ContextImpl, DeviceImpl, DeviceKernelInfo.Name, NDRDesc); - -#ifdef __INTEL_PREVIEW_BREAKING_CHANGES -// Simplify this once `DeviceKernelInfo.Name`'s type is known. -// Using `decltype(auto)` instead of just `auto` to get reference when -// possible. -#endif - decltype(auto) KernelName = KernelNameStrRefT{DeviceKernelInfo.Name}; + std::string_view KernelName = DeviceKernelInfo.Name; auto BuildF = [this, &Program, &KernelName, &ContextImpl] { adapter_impl &Adapter = ContextImpl.getAdapter(); Managed Kernel{Adapter}; @@ -1498,7 +1492,7 @@ const RTDeviceBinaryImage *getBinImageFromMultiMap( } const RTDeviceBinaryImage & -ProgramManager::getDeviceImage(KernelNameStrRefT KernelName, +ProgramManager::getDeviceImage(std::string_view KernelName, context_impl &ContextImpl, const device_impl &DeviceImpl) { if constexpr (DbgProgMgr > 0) { @@ -1804,17 +1798,16 @@ void ProgramManager::cacheKernelImplicitLocalArg( DeviceKernelInfo &ProgramManager::getOrCreateDeviceKernelInfo( const CompileTimeKernelInfoTy &Info) { std::lock_guard Guard(m_DeviceKernelInfoMapMutex); - auto [Iter, Inserted] = - m_DeviceKernelInfoMap.try_emplace(KernelNameStrT{Info.Name.data()}, Info); + auto [Iter, Inserted] = m_DeviceKernelInfoMap.try_emplace(Info.Name, Info); if (!Inserted) Iter->second.setCompileTimeInfoIfNeeded(Info); return Iter->second; } DeviceKernelInfo & -ProgramManager::getOrCreateDeviceKernelInfo(KernelNameStrRefT KernelName) { +ProgramManager::getOrCreateDeviceKernelInfo(std::string_view KernelName) { std::lock_guard Guard(m_DeviceKernelInfoMapMutex); - CompileTimeKernelInfoTy DefaultCompileTimeInfo{std::string_view(KernelName)}; + CompileTimeKernelInfoTy DefaultCompileTimeInfo{KernelName}; auto Result = m_DeviceKernelInfoMap.try_emplace(KernelName, DefaultCompileTimeInfo); return Result.first->second; @@ -2190,7 +2183,7 @@ void ProgramManager::removeImages(sycl_device_binaries DeviceBinary) { // Unmap the unique kernel IDs for the offload entries for (sycl_offload_entry EntriesIt = EntriesB; EntriesIt != EntriesE; EntriesIt = EntriesIt->Increment()) { - detail::KernelNameStrT Name = EntriesIt->GetName(); + std::string_view Name = EntriesIt->GetName(); // Exported device functions won't have a kernel ID if (m_ExportedSymbolImages.find(std::string(Name)) != m_ExportedSymbolImages.end()) { @@ -2279,7 +2272,7 @@ uint32_t ProgramManager::getDeviceLibReqMask(const RTDeviceBinaryImage &Img) { const KernelArgMask * ProgramManager::getEliminatedKernelArgMask(ur_program_handle_t NativePrg, - KernelNameStrRefT KernelName) { + std::string_view KernelName) { // Bail out if there are no eliminated kernel arg masks in our images if (m_EliminatedKernelArgMasks.empty()) return nullptr; @@ -2347,13 +2340,14 @@ std::vector ProgramManager::getAllSYCLKernelIDs() { std::vector AllKernelIDs; AllKernelIDs.reserve(m_KernelName2KernelIDs.size()); - for (std::pair KernelID : m_KernelName2KernelIDs) { + for (std::pair KernelID : + m_KernelName2KernelIDs) { AllKernelIDs.push_back(KernelID.second); } return AllKernelIDs; } -kernel_id ProgramManager::getBuiltInKernelID(KernelNameStrRefT KernelName) { +kernel_id ProgramManager::getBuiltInKernelID(std::string_view KernelName) { std::lock_guard BuiltInKernelIDsGuard(m_BuiltInKernelIDsMutex); auto KernelID = m_BuiltInKernelIDs.find(KernelName); @@ -3131,7 +3125,7 @@ ProgramManager::build(const DevImgPlainWithDeps &DevImgWithDeps, // its ref count incremented. std::tuple, std::mutex *, const KernelArgMask *> ProgramManager::getOrCreateKernel(const context &Context, - KernelNameStrRefT KernelName, + std::string_view KernelName, const property_list &PropList, ur_program_handle_t Program) { @@ -3193,7 +3187,7 @@ ProgramManager::getOrCreateKernel(const context &Context, } ur_kernel_handle_t ProgramManager::getCachedMaterializedKernel( - KernelNameStrRefT KernelName, + std::string_view KernelName, const std::vector &SpecializationConsts) { if constexpr (DbgProgMgr > 0) std::cerr << ">>> ProgramManager::getCachedMaterializedKernel\n" @@ -3224,7 +3218,7 @@ ur_kernel_handle_t ProgramManager::getCachedMaterializedKernel( ur_kernel_handle_t ProgramManager::getOrCreateMaterializedKernel( const RTDeviceBinaryImage &Img, const context &Context, - const device &Device, KernelNameStrRefT KernelName, + const device &Device, std::string_view KernelName, const std::vector &SpecializationConsts) { // Check if we already have the kernel in the cache. if constexpr (DbgProgMgr > 0) diff --git a/sycl/source/detail/program_manager/program_manager.hpp b/sycl/source/detail/program_manager/program_manager.hpp index 94c6114c9dbc2..088b579f36f86 100644 --- a/sycl/source/detail/program_manager/program_manager.hpp +++ b/sycl/source/detail/program_manager/program_manager.hpp @@ -138,7 +138,7 @@ class ProgramManager { return GlobalHandler::instance().getProgramManager(); } - const RTDeviceBinaryImage &getDeviceImage(KernelNameStrRefT KernelName, + const RTDeviceBinaryImage &getDeviceImage(std::string_view KernelName, context_impl &ContextImpl, const device_impl &DeviceImpl); @@ -182,7 +182,7 @@ class ProgramManager { /// \param KernelName the kernel's name Managed getBuiltURProgram(context_impl &ContextImpl, device_impl &DeviceImpl, - KernelNameStrRefT KernelName, + std::string_view KernelName, const NDRDescT &NDRDesc = {}); /// Builds a program from a given set of images or retrieves that program from @@ -207,12 +207,12 @@ class ProgramManager { const NDRDescT &NDRDesc = {}); ur_kernel_handle_t getCachedMaterializedKernel( - KernelNameStrRefT KernelName, + std::string_view KernelName, const std::vector &SpecializationConsts); ur_kernel_handle_t getOrCreateMaterializedKernel( const RTDeviceBinaryImage &Img, const context &Context, - const device &Device, KernelNameStrRefT KernelName, + const device &Device, std::string_view KernelName, const std::vector &SpecializationConsts); ur_program_handle_t getUrProgramFromUrKernel(ur_kernel_handle_t Kernel, @@ -234,11 +234,11 @@ class ProgramManager { /// \param NativePrg the UR program associated with the kernel. /// \param KernelName the name of the kernel. const KernelArgMask *getEliminatedKernelArgMask(ur_program_handle_t NativePrg, - KernelNameStrRefT KernelName); + std::string_view KernelName); // The function returns the unique SYCL kernel identifier associated with a // kernel name or nullopt if there is no such ID. - std::optional tryGetSYCLKernelID(KernelNameStrRefT KernelName) { + std::optional tryGetSYCLKernelID(std::string_view KernelName) { std::lock_guard KernelIDsGuard(m_KernelIDsMutex); auto KernelID = m_KernelName2KernelIDs.find(KernelName); @@ -250,7 +250,7 @@ class ProgramManager { // The function returns the unique SYCL kernel identifier associated with a // kernel name or throws a sycl exception if there is no such ID. - kernel_id getSYCLKernelID(KernelNameStrRefT KernelName) { + kernel_id getSYCLKernelID(std::string_view KernelName) { if (std::optional MaybeKernelID = tryGetSYCLKernelID(KernelName)) return *MaybeKernelID; throw exception(make_error_code(errc::runtime), @@ -263,7 +263,7 @@ class ProgramManager { // The function returns the unique SYCL kernel identifier associated with a // built-in kernel name. - kernel_id getBuiltInKernelID(KernelNameStrRefT KernelName); + kernel_id getBuiltInKernelID(std::string_view KernelName); // The function inserts or initializes a device_global entry into the // device_global map. @@ -381,7 +381,7 @@ class ProgramManager { devices_range Devs, const property_list &PropList); std::tuple, std::mutex *, const KernelArgMask *> - getOrCreateKernel(const context &Context, KernelNameStrRefT KernelName, + getOrCreateKernel(const context &Context, std::string_view KernelName, const property_list &PropList, ur_program_handle_t Program); ProgramManager(); @@ -390,7 +390,7 @@ class ProgramManager { SanitizerType kernelUsesSanitizer() const { return m_SanitizerFoundInImage; } std::optional - kernelImplicitLocalArgPos(KernelNameStrRefT KernelName) const { + kernelImplicitLocalArgPos(std::string_view KernelName) const { auto it = m_KernelImplicitLocalArgPos.find(KernelName); if (it != m_KernelImplicitLocalArgPos.end()) return it->second; @@ -399,7 +399,7 @@ class ProgramManager { DeviceKernelInfo & getOrCreateDeviceKernelInfo(const CompileTimeKernelInfoTy &Info); - DeviceKernelInfo &getOrCreateDeviceKernelInfo(KernelNameStrRefT KernelName); + DeviceKernelInfo &getOrCreateDeviceKernelInfo(std::string_view KernelName); std::set getRawDeviceImages(const std::vector &KernelIDs); @@ -449,7 +449,7 @@ class ProgramManager { /// when C++20 is enabled for the runtime library. /// Access must be guarded by the m_KernelIDsMutex mutex. // - std::unordered_map m_KernelName2KernelIDs; + std::unordered_map m_KernelName2KernelIDs; // Maps KernelIDs to device binary images. There can be more than one image // in case of SPIRV + AOT. @@ -476,7 +476,7 @@ class ProgramManager { /// Used for checking if the last image referencing the kernel name /// is removed in order to trigger cleanup of kernel specific information. /// Access must be guarded by the m_KernelIDsMutex mutex. - std::unordered_map m_KernelNameRefCount; + std::unordered_map m_KernelNameRefCount; /// Caches all exported symbols to allow faster lookup when excluding these /// from kernel bundles. @@ -494,7 +494,7 @@ class ProgramManager { /// Maps names of built-in kernels to their unique kernel IDs. /// Access must be guarded by the m_BuiltInKernelIDsMutex mutex. - std::unordered_map m_BuiltInKernelIDs; + std::unordered_map m_BuiltInKernelIDs; /// Caches list of device images that use or provide virtual functions from /// the same set. Used to simplify access. @@ -527,7 +527,7 @@ class ProgramManager { std::mutex MNativeProgramsMutex; using KernelNameToArgMaskMap = - std::unordered_map; + std::unordered_map; /// Maps binary image and kernel name pairs to kernel argument masks which /// specify which arguments were eliminated during device code optimization. std::unordered_map @@ -541,11 +541,11 @@ class ProgramManager { // different types without temporary key_type object creation. This includes // standard overloads, such as comparison between std::string and // std::string_view or just char*. - std::unordered_map m_KernelImplicitLocalArgPos; + std::unordered_map m_KernelImplicitLocalArgPos; // Map for storing device kernel information. Runtime lookup should be avoided // by caching the pointers when possible. - std::unordered_map m_DeviceKernelInfoMap; + std::unordered_map m_DeviceKernelInfoMap; // Protects m_DeviceKernelInfoMap. std::mutex m_DeviceKernelInfoMapMutex; @@ -572,7 +572,8 @@ class ProgramManager { using MaterializedEntries = std::map, Managed>; - std::unordered_map m_MaterializedKernels; + std::unordered_map + m_MaterializedKernels; // Holds bfloat16 device library images, the 1st element is for fallback // version and 2nd is for native version. These bfloat16 device library diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index e13e445c9fe59..b2422958ed1d5 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -3330,7 +3330,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { const std::shared_ptr &SyclKernel = ExecKernel->MSyclKernel; - KernelNameStrRefT KernelName = ExecKernel->MDeviceKernelInfo.Name; + std::string_view KernelName = ExecKernel->MDeviceKernelInfo.Name; const RTDeviceBinaryImage *BinImage = nullptr; if (detail::SYCLConfig::get()) { BinImage = retrieveKernelBinary(*MQueue, KernelName); diff --git a/sycl/source/detail/scheduler/scheduler.cpp b/sycl/source/detail/scheduler/scheduler.cpp index 58c815a828cb2..75b1a3c7e605a 100644 --- a/sycl/source/detail/scheduler/scheduler.cpp +++ b/sycl/source/detail/scheduler/scheduler.cpp @@ -625,7 +625,7 @@ void Scheduler::cleanupAuxiliaryResources(BlockingT Blocking) { ur_kernel_handle_t Scheduler::completeSpecConstMaterialization( [[maybe_unused]] queue_impl &Queue, [[maybe_unused]] const RTDeviceBinaryImage *BinImage, - [[maybe_unused]] KernelNameStrRefT KernelName, + [[maybe_unused]] std::string_view KernelName, [[maybe_unused]] std::vector &SpecConstBlob) { #if SYCL_EXT_JIT_ENABLE && !_WIN32 return detail::jit_compiler::get_instance().materializeSpecConstants( diff --git a/sycl/source/detail/scheduler/scheduler.hpp b/sycl/source/detail/scheduler/scheduler.hpp index 1ca796ee20efb..31a0ce8e55f4d 100644 --- a/sycl/source/detail/scheduler/scheduler.hpp +++ b/sycl/source/detail/scheduler/scheduler.hpp @@ -460,7 +460,7 @@ class Scheduler { ur_kernel_handle_t completeSpecConstMaterialization( queue_impl &Queue, const RTDeviceBinaryImage *BinImage, - KernelNameStrRefT KernelName, std::vector &SpecConstBlob); + std::string_view KernelName, std::vector &SpecConstBlob); void releaseResources(BlockingT Blocking = BlockingT::BLOCKING); bool isDeferredMemObjectsEmpty(); diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index fbcd88f1bd42a..db0a45b8aa396 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -569,7 +569,7 @@ event handler::finalize() { // in kernel bundle or free function cases). impl->MKernelData.setDeviceKernelInfoPtr( &detail::ProgramManager::getInstance().getOrCreateDeviceKernelInfo( - toKernelNameStrT(MKernelName))); + std::string_view(MKernelName))); } assert(impl->MKernelData.getKernelName() == MKernelName); @@ -985,7 +985,7 @@ void handler::extractArgsAndReqs() { if (impl->MKernelData.getDeviceKernelInfoPtr() == nullptr) { impl->MKernelData.setDeviceKernelInfoPtr( &detail::ProgramManager::getInstance().getOrCreateDeviceKernelInfo( - detail::toKernelNameStrT(MKernel->getName()))); + std::string_view(MKernel->getName()))); } #endif assert(impl->MKernelData.getDeviceKernelInfoPtr() != nullptr); @@ -1054,9 +1054,7 @@ void handler::extractArgsAndReqsFromLambda( // Calling methods of kernel_impl requires knowledge of class layout. // As this is impossible in header, there's a function that calls necessary // method inside the library and returns the result. -detail::ABINeutralKernelNameStrT handler::getKernelName() { - return MKernel->getName(); -} +detail::string_view handler::getKernelName() { return MKernel->getName(); } #endif void handler::verifyUsedKernelBundleInternal(detail::string_view KernelName) { diff --git a/sycl/test/abi/layout_handler.cpp b/sycl/test/abi/layout_handler.cpp index f312eb4a03485..bbdb29653d794 100644 --- a/sycl/test/abi/layout_handler.cpp +++ b/sycl/test/abi/layout_handler.cpp @@ -40,8 +40,8 @@ void foo() { // CHECK: 56 | pointer _M_start // CHECK-NEXT: 64 | pointer _M_finish // CHECK-NEXT: 72 | pointer _M_end_of_storage -// CHECK-NEXT: 80 | class sycl::detail::string MKernelName -// CHECK-NEXT: 80 | char * str +// CHECK-NEXT: 80 | class sycl::detail::string_view MKernelName +// CHECK-NEXT: 80 | const char * str // CHECK-NEXT: 88 | class std::shared_ptr MKernel // CHECK-NEXT: 88 | class std::__shared_ptr (base) // CHECK-NEXT: 88 | class std::__shared_ptr_access (base) (empty) diff --git a/sycl/test/include_deps/sycl_detail_core.hpp.cpp b/sycl/test/include_deps/sycl_detail_core.hpp.cpp index a0bc25739c465..c4402145c2fed 100644 --- a/sycl/test/include_deps/sycl_detail_core.hpp.cpp +++ b/sycl/test/include_deps/sycl_detail_core.hpp.cpp @@ -142,7 +142,6 @@ // CHECK-NEXT: ext/oneapi/kernel_properties/properties.hpp // CHECK-NEXT: ext/oneapi/work_group_scratch_memory.hpp // CHECK-NEXT: detail/sycl_local_mem_builtins.hpp -// CHECK-NEXT: detail/kernel_name_str_t.hpp // CHECK-NEXT: detail/reduction_forward.hpp // CHECK-NEXT: detail/ur.hpp // CHECK-NEXT: ur_api_funcs.def diff --git a/sycl/test/include_deps/sycl_khr_includes_handler.hpp.cpp b/sycl/test/include_deps/sycl_khr_includes_handler.hpp.cpp index 862394bd4f656..d4ce56093ee33 100644 --- a/sycl/test/include_deps/sycl_khr_includes_handler.hpp.cpp +++ b/sycl/test/include_deps/sycl_khr_includes_handler.hpp.cpp @@ -132,7 +132,6 @@ // CHECK-NEXT: ext/oneapi/kernel_properties/properties.hpp // CHECK-NEXT: ext/oneapi/work_group_scratch_memory.hpp // CHECK-NEXT: detail/sycl_local_mem_builtins.hpp -// CHECK-NEXT: detail/kernel_name_str_t.hpp // CHECK-NEXT: detail/reduction_forward.hpp // CHECK-NEXT: detail/ur.hpp // CHECK-NEXT: ur_api_funcs.def diff --git a/sycl/test/include_deps/sycl_khr_includes_kernel_bundle.hpp.cpp b/sycl/test/include_deps/sycl_khr_includes_kernel_bundle.hpp.cpp index 7f606a58d8a68..778cfe3a44218 100644 --- a/sycl/test/include_deps/sycl_khr_includes_kernel_bundle.hpp.cpp +++ b/sycl/test/include_deps/sycl_khr_includes_kernel_bundle.hpp.cpp @@ -140,7 +140,6 @@ // CHECK-NEXT: ext/oneapi/kernel_properties/properties.hpp // CHECK-NEXT: ext/oneapi/work_group_scratch_memory.hpp // CHECK-NEXT: detail/sycl_local_mem_builtins.hpp -// CHECK-NEXT: detail/kernel_name_str_t.hpp // CHECK-NEXT: detail/reduction_forward.hpp // CHECK-NEXT: event.hpp // CHECK-NEXT: ext/oneapi/bindless_images_interop.hpp diff --git a/sycl/test/include_deps/sycl_khr_includes_queue.hpp.cpp b/sycl/test/include_deps/sycl_khr_includes_queue.hpp.cpp index 9cd74ac24ca78..1e802778463f8 100644 --- a/sycl/test/include_deps/sycl_khr_includes_queue.hpp.cpp +++ b/sycl/test/include_deps/sycl_khr_includes_queue.hpp.cpp @@ -146,7 +146,6 @@ // CHECK-NEXT: ext/oneapi/kernel_properties/properties.hpp // CHECK-NEXT: ext/oneapi/work_group_scratch_memory.hpp // CHECK-NEXT: detail/sycl_local_mem_builtins.hpp -// CHECK-NEXT: detail/kernel_name_str_t.hpp // CHECK-NEXT: detail/reduction_forward.hpp // CHECK-NEXT: detail/ur.hpp // CHECK-NEXT: ur_api_funcs.def diff --git a/sycl/test/include_deps/sycl_khr_includes_reduction.hpp.cpp b/sycl/test/include_deps/sycl_khr_includes_reduction.hpp.cpp index 65e5d95389e72..b50ef1bb00635 100644 --- a/sycl/test/include_deps/sycl_khr_includes_reduction.hpp.cpp +++ b/sycl/test/include_deps/sycl_khr_includes_reduction.hpp.cpp @@ -168,7 +168,6 @@ // CHECK-NEXT: ext/oneapi/kernel_properties/properties.hpp // CHECK-NEXT: ext/oneapi/work_group_scratch_memory.hpp // CHECK-NEXT: detail/sycl_local_mem_builtins.hpp -// CHECK-NEXT: detail/kernel_name_str_t.hpp // CHECK-NEXT: detail/ur.hpp // CHECK-NEXT: ur_api_funcs.def // CHECK-NEXT: ext/oneapi/bindless_images_interop.hpp diff --git a/sycl/test/include_deps/sycl_khr_includes_stream.hpp.cpp b/sycl/test/include_deps/sycl_khr_includes_stream.hpp.cpp index efaf1605c801f..eff103e93f136 100644 --- a/sycl/test/include_deps/sycl_khr_includes_stream.hpp.cpp +++ b/sycl/test/include_deps/sycl_khr_includes_stream.hpp.cpp @@ -151,7 +151,6 @@ // CHECK-NEXT: ext/oneapi/kernel_properties/properties.hpp // CHECK-NEXT: ext/oneapi/work_group_scratch_memory.hpp // CHECK-NEXT: detail/sycl_local_mem_builtins.hpp -// CHECK-NEXT: detail/kernel_name_str_t.hpp // CHECK-NEXT: detail/reduction_forward.hpp // CHECK-NEXT: detail/ur.hpp // CHECK-NEXT: ur_api_funcs.def diff --git a/sycl/test/include_deps/sycl_khr_includes_usm.hpp.cpp b/sycl/test/include_deps/sycl_khr_includes_usm.hpp.cpp index 5534c9b9fe6ee..929c372167d8b 100644 --- a/sycl/test/include_deps/sycl_khr_includes_usm.hpp.cpp +++ b/sycl/test/include_deps/sycl_khr_includes_usm.hpp.cpp @@ -161,7 +161,6 @@ // CHECK-NEXT: ext/oneapi/kernel_properties/properties.hpp // CHECK-NEXT: ext/oneapi/work_group_scratch_memory.hpp // CHECK-NEXT: detail/sycl_local_mem_builtins.hpp -// CHECK-NEXT: detail/kernel_name_str_t.hpp // CHECK-NEXT: detail/reduction_forward.hpp // CHECK-NEXT: detail/ur.hpp // CHECK-NEXT: ur_api_funcs.def diff --git a/sycl/unittests/program_manager/Cleanup.cpp b/sycl/unittests/program_manager/Cleanup.cpp index fa5b356b13eee..083fdf05adc17 100644 --- a/sycl/unittests/program_manager/Cleanup.cpp +++ b/sycl/unittests/program_manager/Cleanup.cpp @@ -18,7 +18,7 @@ class ProgramManagerExposed : public sycl::detail::ProgramManager { return m_KernelIDs2BinImage; } - std::unordered_map & + std::unordered_map & getKernelName2KernelID() { return m_KernelName2KernelIDs; } @@ -55,26 +55,23 @@ class ProgramManagerExposed : public sycl::detail::ProgramManager { return NativePrograms; } - std::unordered_map & + std::unordered_map & getDeviceKernelInfoMap() { return m_DeviceKernelInfoMap; } - std::unordered_map & - getKernelNameRefCount() { + std::unordered_map &getKernelNameRefCount() { return m_KernelNameRefCount; } - std::unordered_map> & + std::unordered_map< + const sycl::detail::RTDeviceBinaryImage *, + std::unordered_map> & getEliminatedKernelArgMask() { return m_EliminatedKernelArgMasks; } - std::unordered_map & - getKernelImplicitLocalArgPos() { + std::unordered_map &getKernelImplicitLocalArgPos() { return m_KernelImplicitLocalArgPos; } diff --git a/sycl/unittests/scheduler/SchedulerTestUtils.hpp b/sycl/unittests/scheduler/SchedulerTestUtils.hpp index 209b2de30fe8a..271237e15f374 100644 --- a/sycl/unittests/scheduler/SchedulerTestUtils.hpp +++ b/sycl/unittests/scheduler/SchedulerTestUtils.hpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include