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

Merged
merged 1 commit into from
Jun 9, 2025

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.

Copy link
Contributor

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.

Wasn't aware of the bidirectional include of queue_impl.hpp and graph_impl.hpp, thanks for pointing that out. We've been wanting to split graph_impl hpp/cpp up into smaller files as it's gotten quite large, so made a note on our internal ticket for that to remove this bidirectional include.

I think moving these functions into the cpp file is fine though.

aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 6, 2025
@aelovikov-intel
Copy link
Contributor Author

@intel/llvm-reviewers-runtime (@cperkinsintel especially), ping.

Copy link
Contributor

@uditagarwal97 uditagarwal97 left a comment

Choose a reason for hiding this comment

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

SYCL Changes LGTM.

@aelovikov-intel aelovikov-intel merged commit 6e55f3b into intel:sycl Jun 9, 2025
36 of 37 checks passed
@aelovikov-intel aelovikov-intel deleted the queue_impl branch June 9, 2025 14:26
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 9, 2025
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 9, 2025
aelovikov-intel added a commit that referenced this pull request Jun 9, 2025
Initially started in #18830
Subsequent PRs before this final one:

#18794
#18834
#18748
aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jun 9, 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.

3 participants