-
Notifications
You must be signed in to change notification settings - Fork 768
[SYCL] Use shared_ptr instead of manual changing UR counters #18565
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
aelovikov-intel
merged 19 commits into
intel:sycl
from
Alexandr-Konovalov:Alexandr-Konovalov/UR-counters-shared_ptr
Jun 2, 2025
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0edc034
[SYCL] Use shared_ptr instead of manual changing UR counters
Alexandr-Konovalov 3a3f017
Code formatting.
Alexandr-Konovalov f0be3fe
Code formatting.
Alexandr-Konovalov dad0228
Merge branch 'sycl' into Alexandr-Konovalov/UR-counters-shared_ptr
Alexandr-Konovalov a11ef81
Clarify comment, drop unneeded move.
Alexandr-Konovalov 93d9cc4
Extend scope of checked calls.
Alexandr-Konovalov e9852a6
Merge branch 'sycl' into Alexandr-Konovalov/UR-counters-shared_ptr
Alexandr-Konovalov d5e20f6
Use raw pointer to reference adapter.
Alexandr-Konovalov db56adf
Code formatting.
Alexandr-Konovalov 7715cc6
Delete copy constructor and copy-assignment operator.
Alexandr-Konovalov 54d94f1
Merge branch 'sycl' into Alexandr-Konovalov/UR-counters-shared_ptr
Alexandr-Konovalov 4a20d5f
Return shared_ptr, not individual handlers, from getCGKernelInfo().
Alexandr-Konovalov 76980f2
Code formatting.
Alexandr-Konovalov 8c16b6e
Remove sycl/test/native_cpu/multiple_definitions.cpp.
Alexandr-Konovalov 441344d
Merge branch 'sycl' into Alexandr-Konovalov/UR-counters-shared_ptr
Alexandr-Konovalov cbb03d2
Update sycl/source/detail/program_manager/program_manager.cpp
Alexandr-Konovalov 37bde6f
Keep reference to Adapter, not pointer.
Alexandr-Konovalov 8c0c60a
Code formatting.
Alexandr-Konovalov 728f698
Extend comment.
Alexandr-Konovalov 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
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 |
---|---|---|
|
@@ -19,11 +19,47 @@ 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>; | ||
|
||
struct FastKernelCacheVal { | ||
ur_kernel_handle_t MKernelHandle; /* UR kernel handle pointer. */ | ||
std::mutex *MMutex; /* Mutex guarding this kernel. When | ||
caching is disabled, the pointer is | ||
nullptr. */ | ||
const KernelArgMask *MKernelArgMask; /* Eliminated kernel argument mask. */ | ||
ur_program_handle_t MProgramHandle; /* UR program handle corresponding to | ||
this kernel. */ | ||
const Adapter &MAdapterPtr; /* We can keep reference to the adapter | ||
because during 2-stage shutdown the kernel | ||
cache is destroyed deliberately before the | ||
adapter. */ | ||
|
||
FastKernelCacheVal(ur_kernel_handle_t KernelHandle, std::mutex *Mutex, | ||
const KernelArgMask *KernelArgMask, | ||
ur_program_handle_t ProgramHandle, | ||
const Adapter &AdapterPtr) | ||
: MKernelHandle(KernelHandle), MMutex(Mutex), | ||
MKernelArgMask(KernelArgMask), MProgramHandle(ProgramHandle), | ||
MAdapterPtr(AdapterPtr) {} | ||
|
||
~FastKernelCacheVal() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we set to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
if (MKernelHandle) | ||
MAdapterPtr.call<sycl::detail::UrApiKind::urKernelRelease>(MKernelHandle); | ||
if (MProgramHandle) | ||
MAdapterPtr.call<sycl::detail::UrApiKind::urProgramRelease>( | ||
MProgramHandle); | ||
MKernelHandle = nullptr; | ||
MMutex = nullptr; | ||
MKernelArgMask = nullptr; | ||
MProgramHandle = nullptr; | ||
} | ||
|
||
FastKernelCacheVal(const FastKernelCacheVal &) = delete; | ||
FastKernelCacheVal &operator=(const FastKernelCacheVal &) = delete; | ||
}; | ||
using FastKernelCacheValPtr = std::shared_ptr<FastKernelCacheVal>; | ||
vinser52 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
using FastKernelSubcacheMapT = | ||
::boost::unordered_flat_map<FastKernelCacheKeyT, FastKernelCacheValT>; | ||
::boost::unordered_flat_map<FastKernelCacheKeyT, FastKernelCacheValPtr>; | ||
|
||
using FastKernelSubcacheMutexT = SpinLock; | ||
using FastKernelSubcacheReadLockT = std::lock_guard<FastKernelSubcacheMutexT>; | ||
|
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
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.