Skip to content
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

Converting Vulkan target to support executable-create2. #18306

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

benvanik
Copy link
Collaborator

This produces a new flatbuffer that supports multiple shared modules per HAL executable, reorganizes per-export information to be per-export, and swaps HAL pipeline layouts with internal Vulkan pipeline layouts that are constructed from metadata in the flatbuffer.

This is a startup time regression for as long as we are not linking modules because descriptor set and pipeline layout reuse now happens per executable and not per VM context. The fix is to link modules together. I am not sure why that was never done :/

Progress on #18154.

@benvanik benvanik added the hal/vulkan Runtime Vulkan GPU HAL backend label Aug 21, 2024
@benvanik benvanik force-pushed the users/benvanik/dispatch2-vulkan branch 3 times, most recently from ac9af1f to e0bca76 Compare August 21, 2024 04:05
@benvanik benvanik marked this pull request as ready for review August 21, 2024 04:37
@benvanik benvanik removed the request for review from MaheshRavishankar August 21, 2024 04:38
@benvanik
Copy link
Collaborator Author

(lit test failures are expected during the transition)

runtime/src/iree/hal/drivers/vulkan/pipeline_layout.h Outdated Show resolved Hide resolved
runtime/src/iree/hal/drivers/vulkan/pipeline_layout.h Outdated Show resolved Hide resolved
runtime/src/iree/hal/drivers/vulkan/native_executable.cc Outdated Show resolved Hide resolved
// NOTE: vkCreateComputePipelines takes multiple pipelines but doesn't speed up
// creation on any known driver; we process one at a time so that we can get
// better error messages and multithread the pipeline creation ourselves.
Copy link
Member

Choose a reason for hiding this comment

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

Interesting - did you run those speed tests / benchmarks yourself, or did other people report that somewhere? (I'll buy the point about error messages, but startup time is pretty important for us, so would prefer to have high confidence that what we're doing is optimal)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, drivers are not required and don't multithread pipeline creation internally (as a general rule Vulkan drivers don't maintain their own thread pools in user mode). The only savings is on the call into the driver which is tiny compared to actual creation and shader JIT that usually happens.

From the Vulkan guide:

For compiling pipelines, vkCreateShaderModule and vkCreateGraphicsPipeline are both allowed to be called from multiple threads at once. A common approach for multithreaded shader compilation is to have a background thread dedicated to it, with it constantly looking into a parallel queue to receive compilation requests, and putting the compiled pipelines into another queue that then the main renderthread will connect to the simulation. This is very important to do if you want to have an engine that doesn’t have a lot of hitching. Compiling shader pipelines can take a very long time, so if you have to compile pipelines at runtime outside of a load screen, then you need to implement such a multithreaded async compile scheme for your game to work well.

This produces a new flatbuffer that supports multiple shared modules
per HAL executable, reorganizes per-export information to be per-export,
and swaps HAL pipeline layouts with internal Vulkan pipeline layouts
that are constructed from metadata in the flatbuffer.

This is a startup time regression for as long as we are not linking
modules because descriptor set and pipeline layout reuse now happens
per executable and not per VM context. The fix is to link modules
together.
@benvanik benvanik force-pushed the users/benvanik/dispatch2-vulkan branch from e0bca76 to f6a6122 Compare August 22, 2024 16:48
@benvanik benvanik merged commit 52507b4 into shared/dispatch2 Aug 22, 2024
5 of 13 checks passed
@benvanik benvanik deleted the users/benvanik/dispatch2-vulkan branch August 22, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hal/vulkan Runtime Vulkan GPU HAL backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants