-
Notifications
You must be signed in to change notification settings - Fork 813
[UR][L0 v2 adapter] on queueFinish() synchronize only used command lists #21224
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
base: sycl
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,20 +45,33 @@ struct ur_queue_immediate_out_of_order_t : ur_object, ur_queue_t_ { | |
| lockable<std::array<ur_command_list_manager, numCommandLists>> | ||
| commandListManagers; | ||
|
|
||
| // Track which command lists have pending work to avoid unnecessary | ||
| // synchronization in queueFinish(). Each bit represents one command list. | ||
| std::atomic<uint32_t> usedCommandListsMask = 0; | ||
|
|
||
| ur_queue_flags_t flags; | ||
|
|
||
| std::array<ur_event_handle_t, numCommandLists> barrierEvents; | ||
|
|
||
| uint32_t getNextCommandListId() { | ||
| uint32_t getNextCommandListId(bool markUsed = true) { | ||
|
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 looked at the uses of I suggest changing this to regular variables under common lockable with commandListManagers. Creating a class with these three variables would make the most sense to me. |
||
| bool isGraphCaptureActive; | ||
| auto &cmdListManager = | ||
| (*commandListManagers.get_no_lock())[captureCmdListManagerIdx]; | ||
| cmdListManager.isGraphCaptureActive(&isGraphCaptureActive); | ||
|
|
||
| return isGraphCaptureActive | ||
| ? captureCmdListManagerIdx | ||
| : commandListIndex.fetch_add(1, std::memory_order_relaxed) % | ||
| numCommandLists; | ||
| uint32_t id = | ||
| isGraphCaptureActive | ||
| ? captureCmdListManagerIdx | ||
| : commandListIndex.fetch_add(1, std::memory_order_relaxed) % | ||
| numCommandLists; | ||
|
|
||
| if (markUsed) { | ||
| // Mark this command list as used so queueFinish() synchronizes only | ||
| // lists that actually carried work. | ||
| usedCommandListsMask.fetch_or(1u << id, std::memory_order_relaxed); | ||
| } | ||
|
|
||
| return id; | ||
| } | ||
|
|
||
| public: | ||
|
|
||
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.
It's probably not gonna happen, but in case the hardcoded number of command lists ever gets changed to something bigger than 32, could you add a comment at the
static constexpr size_t numCommandLists = 4;definition that there's a mask that would also need to be modified.