Commit 1fa3885
authored
fix(tensilelite): Reduce unaccounted overhead of ScopedTimer and timing_context (ROCm#6043)
## Motivation
Each `ScopedTimer` / `timing_context` call performed string formatting
and I/O inline, adding significant overhead that inflated parent timers,
especially for bad for high call count but low execution time
operations.
Additionally, `gpu_kernel_execution` and `cpu_reference_gemm` were
placed at the wrong hierarchy level, making the analysis output
misleading.
Follow-up to ROCm#6259.
## Technical Details
Overhead reduction
- **Deferred I/O** (`TimingInstrumentation.hpp`,
`TimingInstrumentation.py`): Replaced inline
`writeLine`/`_timing_logger.info` calls with lightweight buffer appends
during measurement. All formatting and I/O now happens in a single
`flushTimingBuffer()` call after measurement is complete.
- **Overhead calibration** (`TimingInstrumentation.hpp`, `main.cpp`):
Added `calibrateTimingOverhead()` which measures per-call `ScopedTimer`
overhead at startup (warmup + 100k iterations). The calibrated value is
emitted as a `timing_overhead` record and used by `analyze_timing.py` to
subtract instrumentation overhead from parent totals.
- **Buffer pre-allocation** (`TimingInstrumentation.hpp`):
`initTimingBuffer()` reserves 2.5M entries upfront to avoid reallocation
stalls during benchmarking.
- **Analysis improvements** (`analyze_timing.py`): Added per-call
overhead subtraction based on descendant invocation counts, and a new
"Timing Overhead" phase group for `timing_overhead` and
`flush_timing_buffer`.
Fixes
- **Hierarchy fixes** (`main.cpp`, `BenchmarkTimer.cpp`,
`analyze_timing.py`):
- Moved `gpu_kernel_execution` under `benchmark_runs` (was a sibling,
incorrectly double-counted).
- Moved `cpu_data_init` and `cpu_reference_gemm` under `pre_problem`
(where they actually execute).
## Test Plan
Run timing instrumentation end-to-end and verify that parent totals are
consistent with child sums after overhead adjustment.
## Test Result
Timing output shows correct parent-child relationships and
overhead-adjusted totals.
---------
Signed-off-by: Alex Vasile <48962821+Alex-Vasile@users.noreply.github.com>1 parent 4068136 commit 1fa3885
8 files changed
Lines changed: 302 additions & 58 deletions
File tree
- projects/hipblaslt/tensilelite
- Tensile
- Common
- Tests/unit
- characterization/TimingInstrumentation
- client
- include
- src
- scripts
Lines changed: 24 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
40 | 47 | | |
41 | 48 | | |
42 | 49 | | |
43 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
44 | 58 | | |
45 | 59 | | |
46 | 60 | | |
47 | 61 | | |
48 | 62 | | |
49 | | - | |
50 | | - | |
| 63 | + | |
| 64 | + | |
51 | 65 | | |
52 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| 159 | + | |
158 | 160 | | |
159 | 161 | | |
160 | 162 | | |
| |||
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
| |||
682 | 685 | | |
683 | 686 | | |
684 | 687 | | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
685 | 691 | | |
686 | 692 | | |
687 | 693 | | |
| |||
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| 65 | + | |
| 66 | + | |
63 | 67 | | |
64 | 68 | | |
| 69 | + | |
65 | 70 | | |
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
254 | 253 | | |
255 | 254 | | |
256 | 255 | | |
| |||
0 commit comments