Repository navigation
Adding --print_statistics and API for querying HAL memory usage. - #6868
Merged
Merged
Conversation
Used to guard code that performs programmatic statistics tracking. Independent from debug/release and tracing so that fully optimized builds can still track stats if they choose (useful in bare-metal/etc).
hcindyl
reviewed
Aug 25, 2021
Each HAL backend gets the ability to track statistics as it pleases. This is useful for allocators that can adjust allocation sizes or are performing suballocating from larger block pools, etc. The default heap allocator is the only one populating the stats today. Future extensions would be to track things like imported/mapped memory or reach into VMA in Vulkan to query its statistics. Adding --print_statistics to iree-run-module prints: ``` [[ iree_hal_allocator_t memory statistics ]] HOST_LOCAL: 0b peak / 0b allocated / 0b freed / 0b live DEVICE_LOCAL: 106340864b peak / 106340864b allocated / 106340864b freed / 0b live ``` Fixes #6845.
benvanik
force-pushed
the
benvanik-hal-alloc-stats
branch
from
August 25, 2021 22:11
6c45b16 to
ece6bcc
Compare
This uses the VMA device memory reporting functions to give us an accurate size of actual device memory consumed (vs what we think we allocate): ``` [[ iree_hal_allocator_t memory statistics ]] HOST_LOCAL: 8388608b peak / 8388608b allocated / 0b freed / 8388608b live DEVICE_LOCAL: 3506176b peak / 3506176b allocated / 0b freed / 3506176b live ```
This reports the amount of memory we ask for but not what CUDA may be allocating under the covers: ``` [[ iree_hal_allocator_t memory statistics ]] HOST_LOCAL: 32b peak / 32b allocated / 32b freed / 0b live DEVICE_LOCAL: 16b peak / 16b allocated / 16b freed / 0b live ```
benvanik
force-pushed
the
benvanik-hal-alloc-stats
branch
from
August 25, 2021 22:30
ece6bcc to
15aa194
Compare
benvanik
marked this pull request as ready for review
August 25, 2021 22:36
ScottTodd
approved these changes
Aug 25, 2021
Comment on lines
-78
to
+141
| create_info.pDeviceMemoryCallbacks = NULL; | ||
| create_info.pDeviceMemoryCallbacks = &device_memory_callbacks; |
Member
There was a problem hiding this comment.
awesome that there's a place to insert callbacks already :D
Collaborator
Author
There was a problem hiding this comment.
yeah it's pretty apparent from its API that VMA is heavily used by people doing real stuff - lots of good inspiration in there!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IREE_STATISTICS_ENABLE=1can now be configured to add APIsfor querying/printing HAL memory statistics. Future changes will
use this macro for other parts of the system (task system dispatch
statistics, etc).
Each HAL backend gets the ability to track statistics as it pleases.
This is useful for allocators that can adjust allocation sizes or are
performing suballocating from larger block pools, etc.
The default heap allocator is the only one populating the stats today.
Future extensions would be to track things like imported/mapped memory
or reach into VMA in Vulkan to query its sizing statistics.
CUDA/ROCM are currently reporting our logical allocations but there
may be driver APIs that could give us better numbers.
Adding
--print_statisticsto iree-run-module prints:Fixes #6845.