Skip to content

[SYCL] Get rid of vector reallocations for kernel name caches #18539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 3 additions & 5 deletions sycl/source/detail/global_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,10 @@ ThreadPool &GlobalHandler::getHostTaskThreadPool() {
}

KernelNameBasedCacheT *GlobalHandler::createKernelNameBasedCache() {
static std::vector<std::unique_ptr<KernelNameBasedCacheT>>
&KernelNameBasedCaches = getOrCreate(MKernelNameBasedCaches);
static std::deque<KernelNameBasedCacheT> &KernelNameBasedCaches =
getOrCreate(MKernelNameBasedCaches);
LockGuard LG{MKernelNameBasedCaches.Lock};
return KernelNameBasedCaches
.emplace_back(std::make_unique<KernelNameBasedCacheT>())
.get();
return &KernelNameBasedCaches.emplace_back();
}

void GlobalHandler::releaseDefaultContexts() {
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/global_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <sycl/detail/spinlock.hpp>
#include <sycl/detail/util.hpp>

#include <deque>
#include <memory>
#include <unordered_map>

Expand Down Expand Up @@ -130,8 +131,7 @@ class GlobalHandler {
InstWithLock<XPTIRegistry> MXPTIRegistry;
// Thread pool for host task and event callbacks execution
InstWithLock<ThreadPool> MHostTaskThreadPool;
InstWithLock<std::vector<std::unique_ptr<KernelNameBasedCacheT>>>
MKernelNameBasedCaches;
InstWithLock<std::deque<KernelNameBasedCacheT>> MKernelNameBasedCaches;
};
} // namespace detail
} // namespace _V1
Expand Down
Loading