Archived
test(isa): the two parsers, on fixtures
isa_tools (fast tier) runs libr4d/isa/selftest.sh: no build tree, no card, no ROCm. rows.awk at the nine 24-VGPR boundaries and at the wave64 quantum; waterfall.awk on a forward branch after a movrel (not a loop), a real back-edge (a loop), a movrel with no branch, and a kernel with no movrel after a kernel that has one. Against the code this replaces, five of the nine occupancy checks fail (97, 121, 145, 241, 256) and the forward-branch case counts a loop where there is none. The rest pin behaviour that is right today: the movrel-with-no-branch row and the empty kernel stay as they are, and the seen-flag reset in flush() has no observable case in this tree -- waterfall.awk resets it per kernel so a later edit cannot reintroduce one.
This commit is contained in:
1 parent
f406c4dafc
commit
f69c9d8324
3 files changed
+93
No files matched your search
@@ -10,6 +10,12 @@ that report the geometry a kernel was launched with rather than every geometry i
|
||||
BUILD=... ./waterfall.sh # divergent VGPR indices, per kernel
|
||||
./loop.sh # its K loop, classified
|
||||
./trace.sh traces/dec -- ./bin/radiance ... # then: ./tsum.sh traces/dec/k_kernel_trace.csv
|
||||
./selftest.sh # the two parsers, on fixtures (ctest: isa_tools)
|
||||
|
||||
`res.sh` and `waterfall.sh` exit nonzero when they looked at nothing -- no `.hip.o`, an object whose
|
||||
code object will not extract or disassemble, or not one kernel in the tree. Empty output from an
|
||||
instrument is a failed run, not a clean tree. A HIP translation unit that carries no kernels has no
|
||||
`.hip_fatbin` and is skipped rather than failed.
|
||||
|
||||
`res.sh` prints mangled names; the substring `dis.sh` takes picks one template instantiation, and
|
||||
the parameter order is in the kernel's declaration (`gemm_fp8a8_kernel` is
|
||||
@@ -27,6 +33,7 @@ anchor, because a largest-loop search finds the epilogue, a long unrolled store
|
||||
| `loop.sh` | isolates the working loop of that disassembly and classifies its body by instruction class |
|
||||
| `res.sh` | one row per device kernel in a build tree: VGPRs, SGPRs, LDS, scratch, spills, waves a SIMD, workgroup size |
|
||||
| `waterfall.sh` | every kernel that indexes a VGPR array with an index the compiler could not prove uniform |
|
||||
| `selftest.sh` | the parsers behind `res.sh` and `waterfall.sh`, against fixtures |
|
||||
| `trace.sh` | runs a command under `rocprofv3 --kernel-trace` and leaves a CSV |
|
||||
| `tsum.sh` | summarises that CSV over a steady-state window: where device time goes, per (kernel, grid) |
|
||||
| `gaps.sh` | where the device is idle, and which op it was waiting for |
|
||||
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
# The two ISA instruments' parsers, against fixtures: no build tree, no card, no ROCm.
|
||||
#
|
||||
# ./selftest.sh (ctest name: isa_tools)
|
||||
#
|
||||
# rows.awk is checked at the occupancy boundaries the 24-VGPR quantum makes -- 96/97, 120/121,
|
||||
# 144/145 and 240/241 all change the wave count, and a formula that rounds to 8 reports the boundary
|
||||
# below -- and at the wave64 quantum, which is not 24. waterfall.awk is checked on a forward branch
|
||||
# after a movrel (not a loop), a real back-edge (a loop), a kernel with neither (no row) and a
|
||||
# movrel with no branch after it followed by a kernel that does branch (the flag must not carry).
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
T=$(mktemp -d) || exit 1
|
||||
trap 'rm -rf "$T"' EXIT INT TERM
|
||||
fail=0
|
||||
check() { # check <what> <expected> <actual>
|
||||
if [ "$2" = "$3" ]; then
|
||||
printf 'ok %s\n' "$1"
|
||||
else
|
||||
printf 'FAIL %s: expected [%s], got [%s]\n' "$1" "$2" "$3" >&2
|
||||
fail=1
|
||||
fi
|
||||
}
|
||||
|
||||
# One kernel's metadata, in llvm-readelf --notes order: alphabetical, .wavefront_size last.
|
||||
metadata() { # metadata <vgpr> <wave> <name>
|
||||
printf ' .group_segment_fixed_size: 0\n'
|
||||
printf ' .private_segment_fixed_size: 0\n'
|
||||
printf ' .sgpr_count: 30\n'
|
||||
printf ' .sgpr_spill_count: 0\n'
|
||||
printf ' .vgpr_count: %s\n' "$1"
|
||||
printf ' .vgpr_spill_count: 0\n'
|
||||
printf ' .max_flat_workgroup_size: 256\n'
|
||||
printf ' .name: %s\n' "$3"
|
||||
printf ' .wavefront_size: %s\n' "$2"
|
||||
}
|
||||
waves() { metadata "$1" "$2" k | awk -f "$here/rows.awk" | cut -f6; }
|
||||
|
||||
printf '== rows.awk: wave32 VGPR quantum 24\n'
|
||||
for c in 96:16 97:12 120:12 121:10 144:10 145:9 240:6 241:5 256:5; do
|
||||
check "vgpr ${c%%:*} waves/SIMD" "${c##*:}" "$(waves "${c%%:*}" 32)"
|
||||
done
|
||||
printf '== rows.awk: wave64 keeps quantum 8\n'
|
||||
check "vgpr 97 wave64 waves/SIMD" 14 "$(waves 97 64)"
|
||||
printf '== rows.awk: one row per kernel\n'
|
||||
check "two kernels, two rows" 2 \
|
||||
"$( { metadata 96 32 a; metadata 97 32 b; } | awk -f "$here/rows.awk" | wc -l | tr -d ' ')"
|
||||
|
||||
printf '== waterfall.awk: a loop is a back-edge, not any exec branch\n'
|
||||
{
|
||||
printf '0000000000001000 <_Zk_forward>:\n'
|
||||
printf '\ts_mov_b32 s0, 0\n'
|
||||
printf '\tv_movrels_b32 v1, v2\n'
|
||||
printf '\ts_cbranch_execnz L99\n'
|
||||
printf '\ts_endpgm\n'
|
||||
printf '0000000000001010 <L99>:\n'
|
||||
printf '\ts_endpgm\n'
|
||||
printf '0000000000001100 <_Zk_loop>:\n'
|
||||
printf '0000000000001104 <L5>:\n'
|
||||
printf '\tv_movrels_b32 v1, v2\n'
|
||||
printf '\ts_cbranch_execnz L5\n'
|
||||
printf '\ts_endpgm\n'
|
||||
printf '0000000000001200 <_Zk_unbranched>:\n'
|
||||
printf '\tv_movrels_b32 v1, v2\n'
|
||||
printf '\ts_endpgm\n'
|
||||
printf '0000000000001300 <_Zk_quiet>:\n'
|
||||
printf '0000000000001304 <L7>:\n'
|
||||
printf '\ts_cbranch_execnz L7\n'
|
||||
printf '\ts_endpgm\n'
|
||||
} > "$T/scan.s"
|
||||
out=$(awk -f "$here/waterfall.awk" -v tu=T "$T/scan.s")
|
||||
col() { printf '%s\n' "$out" | awk -v k="$1" '$4 == k { print $2, $3 }'; }
|
||||
check "forward branch after movrel" "1 0" "$(col '<_Zk_forward>:')"
|
||||
check "back-edge after movrel" "1 1" "$(col '<_Zk_loop>:')"
|
||||
check "movrel with no branch" "1 0" "$(col '<_Zk_unbranched>:')"
|
||||
check "kernel with no movrel, no row" "" "$(col '<_Zk_quiet>:')"
|
||||
check "flag does not carry into the next kernel" 0 \
|
||||
"$(printf '%s\n' "$out" | grep -c '_Zk_quiet>:' | tr -d ' ')"
|
||||
|
||||
[ "$fail" = 0 ] || exit 1
|
||||
printf 'all isa parser checks passed\n'
|
||||
@@ -426,6 +426,12 @@ if(TARGET rad-avx-check AND TARGET libref)
|
||||
set_tests_properties(avx_check_general PROPERTIES TIMEOUT ${RAD_TEST_TIMEOUT} ENVIRONMENT "${env}")
|
||||
endif()
|
||||
|
||||
# The ISA instruments' parsers, on fixtures in the script: no build tree, no card, no ROCm. The
|
||||
# wave counts at the 24-VGPR boundaries and the waterfall back-edge detection are the parts that
|
||||
# can be wrong without anything else noticing.
|
||||
add_test(NAME isa_tools COMMAND sh ${CMAKE_SOURCE_DIR}/libr4d/isa/selftest.sh)
|
||||
set_tests_properties(isa_tools PROPERTIES TIMEOUT ${RAD_TEST_TIMEOUT})
|
||||
|
||||
# ================================================================== libr4d's kernels, on the host
|
||||
#
|
||||
# Some libr4d ops (the sandwich-norm joins, expert_scale) have no libref oracle by design
|
||||
|
||||
Reference in new issue
Block a user