Skip to content

Replacing the HAL fence with a semaphore modeled on Vulkan timeline semaphores - #1743

Closed
benvanik wants to merge 4 commits into
masterfrom
benvanik-timeline-semaphores
Closed

benvanik wants to merge 4 commits into
masterfrom
benvanik-timeline-semaphores

Conversation

@benvanik

Copy link
Copy Markdown
Collaborator

This gives us both compiler and runtime versions of the hal.semaphore and provides a basic implementation of the host semaphore (for VMLA/LLVMJIT/etc) and the Vulkan native timeline semaphore (requires the layer, extension, or Vulkan 1.2).

This change intentionally does not remove hal.ex.submit_and_wait as that is currently handling resource management. Future changes will add a resource timeline and use the semaphores to advance it as a way to collect resources when no longer required.

@benvanik benvanik added compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm) runtime Relating to the IREE runtime library labels Apr 30, 2020
@benvanik benvanik added this to the 2020Q2 Core milestone Apr 30, 2020
@benvanik
benvanik requested a review from ScottTodd April 30, 2020 02:12
@benvanik
benvanik force-pushed the benvanik-timeline-semaphores branch 2 times, most recently from ff8a315 to 64cf44d Compare April 30, 2020 02:56
@benvanik
benvanik force-pushed the benvanik-timeline-semaphores branch from 64cf44d to 3f6b0f2 Compare April 30, 2020 03:51
@benvanik
benvanik marked this pull request as ready for review April 30, 2020 06:21
@benvanik benvanik mentioned this pull request Apr 30, 2020
5 tasks done

@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.

Still making my way through this. Publishing my comments so far. Generally looks great :D

Comment thread iree/compiler/Dialect/HAL/IR/HALBase.td Resolved
Comment thread iree/compiler/Dialect/HAL/IR/HALOps.td Resolved
Comment thread iree/compiler/Dialect/HAL/IR/HALOps.td Resolved
Comment thread iree/compiler/Dialect/HAL/IR/HALOps.td Resolved
Comment thread iree/compiler/Dialect/HAL/IR/HALOps.td Resolved
Comment thread iree/hal/device.h Resolved
Comment thread iree/hal/device_manager.h Resolved
Comment thread iree/hal/device_manager.h Resolved
Comment thread iree/hal/vulkan/dynamic_symbols.cc Resolved
Comment thread iree/hal/api.h Resolved
Comment thread iree/hal/api.cc Resolved
Comment thread iree/hal/api.h Resolved
Comment thread iree/hal/api.h Resolved
Comment thread iree/hal/host/host_semaphore_test.cc Resolved
Comment thread iree/hal/host/host_submission_queue.h Resolved
Comment thread iree/hal/semaphore.h Resolved
Comment thread iree/hal/semaphore.h Resolved
Comment thread iree/hal/vulkan/vulkan_device.cc Resolved
@benvanik
benvanik requested a review from ScottTodd May 3, 2020 16:12

@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.

Nice :D

Comment thread iree/hal/api.cc Resolved
copybara-service Bot pushed a commit that referenced this pull request May 7, 2020
This works around an issue using SwiftShader that is blocking #1743 (iree/hal/cts/allocator_test crashes within SwiftShader on the second test case).

PiperOrigin-RevId: 310391153
copybara-service Bot pushed a commit that referenced this pull request May 7, 2020
This works around an issue using SwiftShader that is blocking #1743 (iree/hal/cts/allocator_test crashes within SwiftShader on the second test case).

PiperOrigin-RevId: 310391153
copybara-service Bot pushed a commit that referenced this pull request May 7, 2020
This works around an issue using SwiftShader that is blocking #1743 (iree/hal/cts/allocator_test crashes within SwiftShader on the second test case).

PiperOrigin-RevId: 310403182
@ScottTodd ScottTodd self-assigned this May 7, 2020
@ScottTodd

Copy link
Copy Markdown
Member

Still working on merging this. There was an issue with SwiftShader crashing when running iree/hal/cts/allocator_test, which I've worked around, and now iree/test/e2e/vulkan_specific/reduce.mlir has errors running under validation layers that also deadlock when running under SwiftShader.

Logs snippet from reduce.mlir:

