Skip to content

[NFC][SYCL] Use plain context_impl * for func params in scheduler #19156

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 26, 2025

Conversation

aelovikov-intel
Copy link
Contributor

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

Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

Few nits, but overall looking good!

@@ -214,6 +213,10 @@ struct MemObjRecord {

// The context which has the latest state of the memory object.
std::shared_ptr<context_impl> MCurContext;
context_impl *getCurContext() { return MCurContext.get(); }
void setCurContext(context_impl *Ctx) {
MCurContext = Ctx ? Ctx->shared_from_this() : nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding was that the shared_from_this functionality could be used by the shared_ptr ctor, so

Suggested change
MCurContext = Ctx ? Ctx->shared_from_this() : nullptr;
MCurContext = std::shared_ptr<context_impl>{Ctx};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That only works during creation of the very first shared_ptr that has been done in context_impl::create/std::make_shared, AFAIK. https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0033r1.html might be helpful reading on that subject as well.

@@ -214,6 +213,10 @@ struct MemObjRecord {

// The context which has the latest state of the memory object.
std::shared_ptr<context_impl> MCurContext;
context_impl *getCurContext() { return MCurContext.get(); }
Copy link
Contributor

Choose a reason for hiding this comment

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

Could there be a benefit to having a const overload?

Suggested change
context_impl *getCurContext() { return MCurContext.get(); }
context_impl *getCurContext() { return MCurContext.get(); }
const context_impl *getCurContext() const { return MCurContext.get(); }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const-correctness and the choices we have to make (technically, C++ will allow to return non-const from const method) are intentionally left for a future refactoring separate from this activity.

@aelovikov-intel aelovikov-intel merged commit ea4d084 into intel:sycl Jun 26, 2025
25 checks passed
@aelovikov-intel aelovikov-intel deleted the context_impl-scheduler branch June 26, 2025 15:22
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