Archived
Both instruments could report a clean tree after inspecting nothing.
res.sh and waterfall.sh skipped an object whose code object would not extract
(`|| continue`), skipped a disassembly that failed, and then printed a header
and a short table and exited 0. waterfall.sh additionally counted every
s_cbranch_exec* after a movrel -- a forward branch is not the loop that re-runs
the movrel -- and carried that flag across kernels, because flush() reset n and
loops but not seen.
Now: no .hip.o under BUILD, a code object that will not extract, a
llvm-readelf/llvm-objdump that fails, or not one kernel inspected all exit 1. A
HIP translation unit with no kernels carries no .hip_fatbin and is skipped, not
failed -- one exists in this tree (r4d_ar_entry), which is why "every object must
extract" was not an option. The parse is waterfall.awk, and a branch counts only
when its target label was already defined above it, i.e. is a back-edge.
Measured over every kernel this tree builds (761 movrels): 199 loops become 101,
19 rows change, and 12 of them are r4d_ar_twoshot_Nrank_exact reporting 7 where
it has no back-edge at all:
r4d_ar_twoshot_Nrank_exact 7 -> 0 (x12)
r4d_hc_bf16 6 -> 1
xprefetch 4 -> 3
r4d_ple_gate_bf16 3 -> 0
r4d_ngram_ids 2 -> 1
spechub 9 -> 8, 2 -> 0
r4d_encoder_bf16 1 -> 0
29 lines
1.2 KiB
Awk
29 lines
1.2 KiB
Awk
# movrel count per kernel, plus how many of them sit in a real loop.
|
|
#
|
|
# A `movrel` is a divergent VGPR index the compiler had to serialize; the loop that re-runs it once
|
|
# per distinct index is a `s_cbranch_execnz` back-edge around it. Counting every exec branch after
|
|
# a movrel (as this did) also counts forward branches, which are not loops, and carried the flag
|
|
# from one kernel into the next, so a kernel with no movrel at all could report loops.
|
|
#
|
|
# A branch is a back-edge when its target label has already been defined above it: llvm-objdump
|
|
# emits the blocks in address order, so "seen already" is "lower address". Forward targets are
|
|
# skipped.
|
|
function flush( ) {
|
|
if (n > 0) printf "%-22s %6d %6d %s\n", tu, n, loops, k
|
|
n = 0; loops = 0; seen = 0
|
|
}
|
|
/^[0-9a-f]+ <.*>:$/ {
|
|
if ($2 ~ /^<L[0-9]+>:$/) lab[$2] = 1
|
|
else { flush(); k = $2 }
|
|
next
|
|
}
|
|
/movrel/ { n++; seen = 1 }
|
|
/s_cbranch_exec(nz|z)/ {
|
|
# The operand is the target label (`L667`), or a bare address followed by the label in brackets
|
|
# when the disassembler was told to symbolize; the definition line is `0000 <L667>:`.
|
|
key = ($3 ~ /^<L/) ? $3 : "<" $2 ">:"
|
|
if (seen && (key in lab)) loops++
|
|
seen = 0
|
|
}
|
|
END { flush() }
|