Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions sycl/include/sycl/detail/kernel_name_str_t.hpp

This file was deleted.

7 changes: 3 additions & 4 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <sycl/detail/impl_utils.hpp>
#include <sycl/detail/kernel_desc.hpp>
#include <sycl/detail/kernel_launch_helper.hpp>
#include <sycl/detail/kernel_name_str_t.hpp>
#include <sycl/detail/reduction_forward.hpp>
#include <sycl/detail/string.hpp>
#include <sycl/detail/string_view.hpp>
Expand Down Expand Up @@ -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();
Comment on lines 530 to +532
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't you dropping this entire #ifndef?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's quite a lot of legacy code that would need to be removed alongside this, which I'd prefer to be done separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create a separate PR for this, to be landed before this one.


template <typename LambdaNameT> bool lambdaAndKernelHaveEqualName() {
// TODO It is unclear a kernel and a lambda/functor must to be equal or not
Expand All @@ -541,7 +540,7 @@ class __SYCL_EXPORT handler {
assert(MKernel && "MKernel is not initialized");
constexpr std::string_view LambdaName =
detail::CompileTimeKernelInfo<LambdaNameT>.Name;
detail::ABINeutralKernelNameStrT KernelName = getKernelName();
detail::string_view KernelName = getKernelName();
return KernelName == LambdaName;
}
#endif
Expand Down Expand Up @@ -3151,7 +3150,7 @@ class __SYCL_EXPORT handler {
#endif
std::vector<detail::LocalAccessorImplPtr> MLocalAccStorage;
std::vector<std::shared_ptr<detail::stream_impl>> MStreamStorage;
detail::ABINeutralKernelNameStrT MKernelName;
detail::string_view MKernelName;
/// Storage for a sycl::kernel object.
std::shared_ptr<detail::kernel_impl> MKernel;
/// Pointer to the source host memory or accessor(depending on command type).
Expand Down
6 changes: 3 additions & 3 deletions sycl/source/detail/device_global_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#pragma once

#include <mutex>
#include <string_view>
#include <unordered_map>

#include <detail/compiler.hpp>
#include <detail/device_binary_image.hpp>
#include <detail/device_global_map_entry.hpp>
#include <sycl/detail/defines_elementary.hpp>
#include <sycl/detail/kernel_name_str_t.hpp>
#include <sycl/kernel_bundle.hpp>

namespace sycl {
Expand Down Expand Up @@ -161,7 +161,7 @@ class DeviceGlobalMap {

size_t size() const { return MDeviceGlobals.size(); }

size_t count(const KernelNameStrT &UniqueId) const {
size_t count(const std::string_view &UniqueId) const {
return MDeviceGlobals.count(UniqueId);
}

Expand All @@ -173,7 +173,7 @@ class DeviceGlobalMap {
bool MOwnerControlledCleanup = true;

// Maps between device_global identifiers and associated information.
std::unordered_map<KernelNameStrT, std::unique_ptr<DeviceGlobalMapEntry>>
std::unordered_map<std::string_view, std::unique_ptr<DeviceGlobalMapEntry>>
MDeviceGlobals;
std::unordered_map<const void *, DeviceGlobalMapEntry *> MPtr2DeviceGlobal;

Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/device_image_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ std::shared_ptr<kernel_impl> 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<kernel_impl>(
std::move(UrKernel), *getSyclObjImpl(Context), shared_from_this(),
Expand Down
9 changes: 2 additions & 7 deletions sycl/source/detail/device_kernel_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions sycl/source/detail/device_kernel_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
#include <detail/kernel_arg_mask.hpp>
#include <hash_table8.hpp>
#include <sycl/detail/compile_time_kernel_info.hpp>
#include <sycl/detail/kernel_name_str_t.hpp>
#include <sycl/detail/spinlock.hpp>
#include <sycl/detail/ur.hpp>

#include <mutex>
#include <optional>
#include <string_view>

namespace sycl {
inline namespace _V1 {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions sycl/source/detail/handler_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ __SYCL_EXPORT void waitEvents(std::vector<sycl::event> 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;
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#pragma once

#include <sycl/detail/impl_utils.hpp>
#include <sycl/detail/kernel_name_str_t.hpp>
#include <sycl/detail/type_traits.hpp>

#include <ur_api.h>
Expand All @@ -18,6 +17,7 @@
#include <iterator>
#include <memory>
#include <queue>
#include <string_view>
#include <tuple>
#include <variant>
#include <vector>
Expand All @@ -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 <typename SyclTy, typename... Iterators> class variadic_iterator {
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/jit_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned char> &SpecConstBlob) {
#ifndef _WIN32
if (!BinImage) {
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/jit_compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <detail/jit_device_binaries.hpp>
#include <detail/queue_impl.hpp>
#include <sycl/detail/kernel_name_str_t.hpp>
#include <sycl/feature_test.hpp>
#if SYCL_EXT_JIT_ENABLE
#include <JITBinaryInfo.h>
Expand All @@ -21,6 +20,7 @@
#include <functional>
#include <memory>
#include <mutex>
#include <string_view>
#include <unordered_map>

namespace jit_compiler {
Expand All @@ -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<unsigned char> &SpecConstBlob);

std::pair<sycl_device_binaries, std::string> compileSYCL(
Expand Down
5 changes: 2 additions & 3 deletions sycl/source/detail/kernel_bundle_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <sycl/backend_types.hpp>
#include <sycl/context.hpp>
#include <sycl/detail/common.hpp>
#include <sycl/detail/kernel_name_str_t.hpp>
#include <sycl/device.hpp>
#include <sycl/kernel_bundle.hpp>

Expand All @@ -27,6 +26,7 @@
#include <cstdint>
#include <cstring>
#include <memory>
#include <string_view>
#include <unordered_set>
#include <vector>

Expand Down Expand Up @@ -987,8 +987,7 @@ class kernel_bundle_impl
std::move(SelectedImage), *this, ArgMask, UrProgram, CacheMutex);
}

std::shared_ptr<kernel_impl>
tryGetKernel(detail::KernelNameStrRefT Name) const {
std::shared_ptr<kernel_impl> 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.
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/kernel_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ class KernelData {
Kprop.get<cuda::cluster_size_key<3>>()->MProperty);
}

KernelNameStrRefT getKernelName() const {
std::string_view getKernelName() const {
assert(MDeviceKernelInfoPtr);
return static_cast<KernelNameStrRefT>(MDeviceKernelInfoPtr->Name);
return MDeviceKernelInfoPtr->Name;
}

void processArg(void *Ptr, const detail::kernel_param_kind_t &Kind,
Expand Down
8 changes: 6 additions & 2 deletions sycl/source/detail/kernel_id_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

#pragma once

#include <sycl/detail/kernel_name_str_t.hpp>
#include <sycl/kernel_bundle.hpp>

#include <cstring>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm somewhat surprised we need this.

#include <string>
#include <string_view>

namespace sycl {
inline namespace _V1 {
Expand All @@ -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(); }

Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/kernel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class kernel_impl {
return MIsInterop
? MInteropDeviceKernelInfo
: ProgramManager::getInstance().getOrCreateDeviceKernelInfo(
KernelNameStrT(getName()));
std::string_view(getName()));
}

private:
Expand Down
18 changes: 9 additions & 9 deletions sycl/source/detail/kernel_program_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <detail/platform_impl.hpp>
#include <detail/unordered_multimap.hpp>
#include <sycl/detail/common.hpp>
#include <sycl/detail/kernel_name_str_t.hpp>
#include <sycl/detail/locked.hpp>
#include <sycl/detail/os_util.hpp>
#include <sycl/detail/spinlock.hpp>
Expand Down Expand Up @@ -215,7 +214,7 @@ class KernelProgramCache {

using KernelCacheT = emhash8::HashMap<
ur_program_handle_t,
emhash8::HashMap<KernelNameStrT, std::shared_ptr<KernelBuildResult>>>;
emhash8::HashMap<std::string_view, std::shared_ptr<KernelBuildResult>>>;

class FastKernelSubcacheWrapper {
public:
Expand Down Expand Up @@ -260,7 +259,7 @@ class KernelProgramCache {
};

using FastKernelCacheT =
emhash8::HashMap<KernelNameStrT, FastKernelSubcacheWrapper>;
emhash8::HashMap<std::string_view, FastKernelSubcacheWrapper>;

// DS to hold data and functions related to Program cache eviction.
struct EvictionList {
Expand Down Expand Up @@ -365,7 +364,7 @@ class KernelProgramCache {
// set.
template <typename MsgType>
static inline void traceKernel(const MsgType &Msg,
KernelNameStrRefT KernelName,
std::string_view KernelName,
bool IsFastKernelCache = false) {
if (!SYCLConfig<SYCL_CACHE_TRACE>::isTraceInMemCache())
return;
Expand Down Expand Up @@ -430,7 +429,7 @@ class KernelProgramCache {
}

std::pair<std::shared_ptr<KernelBuildResult>, 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);
Expand All @@ -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};
Expand All @@ -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<SYCL_IN_MEM_CACHE_EVICTION_THRESHOLD>::
Expand Down Expand Up @@ -842,8 +841,9 @@ class KernelProgramCache {

// Map between fast kernel cache keys and program handle.
// MFastKernelCacheMutex will be used for synchronization.
std::unordered_map<ur_program_handle_t,
std::vector<std::pair<KernelNameStrT, ur_device_handle_t>>>
std::unordered_map<
ur_program_handle_t,
std::vector<std::pair<std::string_view, ur_device_handle_t>>>
MProgramToFastKernelCacheKeyMap;

EvictionList MEvictionList;
Expand Down
Loading
Loading