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/tools/sm121dis/corpus.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 / tools / sm121dis / corpus.sh` 74 lines · 4461 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # corpus.sh : collects every kernel the library builds, without a GPU, into . 4 # Each GPU test runs in its host-only (and simulator) modes with OMEGA_KERNEL_DUMP_DIR set, so every program the 5 # library encodes lands as .bin (src/omega_blackwell_codegen.c omega_kernel_dump). In CUDA++ the corpus is the 6 # GPU library's kernels; the numeric kernels (DIV, SQRT, load/store, reductions, own encoder) and gpu_tern_test stay 7 # in omega-mv with their producers. Run from the repo root after 8 # `make OUT_DIR= sm121dis-corpus-bins` (mk/sm121dis.mk). Any failed producer invalidates the corpus. 9 set -u 10 OUT=$1; K=$2 11 mkdir -p "$K"; K=$(cd "$K" && pwd) 12 export OMEGA_KERNEL_DUMP_DIR="$K" 13 # Manifest (CUDA++ C6, DRA-475): each kernel is credited to the first producer that wrote it (a later producer that 14 # builds the same bytes finds the file already there); PRODUCERS.tsv counts the new kernels of each run. 15 : > "$K/.seen"; : > "$K/.firstby"; printf 'producer\tnew_kernels\tkernels_so_far\n' > "$K/PRODUCERS.tsv" 16 run() { 17 printf '%s' "$*: " 18 "$@" > "$K/producer.log" 2>&1; rc=$? 19 echo "exit $rc, $(ls "$K"/*.bin 2>/dev/null | wc -l) kernels so far" 20 if [ "$rc" -ne 0 ]; then 21 cat "$K/producer.log" >&2 22 echo "VERDICT FAIL: corpus producer failed: $*" >&2 23 exit "$rc" 24 fi 25 # src/omega_blackwell_codegen.c omega_kernel_dump: a kernel that could not be written whole is missing from the corpus 26 if grep -q '^omega_kernel_dump: ' "$K/producer.log"; then 27 grep '^omega_kernel_dump: ' "$K/producer.log" >&2 28 echo "VERDICT FAIL: kernels not captured whole: $*" >&2 29 exit 1 30 fi 31 rm -f "$K/producer.log" 32 p=$(basename "$1"); shift; [ $# -gt 0 ] && p="$p $*" 33 (cd "$K" && ls -1 | grep '\.bin$' | LC_ALL=C sort) > "$K/.now" 34 LC_ALL=C comm -13 "$K/.seen" "$K/.now" > "$K/.new" 35 while read -r f; do printf '%s\t%s\n' "$f" "$p" >> "$K/.firstby"; done < "$K/.new" 36 printf '%s\t%s\t%s\n' "$p" "$(wc -l < "$K/.new")" "$(wc -l < "$K/.now")" >> "$K/PRODUCERS.tsv" 37 mv "$K/.now" "$K/.seen" 38 } 39 for t in gpu_matmul_api_test gpu_elementwise_test gpu_reconv_test gpu_attention_test gpu_moe_window_test gpu_fp8_api_test \ 40 gpu_decode_attn_test gpu_router_test gpu_bf16_gemv_test gpu_fp8gemm_test gpu_tc_probe_test \ 41 gpu_tc_peak_test gpu_pf_mem_test gpu_qmma_probe_test gpu_cmdlist_test gpu_decode_graph_test; do 42 run "$OUT/$t" --host-only 43 done 44 run "$OUT/gpu_attention_test" --hd 128 --host-only 45 for t in gpu_tcgemm_test gpu_prefill_attn_test gpu_pfgemm_test gpu_qgemm_test gpu_pfhost_test gpu_cmdlist_test; do 46 run "$OUT/$t" --host-only; run "$OUT/$t" --sim 47 done 48 run "$OUT/gpu_gpr_boundary_test" 49 for t in gpu_gemm_test gpu_streams_test gpu_mathlibs_test; do 50 run "$OUT/$t" --host-only; run "$OUT/$t" --sim 51 done 52 # the scan kernels depend only on kind and mutant, so the short simulator sweep builds the same set as the full one 53 run "$OUT/gpu_scan_test" --host-only; run "$OUT/gpu_scan_test" --sim --quick 54 run "$OUT/gpu_isolation_test" --host-only 55 # the hazard checker's sweep (every generator over its accepted shapes, patched as the launchers do): bw_hazard_test 56 # --disasm reads each of these kernels through our disassembler, so each is compared with nvdisasm here 57 run "$OUT/bw_hazard_test" 58 # MANIFEST.tsv: one row per distinct kernel file, its full SHA-256 (the file name is its first 8 bytes), size, words and 59 # first producer. Its own SHA-256 is printed, so a receipt can name the exact corpus. 60 printf 'kernel\tsha256\tbytes\twords\tfirst_producer\n' > "$K/MANIFEST.tsv" 61 bad=0 62 for f in "$K"/*.bin; do 63 b=$(basename "$f") 64 h=$(sha256sum < "$f" | cut -c1-64) 65 [ "$(printf '%s' "$h" | cut -c1-16).bin" = "$b" ] || { echo "VERDICT FAIL: $b does not carry its content hash ($h)" >&2; bad=1; } 66 s=$(wc -c < "$f") 67 pr=$(grep -F "$b " "$K/.firstby" | head -1 | cut -f2-) 68 [ -n "$pr" ] || { echo "VERDICT FAIL: $b has no producer" >&2; bad=1; } 69 printf '%s\t%s\t%s\t%s\t%s\n' "$b" "$h" "$s" $((s / 16)) "$pr" >> "$K/MANIFEST.tsv" 70 done 71 rm -f "$K/.seen" "$K/.new" "$K/.firstby" 72 [ "$bad" = 0 ] || exit 1 73 echo "manifest: $(($(wc -l < "$K/MANIFEST.tsv") - 1)) kernels, $(awk -F'\t' 'NR>1{w+=$4} END{print w+0}' "$K/MANIFEST.tsv") words, sha256 $(sha256sum < "$K/MANIFEST.tsv" | cut -c1-64)" 74 echo "corpus: $(ls "$K"/*.bin | wc -l) kernels in $K"