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/tools-om/fmt.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 / tools-om / fmt.sh` 53 lines · 2288 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # fmt.om acceptance: om/tools/fmt.om (fm_f = "%.Pf", fm_g = "%.Pg"), composed with a test export, against 4 # glibc snprintf through tests/tools-om/fmt_diff.c; a flipped-record negative control; recompiled mutants. 5 # FMT_DIFF_N (default 40000) random doubles, nine conversions each, plus the specials. 6 # Run under: bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 7 set -eu 8 ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) 9 cd "$ROOT" 10 tmp=$(mktemp -d) 11 trap 'rm -rf "$tmp"' EXIT 12 . tests/tools-om/lib.sh 13 tom_pin 14 N=${FMT_DIFF_N:-40000} 15 UNIT=$tmp/fmtt.om 16 { cat om/tools/fmt.om; cat <<'OM' 17 18 note fmtt: test export, conversion g (0 "%.Pf", else "%.Pg") of the f64 with bits xb at precision pr. 19 fn fmtt xb ulong pr ulong g ulong o edit uchar 1600 to ulong 20 x = bitcast f64 xb 21 if ne g 0 22 ret fm_g x pr o 23 end 24 ret fm_f x pr o 25 end 26 OM 27 } > "$UNIT" 28 OMEGA_SEEDED_OMC="$OMC" sh "$BRIDGE/tools/bridge-seeded" c "$UNIT" > "$tmp/fmtt.c" 29 $CC $TOM_CFLAGS -o "$tmp/fmt_diff" tests/tools-om/fmt_diff.c "$tmp/fmtt.c" -lm 30 "$tmp/fmt_diff" "$N" c > "$tmp/c.out" 31 "$tmp/fmt_diff" "$N" om > "$tmp/om.out" 32 cmp "$tmp/c.out" "$tmp/om.out" || { echo "FAIL fmt differential"; diff "$tmp/c.out" "$tmp/om.out" | head; exit 1; } 33 lines=$(wc -l < "$tmp/c.out") 34 echo "differential: $lines conversions identical to glibc snprintf" 35 tom_flip "$tmp/c.out" "$tmp/om.out" 36 37 killed=0 38 "$tmp/fmt_diff" 2000 c > "$tmp/c.small" 39 mut() { # NAME SITE REPLACEMENT 40 tom_mutant "$1" "$UNIT" "$2" "$3" 41 $CC $TOM_CFLAGS -o "$tmp/$1.bin" tests/tools-om/fmt_diff.c "$tmp/$1.c" -lm 42 "$tmp/$1.bin" 2000 om > "$tmp/$1.out" || true 43 if cmp -s "$tmp/c.small" "$tmp/$1.out"; then echo "FAIL mutant $1 survived"; exit 1; fi 44 echo "mutant $1: killed ($(cmp "$tmp/c.small" "$tmp/$1.out" | sed 's/.*, //'))"; killed=$((killed + 1)) 45 } 46 mut ties_even 'ret and sub ulong get d sub q 1 48 1' 'ret ulong 1' 47 mut round_down 'if lt c 53' 'if lt c 52' 48 mut pow5 'n = fm_mul l n `1220703125`' 'n = fm_mul l n `1220703124`' 49 mut exp_digits 'if lt xa 10' 'if lt xa 9' 50 mut g_small 'if gt xa 4' 'if gt xa 5' 51 mut g_large 'if ge xa pr' 'if gt xa pr' 52 echo "fmt mutants: $killed killed" 53 echo "tools-om fmt: PASS (differential $lines conversions, negative control, $killed mutants killed)"