Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/amd-exec/run.sh # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / amd-exec / run.sh` 226 lines · 14183 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # Host-only gfx942 instruction execution. Usage: sh tests/amd-exec/run.sh /absolute/pinned/omc 4 # AMD_EXEC_OUT optionally preserves artifacts. Production = seeded Omega; Python is test only. 5 # Pin refusal=69, usage=64, missing tool=3, unsupported host=77; hardware always NOT_RUN. 6 set -eu 7 LC_ALL=C 8 export LC_ALL 9 [ "$#" -eq 1 ] || { echo 'usage: run.sh /absolute/pinned/omc' >&2; exit 64; } 10 omc=$1 11 case $omc in /*) ;; *) exit 64 ;; esac 12 command -v sha256sum >/dev/null 2>&1 || exit 3 13 [ -f "$omc" ] && [ -x "$omc" ] || exit 3 14 pin=`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` 15 digest=$(sha256sum < "$omc") 16 [ "${digest%% *}" = "$pin" ] || { echo 'REFUSED compiler digest' >&2; exit 69; } 17 # No source read, output-directory creation, compilation, or producer run precedes this check. 18 [ "$(uname -s)" = Linux ] && [ "$(uname -m)" = aarch64 ] || exit 77 19 for tool in python3 cat cmp chmod mkdir mktemp dirname sed grep timeout; do 20 command -v "$tool" >/dev/null 2>&1 || { echo "NOT_RUN missing $tool"; exit 3; } 21 done 22 root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) 23 out=${AMD_EXEC_OUT:-$(mktemp -d "${TMPDIR:-/tmp}/gfx942-exec.XXXXXX")} 24 mkdir -p "$out" 25 out=$(CDPATH= cd -- "$out" && pwd) 26 src=$root/backend/amd/gfx942 27 python3 -I "$root/tests/amd/receipt.py" write "$root" "$out" 28 printf 'PIN omc=%s\n' "$pin" 29 python3 --version 30 # Instruments run with this directory first on sys.path; a stdlib-named module here breaks oracle imports. 31 python3 -I "$root/tests/amd-exec/stdlib-shadow.py" test "$root/tests/amd-exec" 32 cat "$src/exec/fp.om" "$src/exec/fma.om" "$src/exec/main.om" > "$out/exec.om" 33 for name in hsaco exec rope; do 34 input=$src/$name.om 35 [ "$name" != exec ] || input=$out/exec.om 36 for iteration in 1 2; do 37 timeout 120 "$omc" < "$input" > "$out/$name.$iteration" 2> "$out/$name.$iteration.compile.log" 38 [ ! -s "$out/$name.$iteration.compile.log" ] || { cat "$out/$name.$iteration.compile.log"; exit 1; } 39 chmod 700 "$out/$name.$iteration" 40 done 41 cmp "$out/$name.1" "$out/$name.2" 42 echo "PASS $name two builds byte-identical" 43 done 44 { 45 cat "$src/exec/fp.om" "$src/exec/fma.om" 46 sed '/^fn main to int/,$d' "$src/exec/main.om" 47 cat "$root/tests/amd-exec/semantics-probe.om" 48 } > "$out/semantics.om" 49 mutants=$(python3 -I "$root/tests/amd-exec/semantics.py" mutate "$out/semantics.om" "$out") 50 for variant in semantics $mutants; do 51 timeout 120 "$omc" < "$out/$variant.om" > "$out/$variant" 2> "$out/$variant.compile.log" 52 [ ! -s "$out/$variant.compile.log" ] || { cat "$out/$variant.compile.log"; exit 1; } 53 chmod 700 "$out/$variant" 54 if [ "$variant" = semantics ]; then 55 python3 -I "$root/tests/amd-exec/semantics.py" suite "$out/$variant" "$out" 56 else 57 python3 -I "$root/tests/amd-exec/semantics.py" control "$out/$variant" "$out" "$variant" 58 fi 59 done 60 { printf 'om2\n'; cat "$src/exec/fma.om" "$root/tests/amd-exec/fma-probe.om"; } > "$out/fma-probe.om" 61 timeout 120 "$omc" < "$out/fma-probe.om" > "$out/fma-probe" 2> "$out/fma-probe.compile.log" 62 [ ! -s "$out/fma-probe.compile.log" ] || { cat "$out/fma-probe.compile.log"; exit 1; } 63 chmod 700 "$out/fma-probe" 64 python3 -I "$root/tests/amd-exec/sgemm.py" probe "$out/fma-probe" 65 python3 -I "$root/tests/amd-exec/fp8gemv.py" mutate "$out/exec.om" "$out/exec-ocp.om" 66 timeout 120 "$omc" < "$out/exec-ocp.om" > "$out/exec-ocp" 2> "$out/exec-ocp.compile.log" 67 [ ! -s "$out/exec-ocp.compile.log" ] || { cat "$out/exec-ocp.compile.log"; exit 1; } 68 chmod 700 "$out/exec-ocp" 69 python3 -I "$root/tests/amd-exec/bf16gemv.py" swap-mutant "$out/exec.om" "$out/exec-swapped.om" 70 timeout 120 "$omc" < "$out/exec-swapped.om" > "$out/exec-swapped" 2> "$out/exec-swapped.compile.log" 71 [ ! -s "$out/exec-swapped.compile.log" ] || { cat "$out/exec-swapped.compile.log"; exit 1; } 72 chmod 700 "$out/exec-swapped" 73 kernels= 74 for table in "$src/"*.isa; do 75 kernel=${table##*/} 76 kernels="${kernels}${kernels:+ }${kernel%.isa}" 77 done 78 for kernel in $kernels; do 79 for iteration in 1 2; do 80 timeout 30 "$out/hsaco.$iteration" "$src/$kernel.isa" > "$out/$kernel.$iteration.hsaco" 81 done 82 cmp "$out/$kernel.1.hsaco" "$out/$kernel.2.hsaco" 83 echo "PASS $kernel code object two builds byte-identical" 84 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/$kernel.1.hsaco" "$out/$kernel.text" 85 done 86 digest=$(sha256sum < "$out/vadd.1.hsaco") 87 [ "${digest%% *}" = `10eb12e019ff2117ddc0190650899d4254589375c62e5ebb970b1bbb7e67e55f` ] 88 echo 'PASS vadd code object unchanged from pre-generalization' 89 digest=$(sha256sum < "$out/fsum16.1.hsaco") 90 [ "${digest%% *}" = `15cf499fa114e801d931fb73cbee13fcb6e8764c08a470368306625a8df37478` ] 91 echo 'PASS fsum16 code object unchanged from pre-SGEMM' 92 digest=$(sha256sum < "$out/sgemm.1.hsaco") 93 [ "${digest%% *}" = `466d2a9e8ed61768ca1d09c283933dbae12f768a5bae22f5cf50f13c527d7e70` ] 94 echo 'PASS corrected sgemm code object unchanged from pre-FP8' 95 digest=$(sha256sum < "$out/fp8gemv.1.hsaco") 96 [ "${digest%% *}" = `b2260043751f6483deae05d3c3b5cb1d2a5e97031d299998d9d4b04691fcaf5b` ] 97 echo 'PASS fp8gemv code object unchanged from pre-BF16' 98 digest=$(sha256sum < "$out/bf16gemv.1.hsaco") 99 [ "${digest%% *}" = `59f955f07f5702235927835b98e9934e574fe266744ea53b3ab2db35d30179fa` ] 100 echo 'PASS bf16gemv code object unchanged from pre-GEMV2' 101 sed 's/^I 5 260 8 4 0x01 /I 5 261 8 4 0x01 /' "$src/vadd.isa" > "$out/flipped.isa" 102 if cmp -s "$src/vadd.isa" "$out/flipped.isa"; then echo 'FAIL mutant did not apply'; exit 1; fi 103 timeout 30 "$out/hsaco.1" "$out/flipped.isa" > "$out/flipped.hsaco" 104 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/flipped.hsaco" "$out/flipped.text" 105 python3 -I "$root/tests/amd-exec/oracle.py" suite "$out/exec.1" "$out/vadd.text" "$out/flipped.text" "$out" 106 python3 -I "$root/tests/amd-exec/oracle.py" reverse-table "$src/fsum16.isa" "$out/reversed.isa" 107 timeout 30 "$out/hsaco.1" "$out/reversed.isa" > "$out/reversed.hsaco" 108 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/reversed.hsaco" "$out/reversed.text" 109 python3 -I "$root/tests/amd-exec/oracle.py" fsum-suite "$out/exec.1" "$out/fsum16.text" "$out/reversed.text" "$out" 110 python3 -I "$root/tests/amd-exec/sgemm.py" mutant "$src/sgemm.isa" "$out/unfused.isa" 111 timeout 30 "$out/hsaco.1" "$out/unfused.isa" > "$out/unfused.hsaco" 112 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/unfused.hsaco" "$out/unfused.text" 113 python3 -I "$root/tests/amd-exec/sgemm.py" suite "$out/exec.1" "$out/sgemm.text" "$out/unfused.text" "$out" 114 python3 -I "$root/tests/amd-exec/fp8gemv.py" scale-mutant "$src/fp8gemv.isa" "$out/no-scale.isa" 115 timeout 30 "$out/hsaco.1" "$out/no-scale.isa" > "$out/no-scale.hsaco" 116 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/no-scale.hsaco" "$out/no-scale.text" 117 python3 -I "$root/tests/amd-exec/fp8gemv.py" suite "$out/exec.1" "$out/fp8gemv.text" "$out/exec-ocp" "$out/no-scale.text" "$out" 118 python3 -I "$root/tests/amd-exec/bf16gemv.py" truncate-mutant "$src/bf16gemv.isa" "$out/truncated-x.isa" 119 timeout 30 "$out/hsaco.1" "$out/truncated-x.isa" > "$out/truncated-x.hsaco" 120 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/truncated-x.hsaco" "$out/truncated-x.text" 121 python3 -I "$root/tests/amd-exec/bf16gemv.py" suite "$out/exec.1" "$out/bf16gemv.text" "$out/exec-swapped" "$out/truncated-x.text" "$out" 122 { 123 cat "$src/exec/fp.om" "$src/exec/fma.om" 124 sed '/^fn main to int/,$d' "$src/exec/main.om" 125 cat "$root/tests/amd-exec/row-probe.om" 126 } > "$out/row-probe.om" 127 timeout 120 "$omc" < "$out/row-probe.om" > "$out/row-probe" 2> "$out/row-probe.compile.log" 128 [ ! -s "$out/row-probe.compile.log" ] || { cat "$out/row-probe.compile.log"; exit 1; } 129 chmod 700 "$out/row-probe" 130 for kernel in fp8gemv2 bf16gemv2; do 131 python3 -I "$root/tests/amd-exec/gemv2.py" mutate "$src/$kernel.isa" "$out" 132 for control in order tail stride; do 133 timeout 30 "$out/hsaco.1" "$out/$kernel-$control.isa" > "$out/$kernel-$control.hsaco" 134 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/$kernel-$control.hsaco" "$out/$kernel-$control.text" 135 done 136 done 137 python3 -I "$root/tests/amd-exec/gemv2.py" suite "$out/exec.1" "$out/row-probe" "$out" 138 cat "$src/exec/fp.om" "$root/tests/amd-exec/trans-probe.om" > "$out/trans-probe.om" 139 timeout 120 "$omc" < "$out/trans-probe.om" > "$out/trans-probe" 2> "$out/trans-probe.compile.log" 140 [ ! -s "$out/trans-probe.compile.log" ] || { cat "$out/trans-probe.compile.log"; exit 1; } 141 chmod 700 "$out/trans-probe" 142 python3 -I "$root/tests/amd-exec/attention.py" transprobe "$out/trans-probe" 143 python3 -I "$root/tests/amd-exec/log.py" "$out/trans-probe" 144 python3 -I "$root/tests/amd-exec/attention.py" mutate "$src/attn256_part.isa" "$out" 145 for control in no-max wrong-gqa v-from-k; do 146 timeout 30 "$out/hsaco.1" "$out/attention-$control.isa" > "$out/attention-$control.hsaco" 147 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/attention-$control.hsaco" "$out/attention-$control.text" 148 done 149 python3 -I "$root/tests/amd-exec/attention.py" suite "$out/exec.1" "$out" 150 python3 -I "$root/tests/amd-exec/prep.py" mutate "$src" "$out" 151 for control in no-one wrong-pair wrong-position truncate-cache extra-swish wrong-gate-stride; do 152 timeout 30 "$out/hsaco.1" "$out/prep-$control.isa" > "$out/prep-$control.hsaco" 153 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/prep-$control.hsaco" "$out/prep-$control.text" 154 done 155 timeout 120 "$omc" < "$out/rope-wrong-dim.om" > "$out/rope-wrong-dim" 2> "$out/rope-wrong-dim.compile.log" 156 [ ! -s "$out/rope-wrong-dim.compile.log" ] || { cat "$out/rope-wrong-dim.compile.log"; exit 1; } 157 chmod 700 "$out/rope-wrong-dim" 158 { sed '/^fn main to int/,$d' "$src/rope.om"; cat "$root/tests/amd-exec/ropefreq-probe.om"; } > "$out/ropefreq-probe.om" 159 timeout 120 "$omc" < "$out/ropefreq-probe.om" > "$out/ropefreq-probe" 2> "$out/ropefreq-probe.compile.log" 160 [ ! -s "$out/ropefreq-probe.compile.log" ] || { cat "$out/ropefreq-probe.compile.log"; exit 1; } 161 chmod 700 "$out/ropefreq-probe" 162 python3 -I "$root/tests/amd-exec/prep.py" suite "$out/exec.1" "$out/rope.1" "$out" 163 python3 -I "$root/tests/amd-exec/token_ref.py" mutate "$src" "$out" 164 for control in mlpsilu-no-silu mlpsilu-wrong-up; do 165 timeout 30 "$out/hsaco.1" "$out/$control.isa" > "$out/$control.hsaco" 166 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/$control.hsaco" "$out/$control.text" 167 done 168 python3 -I "$root/tests/amd-exec/token_ref.py" suite "$out/exec.1" "$out" 169 python3 -I "$root/tests/amd-exec/norm.py" mutate "$src" "$out" 170 for control in rmsnorm5120-no-one rmsnorm5120-wrong-mean rmsnorm5120-dropped-chunk; do 171 timeout 30 "$out/hsaco.1" "$out/$control.isa" > "$out/$control.hsaco" 172 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/$control.hsaco" "$out/$control.text" 173 done 174 python3 -I "$root/tests/amd-exec/norm.py" suite "$out/exec.1" "$out" 175 python3 -I "$root/tests/amd-exec/gdnconv.py" mutate "$src" "$out" 176 for control in gdnconv4-no-input-round gdnconv4-no-conv-round gdnconv4-no-silu-round gdnconv4-wrong-cache-shift; do 177 timeout 30 "$out/hsaco.1" "$out/$control.isa" > "$out/$control.hsaco" 178 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/$control.hsaco" "$out/$control.text" 179 done 180 python3 -I "$root/tests/amd-exec/gdnconv.py" suite "$out/exec.1" "$out" 181 python3 -I "$root/tests/amd-exec/gdn.py" mutate "$src" "$out" 182 for control in $(python3 -I "$root/tests/amd-exec/gdn.py" controls); do 183 timeout 30 "$out/hsaco.1" "$out/$control.isa" > "$out/$control.hsaco" 184 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/$control.hsaco" "$out/$control.text" 185 done 186 python3 -I "$root/tests/amd-exec/gdn.py" suite "$out/exec.1" "$out" 187 python3 -I "$root/tests/amd-exec/decode.py" mutate "$src" "$out" 188 for control in $(python3 -I "$root/tests/amd-exec/decode.py" controls); do 189 timeout 30 "$out/hsaco.1" "$out/$control.isa" > "$out/$control.hsaco" 190 python3 -I "$root/tests/amd-exec/oracle.py" extract "$out/$control.hsaco" "$out/$control.text" 191 done 192 python3 -I "$root/tests/amd-exec/decode.py" suite "$out/exec.1" "$out" 193 python3 -I "$root/tests/amd-exec/prep_section.py" "$out/exec.1" "$out" 194 python3 -I "$root/tests/amd-exec/token_access.py" "$omc" "$src" "$out" 195 python3 -I "$root/tests/amd-exec/fp8gemv.py" flat-mutant "$out/exec.om" "$out/exec-flat.om" 196 timeout 120 "$omc" < "$out/exec-flat.om" > "$out/exec-flat" 2> "$out/exec-flat.compile.log" 197 [ ! -s "$out/exec-flat.compile.log" ] || { cat "$out/exec-flat.compile.log"; exit 1; } 198 chmod 700 "$out/exec-flat" 199 python3 -I "$root/tests/amd-exec/fp8gemv.py" long-wave "$out/exec.1" "$out/exec-flat" "$out/fp8gemv.text" "$out" 200 python3 -I "$root/tests/amd-exec/fp8gemv.py" flat-grid-mutant "$out/exec.om" "$out/exec-flatgrid.om" 201 timeout 120 "$omc" < "$out/exec-flatgrid.om" > "$out/exec-flatgrid" 2> "$out/exec-flatgrid.compile.log" 202 [ ! -s "$out/exec-flatgrid.compile.log" ] || { cat "$out/exec-flatgrid.compile.log"; exit 1; } 203 chmod 700 "$out/exec-flatgrid" 204 python3 -I "$root/tests/amd-exec/fp8gemv.py" tall-grid "$out/exec.1" "$out/exec-flatgrid" "$out/vadd.text" "$out" 205 cat > "$out/wrong-omc" <<'WRONG' 206 #!/bin/sh 207 printf 'WRONG_COMPILER_EXECUTED\n' >&2 208 exit 99 209 WRONG 210 chmod 700 "$out/wrong-omc" 211 rc=0 212 AMD_EXEC_OUT="$out/wrong-pin-must-not-exist" sh "$root/tests/amd-exec/run.sh" "$out/wrong-omc" > "$out/wrong-pin.log" 2>&1 || rc=$? 213 [ "$rc" -eq 69 ] && grep -qx 'REFUSED compiler digest' "$out/wrong-pin.log" 214 [ ! -e "$out/wrong-pin-must-not-exist" ] 215 if grep -q WRONG_COMPILER_EXECUTED "$out/wrong-pin.log"; then exit 1; fi 216 echo 'CONTROL wrong-compiler-digest CAUGHT exit=69 before compiler execution or output creation' 217 # Execute Markdown shell blocks verbatim with the caller's documented python3. 218 # Weights are an explicit outside oracle dependency, never silently substituted. 219 if [ -z "${AMD_WEIGHTS:-}" ] || [ ! -d "$AMD_WEIGHTS" ]; then 220 echo 'NOT_RUN documented commands require AMD_WEIGHTS checkpoint directory' 221 exit 77 222 fi 223 OMEGA_OMC="$omc" AMD_DOC_OUT="$out/documented" python3 "$root/tests/amd-exec/documented.py" 224 sha256sum "$out/hsaco.1" "$out/exec.1" "$out/"*.1.hsaco 225 python3 -I "$root/tests/amd/receipt.py" check "$root" "$out" 226 python3 -I "$root/tests/amd-exec/sgemm.py" summary "$kernels"