Skip to content

[NFC][SYCL] Use context_impl & in sampler_impl ctor and near it #19153

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
merged 1 commit into from
Jun 25, 2025

Conversation

aelovikov-intel
Copy link
Contributor

SetArgBasedOnType argument is only used to pass to the sampler_impl ctor so update it.

getCGKernelInfo is only called in a function that also calls sampler_impl ctor so updating its signuature allows to update that caller's local ContextImpl variable, so makes sense to do as part of this PR as well.

Continuation of the refactoring in
#18795
#18877
#18966
#18979
#18980
#18981
#19007
#19030
#19123
#19126

`SetArgBasedOnType` argument is only used to pass to the `sampler_impl`
ctor so update it.

`getCGKernelInfo` is only called in a function that also calls
`sampler_impl` ctor so updating its signuature allows to update that
caller's local `ContextImpl` variable, so makes sense to do as part of
this PR as well.

Continuation of the refactoring in
intel#18795
intel#18877
intel#18966
intel#18979
intel#18980
intel#18981
intel#19007
intel#19030
intel#19123
intel#19126
@aelovikov-intel aelovikov-intel requested a review from a team as a code owner June 25, 2025 17:54
@aelovikov-intel aelovikov-intel requested a review from againull June 25, 2025 17:54
sampler_impl::getOrCreateSampler(context_impl &ContextImpl) {
// Just for the `MContextToSampler` lookups. Could probably be changed once we
// move to C++20 and would have heterogeneous lookup.
std::shared_ptr<context_impl> ContextImplPtr = ContextImpl.shared_from_this();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is extra overhead, but we have unconditional mutex lock below (and another one near return on non-exceptional code path), so shouldn't matter.


MContextToSampler[syclContext] = Sampler;
MContextToSampler[syclContext.shared_from_this()] = Sampler;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

std::unordered_map::operator[] was performing a copy internally before, now it can just move (and rvalue-ref overload is C++11, so available to us), so no significant (if at all) overhead here.

@againull againull merged commit 0c6ce91 into intel:sycl Jun 25, 2025
25 checks passed
@aelovikov-intel aelovikov-intel deleted the context_impl-sampler_impl branch June 25, 2025 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants