Skip to content

[vulkan] Support emulated timeline semaphores - #2208

Closed
antiagainst wants to merge 22 commits into
iree-org:googlefrom
antiagainst:timeline-semaphore
Closed

antiagainst wants to merge 22 commits into
iree-org:googlefrom
antiagainst:timeline-semaphore

Conversation

@antiagainst

Copy link
Copy Markdown
Member

This commit adds a iree::hal::Semaphore implementation for Vulkan
using binary semaphores and fences. It supports the functionality
of a timeline semaphore while guaranteeing the usage requirements
of binary semaphores and fences. In order to do that, we also need
a special iree::hal::CommandQueue implementation for Vulkan that
is able to defer releasing submissions to the GPU.

This commit only wires up build configuration on CMake side for
now. Conditionally compiling targets needs more consideration
on Bazel side.

Progress on #2002.

This commit adds a iree::hal::Semaphore implementation for Vulkan
using binary semaphores and fences. It supports the functionality
of a timeline semaphore while guaranteeing the usage requirements
of binary semaphores and fences. In order to do that, we also need
a special iree::hal::CommandQueue implementation for Vulkan that
is able to defer releasing submissions to the GPU.

This commit only wires up build configuration on CMake side for
now. Conditionally compiling targets needs more consideration
on Bazel side.
Comment thread CMakeLists.txt Resolved
Comment thread iree/hal/vulkan/CMakeLists.txt Resolved
Comment thread iree/hal/vulkan/handle_util.h Resolved
Comment thread iree/hal/vulkan/vulkan_device.cc Resolved
Comment thread CMakeLists.txt Outdated
Comment on lines +135 to +136
option(IREE_HAL_VULKAN_EMULATE_TIMELINE_SEMAPHORE
"Emulates timeline semaphore with binary semaphores and fences" OFF)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about always including emulation support and choosing at runtime whether to use it or not based on the Vulkan driver's capabilities (if Vulkan 1.2 or the extension exists)? We could also switch to that after working through some of the configuration details on the Bazel side (mostly thinking of our upstream setup). We've leaned towards increasing binary size instead of adding build complexity for similar pieces of code before.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's actually a good point. Agreed that choices inside the build system is not preferrable. It would require quite some large scope changes though; let me get to this later.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added a TODO

Comment thread iree/hal/vulkan/handle_util.h Resolved
Comment thread iree/hal/vulkan/vulkan_device.h Resolved
Comment on lines +753 to +756
// TODO(antiagainst): We actually should get the fences associated with the
// emulated timeline semaphores so that we can wait them in a bunch. This
// implementation is problematic if we wait to wait any and we have the first
// semaphore taking extra long time but the following ones signal quickly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the TODO. This could end up waiting the full deadline (possibly deadlocking?) even if one of the semaphores is already past its signal value...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yup. Sorry for being lazy. ;-P Don't want to further balloon this patch. It is working; I'll fix this later. :)

@antiagainst

Copy link
Copy Markdown
Member Author

Ready for another round of review now. :)

@antiagainst

Copy link
Copy Markdown
Member Author

Okay there are some additional bugs in the impl I need to track down.. Please wait a bit.

@antiagainst

Copy link
Copy Markdown
Member Author

Okay this is good to go for a second round of reviews for now.

@ScottTodd ScottTodd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Generally LGTM. Want @benvanik 's approval also though :D

I can take a look after submit at changing from a build time enable/disable to a runtime check, with associated Bazel (and upstream Google) changes.

Comment thread iree/hal/vulkan/vulkan_device.cc Resolved
Comment thread iree/hal/vulkan/timepoint_util.h Resolved
Comment thread iree/hal/vulkan/timepoint_util.cc Resolved
Comment thread iree/hal/vulkan/vulkan_device.h Resolved
Comment thread iree/hal/vulkan/vulkan_device.cc Resolved
Comment thread iree/hal/vulkan/vulkan_device.cc Resolved
@GMNGeoffrey
GMNGeoffrey changed the base branch from master to google June 23, 2020 17:36
@antiagainst
antiagainst requested a review from benvanik June 23, 2020 19:44
copybara-service Bot pushed a commit that referenced this pull request Jun 24, 2020
This commit adds a iree::hal::Semaphore implementation for Vulkan
using binary semaphores and fences. It supports the functionality
of a timeline semaphore while guaranteeing the usage requirements
of binary semaphores and fences. In order to do that, we also need
a special iree::hal::CommandQueue implementation for Vulkan that
is able to defer releasing submissions to the GPU.

Progress on #2002.

Closes #2208

PiperOrigin-RevId: 317944867
copybara-service Bot pushed a commit that referenced this pull request Jun 24, 2020
This commit adds a iree::hal::Semaphore implementation for Vulkan
using binary semaphores and fences. It supports the functionality
of a timeline semaphore while guaranteeing the usage requirements
of binary semaphores and fences. In order to do that, we also need
a special iree::hal::CommandQueue implementation for Vulkan that
is able to defer releasing submissions to the GPU.

Progress on #2002.

Closes #2208

PiperOrigin-RevId: 317944867
copybara-service Bot pushed a commit that referenced this pull request Jun 24, 2020
This commit adds a iree::hal::Semaphore implementation for Vulkan
using binary semaphores and fences. It supports the functionality
of a timeline semaphore while guaranteeing the usage requirements
of binary semaphores and fences. In order to do that, we also need
a special iree::hal::CommandQueue implementation for Vulkan that
is able to defer releasing submissions to the GPU.

Progress on #2002.

Closes #2208

PiperOrigin-RevId: 317944867
copybara-service Bot pushed a commit that referenced this pull request Jun 24, 2020
This commit adds a iree::hal::Semaphore implementation for Vulkan
using binary semaphores and fences. It supports the functionality
of a timeline semaphore while guaranteeing the usage requirements
of binary semaphores and fences. In order to do that, we also need
a special iree::hal::CommandQueue implementation for Vulkan that
is able to defer releasing submissions to the GPU.

Progress on #2002.

Closes #2208

PiperOrigin-RevId: 317944867
copybara-service Bot pushed a commit that referenced this pull request Jun 24, 2020
These would have flagged on #2208.

Closes #2296

COPYBARA_INTEGRATE_REVIEW=#2296 from ScottTodd:thread-safety-warnings 5b362b0
PiperOrigin-RevId: 318072816
@antiagainst
antiagainst deleted the timeline-semaphore branch June 25, 2020 01:19
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.

4 participants