-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL] Optimize kernel name based cache lookup #18081
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
Merged
sergey-semenov
merged 53 commits into
intel:sycl
from
sergey-semenov:kernelnamebasedcacheopt
May 19, 2025
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
8dde49e
[SYCL] Optimize kernel name based cache lookup
sergey-semenov e837478
Apply clang-format
sergey-semenov 0c9f44e
Adjust comment
sergey-semenov 6c2e229
Add newline
sergey-semenov c8d69fb
Typo fix
sergey-semenov 2e834ca
Simplify stored pointer
sergey-semenov 00d5461
Fix test
sergey-semenov 6b19383
Invalidate moved-from wrappers
sergey-semenov a07593b
Apply clang-format
sergey-semenov 897521c
Misc stylistic changes
sergey-semenov 8ec295a
One more wrapper move fix
sergey-semenov 4b60007
Clang-format
sergey-semenov a18c986
Update Windows ABI dump
sergey-semenov 0a15e0d
Fix issue with multiple contexts
vinser52 c32d910
Fix KernelProgramCache::reset() to properly cleanup cached kernels
vinser52 cac94ab
Properly cleanup fast kernel cache when KernelProgramCache is destructed
vinser52 994c9f5
Merge branch 'sycl' into kernelnamebasedcacheopt
vinser52 67e926c
Fix issue in the FastKernelCacheWrapper destructor
vinser52 8cfaf2c
Fix multiple_source test
sergey-semenov 0eff24c
Merge branch 'sycl' into kernelnamebasedcacheopt
sergey-semenov 07bea96
Adjust expected kernel name in the test
sergey-semenov f85591e
Merge branch 'sycl' into kernelnamebasedcacheopt
sergey-semenov 7eaa526
Add a struct for the kernel name based cache
sergey-semenov a311cb2
Apply comment
sergey-semenov 9ad056b
Fix warning
sergey-semenov 2e53abe
Update Windows ABI symbols
sergey-semenov 1cd087a
Merge branch 'sycl' into kernelnamebasedcacheopt
sergey-semenov 1310fda
Apply clang-format
sergey-semenov 650dd6c
Add newline at EOF
sergey-semenov 4a68d29
Manage the struct lifetime in global handler
sergey-semenov 0890de6
Store maps instead of pointers
sergey-semenov f783c0e
Update Linux ABI dump
sergey-semenov 65fff8c
Update Windows ABI dump
sergey-semenov bf8a365
Merge branch 'sycl' into kernelnamebasedcacheopt
sergey-semenov f34185d
Clean up leftover code
sergey-semenov a0a7394
Remove a TODO comment
sergey-semenov b0b8cfe
Drop an unneeded include
sergey-semenov 1016a4b
Adjust comment
sergey-semenov de5d9b3
Remove unneeded include
sergey-semenov 8f51de7
Add a mutex to each subcache
sergey-semenov 812abf3
Use a struct instead of pair to improve readability
sergey-semenov 8e325d8
Drop unneeded header
sergey-semenov 5e5be16
Align fast kernel cache naming
sergey-semenov 9d8fca1
Merge branch 'sycl' into kernelnamebasedcacheopt
sergey-semenov 4c480b6
Fix subcache eviction + minor renaming
sergey-semenov 446e0de
Apply clang-format
sergey-semenov 48f4959
Merge branch 'sycl' into kernelnamebasedcacheopt
sergey-semenov 7eb9327
Apply comment
sergey-semenov 6198318
Merge branch 'sycl' into kernelnamebasedcacheopt
sergey-semenov bf1911e
Merge branch 'sycl' into kernelnamebasedcacheopt
sergey-semenov 0805355
Merge branch 'sycl' into kernelnamebasedcacheopt
sergey-semenov 8bbffdc
Merge branch 'sycl' into kernelnamebasedcacheopt
sergey-semenov 777639f
Apply clang-format
sergey-semenov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//==--------------------- kernel_name_based_cache.hpp ----------------------==// | ||
// | ||
// 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 <sycl/detail/export.hpp> | ||
|
||
namespace sycl { | ||
inline namespace _V1 { | ||
namespace detail { | ||
|
||
struct KernelNameBasedCacheT; | ||
__SYCL_EXPORT KernelNameBasedCacheT *createKernelNameBasedCache(); | ||
|
||
// Retrieves a cache pointer unique to a kernel name type that can be used to | ||
// avoid kernel name based lookup in the runtime. | ||
template <typename KernelName> | ||
KernelNameBasedCacheT *getKernelNameBasedCache() { | ||
static KernelNameBasedCacheT *Instance = createKernelNameBasedCache(); | ||
return Instance; | ||
} | ||
|
||
} // namespace detail | ||
} // namespace _V1 | ||
} // namespace sycl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//==--------------------- kernel_name_based_cache.cpp ----------------------==// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <detail/global_handler.hpp> | ||
#include <sycl/detail/kernel_name_based_cache.hpp> | ||
|
||
namespace sycl { | ||
inline namespace _V1 { | ||
namespace detail { | ||
|
||
KernelNameBasedCacheT *createKernelNameBasedCache() { | ||
return GlobalHandler::instance().createKernelNameBasedCache(); | ||
} | ||
|
||
} // namespace detail | ||
} // namespace _V1 | ||
} // namespace sycl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//==-------------------- kernel_name_based_cache_t.hpp ---------------------==// | ||
// | ||
// 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 <detail/kernel_arg_mask.hpp> | ||
#include <sycl/detail/spinlock.hpp> | ||
#include <sycl/detail/ur.hpp> | ||
|
||
#include <mutex> | ||
|
||
#include <boost/unordered/unordered_flat_map.hpp> | ||
|
||
namespace sycl { | ||
inline namespace _V1 { | ||
namespace detail { | ||
using FastKernelCacheKeyT = std::pair<ur_device_handle_t, ur_context_handle_t>; | ||
using FastKernelCacheValT = | ||
std::tuple<ur_kernel_handle_t, std::mutex *, const KernelArgMask *, | ||
ur_program_handle_t>; | ||
using FastKernelSubcacheMapT = | ||
::boost::unordered_flat_map<FastKernelCacheKeyT, FastKernelCacheValT>; | ||
|
||
using FastKernelSubcacheMutexT = SpinLock; | ||
using FastKernelSubcacheReadLockT = std::lock_guard<FastKernelSubcacheMutexT>; | ||
using FastKernelSubcacheWriteLockT = std::lock_guard<FastKernelSubcacheMutexT>; | ||
|
||
struct FastKernelSubcacheT { | ||
FastKernelSubcacheMapT Map; | ||
FastKernelSubcacheMutexT Mutex; | ||
}; | ||
|
||
struct KernelNameBasedCacheT { | ||
FastKernelSubcacheT FastKernelSubcache; | ||
}; | ||
|
||
} // namespace detail | ||
} // namespace _V1 | ||
} // namespace sycl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.