Skip to content

[NFCI][SYCL][Graph] Cleanup after enable_shared_from_this for queue_impl #18748

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

Open
wants to merge 1 commit into
base: sycl
Choose a base branch
from

Conversation

aelovikov-intel
Copy link
Contributor

@aelovikov-intel aelovikov-intel commented May 30, 2025

foo(const std::shared_ptr<queue_impl> &) doesn't provide any information about possible nullptr arguments. It could provide information about possibility of creating a copy if used sparsely, but when entire codebase passes all objects like this it's meaningless too.

Instead of that, the WIP refactoring across the entire codebase is to pass by raw ptr/ref (depending on the possibility of nullptr value) and extending lifetimes with explicit shared_from_this().

This PR is limited to graph_impl.hpp interfaces accepting queue_impl, clean up after #18715.

@aelovikov-intel aelovikov-intel requested review from a team as code owners May 30, 2025 17:26
@aelovikov-intel aelovikov-intel marked this pull request as draft May 30, 2025 18:10
@aelovikov-intel aelovikov-intel changed the title [NFCI][SYCL] Cleanup after enable_shared_from_this for queue_impl [NFCI][SYCL][Graph] Cleanup after enable_shared_from_this for queue_impl Jun 6, 2025
@aelovikov-intel aelovikov-intel marked this pull request as ready for review June 6, 2025 20:06
addQueue(const std::shared_ptr<sycl::detail::queue_impl> &RecordingQueue) {
MRecordingQueues.insert(RecordingQueue);
}
void addQueue(sycl::detail::queue_impl &RecordingQueue);
Copy link
Contributor Author

@aelovikov-intel aelovikov-intel Jun 6, 2025

Choose a reason for hiding this comment

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

I had to move this and the ones below into the graph_impl.cpp because queue_impl is incomplete at this point. queue_impl.hpp/graph_impl.hpp include each other (which is totally wrong but not the subject of this PR) and untangling that would be a task that I'm not willing to take on, at least not now.

Another alternative would be to make these templates:

template <typename QueueImplTy = queue_impl>
void foo(QueueImplTy &Q)

to make weak_from_this() template-type-dependent and delay the requirement for a complete type until foo is instantiated (vs defined as of now).

Accepting std::weak_ptr<queue_impl> would also work (and some pre-existing methods do just that already) but I find it lacking in expressiveness - it doesn't communicate expectations about nullptr possibility of if the argument can be in already expired state.

aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 6, 2025
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 6, 2025
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 6, 2025
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 6, 2025
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.

1 participant