[WIP] Perf: cache hash and prefetch chain in TensorMap lookup/insert#464
Open
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
Open
Conversation
There was a problem hiding this comment.
Code Review
This pull request optimizes the PTO2TensorMap by caching hash values during lookup and reusing them during insertion for INOUT tensors in pto2_submit_mixed_task. Additionally, it introduces a prefetch instruction in the lookup loop to improve cache performance when traversing bucket chains. I have no feedback to provide.
- Cache the hash(addr) result from lookup() and reuse it in the subsequent insert() call for INOUT tensors, eliminating a redundant 64-bit multiply per tensor - Add software prefetch of next_in_bucket during chain traversal to hide memory latency on chains longer than one entry - Add lookup/insert/link_entry overloads that accept precomputed hash Benchmarked on Ascend910 (device 11, 100 rounds, 3 runs averaged): benchmark_bgemm -3.8%, other workloads -0.2% to -0.7%.
b688858 to
a0eff4b
Compare
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.
Summary
hash(addr)result fromlookup()and reuse it in the subsequentinsert()call for INOUT tensors, eliminating a redundant 64-bit multiply per tensornext_in_bucketduring chain traversal to hide memory latency on chains longer than one entrylookup/insert/link_entryoverloads that accept precomputed hashBenchmark Results
Ascend910 (device 11, 100 rounds, 3 runs averaged):
The bgemm improvement is expected: it has the highest lookup+dep percentage (45.8% of orch time) and uses INOUT tensors extensively.