Skip to content

Remove "memory access" attributes from interface bindings. - #7734

Merged
ScottTodd merged 8 commits into
iree-org:mainfrom
ScottTodd:interfaces-optimize
Nov 29, 2021
Merged

ScottTodd merged 8 commits into
iree-org:mainfrom
ScottTodd:interfaces-optimize

Conversation

@ScottTodd

Copy link
Copy Markdown
Member

These were (mostly) unused both in the compiler and runtime. The stream dialect includes a stream.cmd.discard operation and already performs copy-on-write analysis, so these concepts should already be modeled and validated sufficiently earlier in compilation. Runtime validation could be useful for buffers passed in from user code, but we don't necessarily need all this supporting compiler code for that.

This is part of the hal.interface optimizations tracked in #3502:

  • By omitting this information, hal.interface ops are more likely to be recognized as duplicates, which also helps the ElideRedundantCommands pass remove hal.command_buffer.push_descriptor_set ops (as it does not currently elide matching descriptor set bindings across layouts).
    • MobileBertSquad went from 13 hal.interface ops and 462 push_descriptor_set ops to 4 hal.interface ops and 127 push_descriptor_set ops with this change
  • One possible next step is to perform a resource usage frequency analysis and use that to sort resources to both minimize the number of required updates and "Place the least frequently changing descriptor sets near the start of the pipeline layout" (as the Vulkan spec recommends).

Note: the HAL still uses the iree_hal_memory_access_t type in many other places.

This was unused both in the compiler and runtime. The stream dialect includes a `stream.cmd.discard` operation and already performs copy-on-write analysis, so these concepts should already be modeled and validated sufficiently earlier in compilation. Runtime validation _could_ be useful for buffers passed in from user code, but we don't necessarily need all this supporting compiler code for that.

By omitting this information, `hal.interface` ops are more likely to be recognized as duplicates, which also helps the `ElideRedundantCommands` pass remove `hal.command_buffer.push_descriptor_set` ops (as it does not currently elide matching descriptor set bindings across layouts).

Note: the HAL still uses the `iree_hal_memory_access_t` type in many other places.
@ScottTodd ScottTodd added compiler/dialects Relating to the IREE compiler dialects (flow, hal, vm) runtime Relating to the IREE runtime library performance ⚡ Performance/optimization related work across the compiler and runtime labels Nov 24, 2021
@google-cla google-cla Bot added the cla: yes label Nov 24, 2021
Comment thread iree/hal/buffer.h Resolved
Comment thread iree/hal/buffer.h Resolved
Comment thread iree/hal/buffer.h
// is guaranteed not to alias (ala C's `restrict` keyword).
IREE_HAL_MEMORY_ACCESS_MAY_ALIAS = 1u << 3,
// Memory may have any access.
IREE_HAL_MEMORY_ACCESS_ANY = 1u << 4,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we should probably restrict buffers from being created with this bit - unfortunately that code isn't really centralized so all the creation functions would have to do the masking off of the _ANY bit (iree_hal_heap_buffer_create, etc) - so maybe fine to ignore for now

@iree-github-actions-bot

Copy link
Copy Markdown
Contributor

Abbreviated Benchmark Summary

@ commit f36bc2b2ad13a1264ceee7e6e21fb11ca65fc9be (vs. base 916c6f92ee4729da21ab0cf266f086f9a4f3b80b)

Regressed Benchmarks 🚩

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileNetV3Small [fp32,imagenet] (TFLite) full-inference,default-flags with IREE-Vulkan @ Pixel-4 (GPU-Adreno-640) 19 (vs. 13, 46.15%↑) 19 0
MobileNetV3Small [fp32,imagenet] (TFLite) full-inference,experimental-flags with IREE-Vulkan @ Pixel-4 (GPU-Adreno-640) 19 (vs. 13, 46.15%↑) 19 0
MobileSSD [fp32] (TFLite) little-core,full-inference,default-flags with IREE-Dylib-Sync @ SM-G980F (CPU-ARMv8.2-A) 2496 (vs. 2150, 16.09%↑) 2505 29

[Top 3 out of 9 benchmark results showed]

Improved Benchmarks 🎉

Benchmark Name Average Latency (ms) Median Latency (ms) Latency Standard Deviation (ms)
MobileBertSquad [fp32] (TFLite) full-inference,experimental-flags with IREE-Vulkan @ SM-G980F (GPU-Mali-G77) 187 (vs. 291, 35.74%↓) 187 2
MobileBertSquad [fp32] (TFLite) full-inference,default-flags with IREE-Vulkan @ SM-G980F (GPU-Mali-G77) 186 (vs. 287, 35.19%↓) 186 2
DeepLabV3 [fp32] (TFLite) full-inference,experimental-flags with IREE-Vulkan @ SM-G980F (GPU-Mali-G77) 44 (vs. 67, 34.33%↓) 42 5

[Top 3 out of 16 benchmark results showed]

For more information:

@ScottTodd
ScottTodd marked this pull request as ready for review November 24, 2021 16:39
@ScottTodd
ScottTodd requested a review from benvanik November 24, 2021 16:39
@ScottTodd
ScottTodd merged commit fd51378 into iree-org:main Nov 29, 2021
@ScottTodd
ScottTodd deleted the interfaces-optimize branch November 29, 2021 16:54
@NatashaKnk NatashaKnk mentioned this pull request Nov 29, 2021
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) performance ⚡ Performance/optimization related work across the compiler and runtime runtime Relating to the IREE runtime library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants