-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] enable_shared_from_this for kernel_bundle_impl #18899
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
againull
merged 16 commits into
intel:sycl
from
Alexandr-Konovalov:Alexandr-Konovalov/shared_from_this-kernel_bundle_impl
Jun 17, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
06ee707
[SYCL] enable_shared_from_this for kernel_bundle_impl
Alexandr-Konovalov 1ad2b56
Merge branch 'sycl' into Alexandr-Konovalov/shared_from_this-kernel_b…
Alexandr-Konovalov c6130ff
Code formatting.
Alexandr-Konovalov ea89dd2
Code formatting.
Alexandr-Konovalov a777b1e
Code formatting.
Alexandr-Konovalov 7974ec0
Add getOrInsertHandlerKernelBundlePtr.
Alexandr-Konovalov 6aa90e9
Code formatting.
Alexandr-Konovalov 4b651b6
Update sycl/include/sycl/handler.hpp
Alexandr-Konovalov 986711d
Addressing code review.
Alexandr-Konovalov 47af740
Add newly exported Windows symbol.
Alexandr-Konovalov 60c1806
Merge branch 'sycl' into Alexandr-Konovalov/shared_from_this-kernel_b…
Alexandr-Konovalov 6c42146
Create std::shared_ptr<detail::kernel_bundle_impl> only on spot.
Alexandr-Konovalov 1e3f2d4
Code formatting.
Alexandr-Konovalov 35a8acf
Do not use move semanics and call shared_from_this() on the spot.
Alexandr-Konovalov 3f1efb2
Code formatting.
Alexandr-Konovalov b2f44c4
Merge branch 'sycl' into Alexandr-Konovalov/shared_from_this-kernel_b…
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
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,59 @@ | ||
//==----------------- device_image_impl.cpp - SYCL device_image_impl -------==// | ||
// | ||
// 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/device_image_impl.hpp> | ||
#include <detail/kernel_bundle_impl.hpp> | ||
|
||
namespace sycl { | ||
inline namespace _V1 { | ||
namespace detail { | ||
|
||
std::shared_ptr<kernel_impl> device_image_impl::tryGetSourceBasedKernel( | ||
std::string_view Name, const context &Context, | ||
const kernel_bundle_impl &OwnerBundle, | ||
const std::shared_ptr<device_image_impl> &Self) const { | ||
if (!(getOriginMask() & ImageOriginKernelCompiler)) | ||
return nullptr; | ||
|
||
assert(MRTCBinInfo); | ||
std::string AdjustedName = adjustKernelName(Name); | ||
if (MRTCBinInfo->MLanguage == syclex::source_language::sycl) { | ||
auto &PM = ProgramManager::getInstance(); | ||
for (const std::string &Prefix : MRTCBinInfo->MPrefixes) { | ||
auto KID = PM.tryGetSYCLKernelID(Prefix + AdjustedName); | ||
|
||
if (!KID || !has_kernel(*KID)) | ||
continue; | ||
|
||
auto UrProgram = get_ur_program_ref(); | ||
auto [UrKernel, CacheMutex, ArgMask] = | ||
PM.getOrCreateKernel(Context, AdjustedName, | ||
/*PropList=*/{}, UrProgram); | ||
return std::make_shared<kernel_impl>(UrKernel, *getSyclObjImpl(Context), | ||
Self, OwnerBundle.shared_from_this(), | ||
ArgMask, UrProgram, CacheMutex); | ||
} | ||
return nullptr; | ||
} | ||
|
||
ur_program_handle_t UrProgram = get_ur_program_ref(); | ||
const AdapterPtr &Adapter = getSyclObjImpl(Context)->getAdapter(); | ||
ur_kernel_handle_t UrKernel = nullptr; | ||
Adapter->call<UrApiKind::urKernelCreate>(UrProgram, AdjustedName.c_str(), | ||
&UrKernel); | ||
// Kernel created by urKernelCreate is implicitly retained. | ||
|
||
return std::make_shared<kernel_impl>( | ||
UrKernel, *detail::getSyclObjImpl(Context), Self, | ||
OwnerBundle.shared_from_this(), /*ArgMask=*/nullptr, UrProgram, | ||
/*CacheMutex=*/nullptr); | ||
} | ||
|
||
} // 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
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.