-
Notifications
You must be signed in to change notification settings - Fork 845
[SYCL][Graph] Avoid removing in-order event dependencies across the native recording capture boundary #22604
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
mmichel11
wants to merge
4
commits into
intel:sycl
Choose a base branch
from
adamfidel:matt/native_graph_event_tracking_pr
base: sycl
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,6 +272,24 @@ class context_impl : public std::enable_shared_from_this<context_impl> { | |
| bool supportsReusableEvents(); | ||
| bool supportsEventProfiling(); | ||
|
|
||
| /// @return True if any native graph recording is active on a queue | ||
| /// in this context. | ||
| bool isNativeRecordingActive() const { | ||
| return MNativeRecordingCount.load(std::memory_order_acquire) > 0; | ||
| } | ||
|
|
||
| /// Register that a native graph recording has begun on a queue in this | ||
| /// context. | ||
| void nativeRecordingBegan() { | ||
| MNativeRecordingCount.fetch_add(1, std::memory_order_release); | ||
| } | ||
|
|
||
| /// Register that a native graph recording has ended on a queue in this | ||
| /// context. | ||
| void nativeRecordingEnded() { | ||
| MNativeRecordingCount.fetch_sub(1, std::memory_order_release); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should add an assertion that we don't get negative counter here which indicates imbalance in Began/Ended. |
||
| } | ||
|
|
||
| private: | ||
| bool MOwnedByRuntime; | ||
| async_handler MAsyncHandler; | ||
|
|
@@ -365,6 +383,12 @@ class context_impl : public std::enable_shared_from_this<context_impl> { | |
| MNativeGraphRegistry; | ||
| mutable std::mutex MNativeGraphRegistryMutex; | ||
|
|
||
| // Count of active native graph recordings in this context. Incremented when | ||
| // a native capture begins on a queue and decremented when it ends. Used to | ||
| // preserve in-order dependencies that cross the native-recording capture | ||
| // boundary. | ||
| std::atomic<int64_t> MNativeRecordingCount{0}; | ||
|
|
||
| void verifyProps(const property_list &Props) const; | ||
| }; | ||
|
|
||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can replace the acquire/release stuff with
memory_order_relaxedsince I don't think a stricter ordering buys us anything.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I used acquire-release is due to the transition of the counter from 1 -> 0 in end capture. The release update and acquire load guarantee the effects of the end capture are observed by another thread when it sees 0 in the counter. I was thinking of this for the case where a submission to a forked queue is done concurrent to end capture on the primary queue. This is always a user application race though for what is actually captured.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, I think keeping acquire-release is fine as is.