46: I ../iree/tools/run_mlir_main.cc:291] Evaluating all functions in module for driver 'vulkan'...
46: I ../iree/tools/vm_util.cc:304] Creating driver and device for 'vulkan'...
46: E ../iree/hal/vulkan/debug_reporter.cc:40] Cannot call vkDestroySemaphore on VkSemaphore 0xc000000000c[] that is currently in use by a command buffer. The Vulkan spec states: All submitted batches that refer to semaphore must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroySemaphore-semaphore-01137)
46: E ../iree/hal/vulkan/debug_reporter.cc:40] Attempt to free VkCommandBuffer 0x54bad60[] which is in use. The Vulkan spec states: All elements of pCommandBuffers must not be in the pending state (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkFreeCommandBuffers-pCommandBuffers-00047)
46: I ../iree/tools/vm_util.cc:204] result[0]: Buffer<sint32[2]>
46: E ../iree/hal/vulkan/debug_reporter.cc:40] Cannot call vkDestroyPipeline on VkPipeline 0x70000000007[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to pipeline must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyPipeline-pipeline-00765)

Comment thread iree/hal/api.cc Resolved
@ScottTodd

Copy link
Copy Markdown
Member

Still working on merging this. There was an issue with SwiftShader crashing when running iree/hal/cts/allocator_test, which I've worked around, and now iree/test/e2e/vulkan_specific/reduce.mlir has errors running under validation layers that also deadlock when running under SwiftShader.

Logs snippet from reduce.mlir:

46: I ../iree/tools/run_mlir_main.cc:291] Evaluating all functions in module for driver 'vulkan'...
46: I ../iree/tools/vm_util.cc:304] Creating driver and device for 'vulkan'...
46: E ../iree/hal/vulkan/debug_reporter.cc:40] Cannot call vkDestroySemaphore on VkSemaphore 0xc000000000c[] that is currently in use by a command buffer. The Vulkan spec states: All submitted batches that refer to semaphore must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroySemaphore-semaphore-01137)
46: E ../iree/hal/vulkan/debug_reporter.cc:40] Attempt to free VkCommandBuffer 0x54bad60[] which is in use. The Vulkan spec states: All elements of pCommandBuffers must not be in the pending state (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkFreeCommandBuffers-pCommandBuffers-00047)
46: I ../iree/tools/vm_util.cc:204] result[0]: Buffer<sint32[2]>
46: E ../iree/hal/vulkan/debug_reporter.cc:40] Cannot call vkDestroyPipeline on VkPipeline 0x70000000007[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to pipeline must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyPipeline-pipeline-00765)

This was (at least in part) an issue with the validation layers not handling timeline semaphores signalling command buffer completion.

copybara-service Bot pushed a commit that referenced this pull request May 8, 2020
reduce.mlir fails with #1743 under SwiftShader due to a SwiftShader bug where we can't create a Vulkan driver twice within the same binary. The check tests don't exhibit this bug (since they reuse a single driver/device for each test case).

Closes #1855

COPYBARA_INTEGRATE_REVIEW=#1855 from ScottTodd:vulkan-check-test 9aa914e
PiperOrigin-RevId: 310634622
copybara-service Bot pushed a commit that referenced this pull request May 11, 2020
These were all separate tests due to historical restrictions with the test runner. They didn't get picked up in the initial conversion because their naming confused me about what they were trying to test.

Unblocks #1743.

PiperOrigin-RevId: 310954767
copybara-service Bot pushed a commit that referenced this pull request May 11, 2020
These were all separate tests due to historical restrictions with the test runner. They didn't get picked up in the initial conversion because their naming confused me about what they were trying to test.

We still need a separate limited test set for vulkan because of some outstanding issues (#1869 and #1869)

Unblocks #1743.

PiperOrigin-RevId: 310954767
copybara-service Bot pushed a commit that referenced this pull request May 11, 2020
These were all separate tests due to historical restrictions with the test runner. They didn't get picked up in the initial conversion because their naming confused me about what they were trying to test.

We still need a separate limited test set for vulkan because of some outstanding issues (#1869 and #1869)

Unblocks #1743.

PiperOrigin-RevId: 311020118
@benvanik
benvanik deleted the benvanik-timeline-semaphores branch June 16, 2020 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm) runtime Relating to the IREE runtime library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants