-
Notifications
You must be signed in to change notification settings - Fork 124
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
Add basic command buffer support to level zero adapter v2 #2532
Conversation
…ied-runtime into add-command-buffer-support
scripts/templates/queue_api.cpp.mako
Outdated
@@ -19,6 +19,8 @@ from templates import helper as th | |||
* | |||
*/ | |||
|
|||
// This file was generated basing on scripts/templates/queue_api.cpp.mako |
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.
nit:
Do not edit. This file is auto generated from a template:
scripts/templates/queue_api.cpp.mako
} // namespace | ||
|
||
std::pair<ze_event_handle_t *, uint32_t> | ||
ur_exp_command_buffer_handle_t_::getWaitListView( |
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.
This is identical to the implementation in queue. Please create simple WaitListView abstraction usable in both.
ze_command_list_handle_t &commandList) { | ||
|
||
using queue_group_type = ur_device_handle_t_::queue_group_info_t::type; | ||
// that should be call to queue getZeOrdinal, |
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.
This, together with the fact that we have no way to allocate events from the correct queue, makes me think we either need to defer creation of these objects until the first enqueue of the command buffer or urCommandBufferCreateExp
should take a queue.
@EwanC thoughts?
I'm also thinking whether it wouldn't make sense just to make the CommandBuffer allocate a whole pool of events from the context. That way, when we need an event, we don't have to acquire context locks.
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.
This, together with the fact that we have no way to allocate events from the correct queue, makes me think we either need to defer creation of these objects until the first enqueue of the command buffer or urCommandBufferCreateExp should take a queue.
@EwanC thoughts?
I'm not that keen on urCommandBufferCreateExp
taking a queue. 1) it doesn't match the SYCL API, where we don't have a queue object when creating the UR command-buffer. 2) It is the opposite direction to where the OpenCL WG is going with command-buffers in KhronosGroup/OpenCL-Docs#1292 to separate the queues used on command-buffer creation and enqueue.
Are there only 2 types of queue ordinal relevant here, compute and copy? If so I would suggest creating command-lists for both. This PR doesn't have the v1 functionality of splitting commands from the UR command-buffers into compute and copy command-lists. But we saw this having good perf benefits on V1, so would be imagine creating a copy engine command-list is something we'll need to do at some point anyway.
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.
Are there only 2 types of queue ordinal relevant here, compute and copy?
In v2 by default we are only going to use the compute ordinal, letting the UMD decide whether to offload the copy to a separate engine. So the answer here is: "just use compute". I was more thinking about the general direction.
What you say makes sense.
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.
cool, letting the UMD handle this consideration definitely sounds like it will simplify the adapter code
checkImmediateAppendSupport(context); | ||
|
||
if (isUpdatable) { | ||
UR_ASSERT(context->getPlatform()->ZeMutableCmdListExt.Supported, |
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.
Please don't use these "asserts". Do a normal if and return UR_RESULT_ERROR_UNSUPPORTED_FEATURE
.
I just dislike overloading the term "assert" to mean fail with error.
* @param[out] commandList The L0 command-list created by this function. | ||
* @return UR_RESULT_SUCCESS or an error code on failure | ||
*/ | ||
ur_result_t createMainCommandList(ur_context_handle_t context, |
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.
this isn't used anywhere.
std::pair<ze_event_handle_t *, uint32_t> | ||
getWaitListView(const ur_event_handle_t *phWaitEvents, | ||
uint32_t numWaitEvents); | ||
|
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.
private:
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.
bump
The cache action is stopping support for anything but the very latest version. We need to update to 4.2.0 for the cache to continue functioning. actions/cache#1510
…he WaitEvent is done at the right time. This fixes a potential race condition where, if the SignalCommandList executes before the ComputeCommandList, the WaitEvent could be reset before the ComputeCommandList can wait on it and, consequently, create a deadlock.
Added implementation details to OpenCL adapter for processing image format structs. Added a couple missing enums to spec for ur_image_info_t and added CTS tests for these.
…fo-unswitch Move urMemImageGetInfo success test from a switch to individual test
update GitHub Cache action to 4.2.0
…/memimage-info-unswitch Revert "Move urMemImageGetInfo success test from a switch to individual test"
…oref-arg Fix passing struct object by value
…s-images-host-usm Enable creation of bindless images backed by host USM
…ool_config_parse fix parseDisjointPoolConfig and add tests
…ssaryCLSkip Remove unnecessary OpenCL KNOWN_FAILURE from urKernelGetInfoTest.
# This is the 1st commit message: parent 9824163 author Mikołaj Komar <mikolaj.komar@intel.com> 1734527193 +0000 committer Mateusz P. Nowak <mateusz.p.nowak@intel.com> 1738059437 +0000 Prepare ground for command_buffer in v2 Enforce in order list usage, and add initialization and destruction to buffer Add initial support of command buffers to adapter v2 Update UR calls handling Remove unnecessary comment Move not implemented command buffer commands to previous position Fix most issues with code Fix formatting and modify queue_api template Move command buffer cleanup to destructor Use cached command lists instead of created ones Remove not needed function and change phrasing Add initial implementation of command list manager Use list manager instead of custom implementation in queue Optimalize imports Remove not needed destructor Revert "Fix formatting" This reverts commit 545e577. # This is the commit message oneapi-src#2: Move command list close to the command buffer # This is the commit message oneapi-src#3: Moved try outside function block # This is the commit message oneapi-src#4: Move enqueue generic command list back to queue
author Mikołaj Komar <mikolaj.komar@intel.com> 1734527193 +0000 committer Mateusz P. Nowak <mateusz.p.nowak@intel.com> 1738059437 +0000 Prepare ground for command_buffer in v2 Enforce in order list usage, and add initialization and destruction to buffer Add initial support of command buffers to adapter v2 Update UR calls handling Remove unnecessary comment Move not implemented command buffer commands to previous position Fix most issues with code Fix formatting and modify queue_api template Move command buffer cleanup to destructor Use cached command lists instead of created ones Remove not needed function and change phrasing Add initial implementation of command list manager Use list manager instead of custom implementation in queue Optimalize imports Remove not needed destructor Revert "Fix formatting" This reverts commit 545e577. Move command list close to the command buffer Moved try outside function block Move enqueue generic command list back to queue Share events and lists between queue and command list manager Use ze events instead of ur in getSignalEvent
# This is the 1st commit message: parent 9824163 author Mikołaj Komar <mikolaj.komar@intel.com> 1734527193 +0000 committer Mateusz P. Nowak <mateusz.p.nowak@intel.com> 1738059437 +0000 Prepare ground for command_buffer in v2 Enforce in order list usage, and add initialization and destruction to buffer Add initial support of command buffers to adapter v2 Update UR calls handling Remove unnecessary comment Move not implemented command buffer commands to previous position Fix most issues with code Fix formatting and modify queue_api template Move command buffer cleanup to destructor Use cached command lists instead of created ones Remove not needed function and change phrasing Add initial implementation of command list manager Use list manager instead of custom implementation in queue Optimalize imports Remove not needed destructor Revert "Fix formatting" This reverts commit 545e577. Move command list close to the command buffer Moved try outside function block Move enqueue generic command list back to queue Share events and lists between queue and command list manager Use ze events instead of ur in getSignalEvent # This is the commit message oneapi-src#2: Remove not needed structs and reformat code # This is the commit message oneapi-src#3: Fix PR comments
# This is the 1st commit message: parent 9824163 author Mikołaj Komar <mikolaj.komar@intel.com> 1734527193 +0000 committer Mateusz P. Nowak <mateusz.p.nowak@intel.com> 1738059437 +0000 Prepare ground for command_buffer in v2 Enforce in order list usage, and add initialization and destruction to buffer Add initial support of command buffers to adapter v2 Update UR calls handling Remove unnecessary comment Move not implemented command buffer commands to previous position Fix most issues with code Fix formatting and modify queue_api template Move command buffer cleanup to destructor Use cached command lists instead of created ones Remove not needed function and change phrasing Add initial implementation of command list manager Use list manager instead of custom implementation in queue Optimalize imports Remove not needed destructor Revert "Fix formatting" This reverts commit 545e577. Move command list close to the command buffer Moved try outside function block Move enqueue generic command list back to queue Share events and lists between queue and command list manager Use ze events instead of ur in getSignalEvent # This is the commit message oneapi-src#2: Remove not needed structs and reformat code # This is the commit message oneapi-src#3: Fix PR comments # This is the commit message oneapi-src#4: Fix ze function calling # This is the commit message oneapi-src#5: Fix access to some fields in command buffer v2 # This is the commit message oneapi-src#6: Fix compilation
This pull request implements basic calls to command buffer in level zero v2 adapter. These calls are required by sycl graph functionality implemented inside llvm, such as record and replay.