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
CUDApp / tests / host-trace / badfrag.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note badfrag GOOD.otr PREFIX: writes PREFIX.N.otr for N = 0..12, each the good OTR1 file with one |
| 3 | note fault. omtrace v must reject mutant N with exit status listed in tests/host-trace/run-host-trace.sh. |
| 4 | note Mutants: 0 magic, 1 version, 2 record size, 3 clock domain, 4 truncated by one byte, |
| 5 | note 5 name count above 256, 6 record 0 kind 12, 7 record 0 flags 2, 8 record 0 ends before it starts, |
| 6 | note 9 a space in the first name, 10 record 0 names id 9999, 11 header open-span count 1, |
| 7 | note 12 record 2 (an instant) has a duration. Record 2 must be an instant in the input. |
| 8 | global img uchar 262144 |
| 9 | global work uchar 262144 |
| 10 | global path uchar 4096 |
| 11 | global st ulong 4 |
| 12 | note st: 0 image bytes, 1 prefix bytes |
| 13 | fn putle at ulong v ulong k ulong to void |
| 14 | for i ulong k |
| 15 | put work add at i uchar and shr v mul i 8 255 |
| 16 | end |
| 17 | end |
| 18 | fn rd at ulong k ulong to ulong |
| 19 | v = ulong 0 |
| 20 | for i ulong k |
| 21 | v = or v shl ulong get img add at i mul i 8 |
| 22 | end |
| 23 | ret v |
| 24 | end |
| 25 | fn fresh to void |
| 26 | for i ulong get st 0 |
| 27 | put work i get img i |
| 28 | end |
| 29 | end |
| 30 | fn namepos to ulong |
| 31 | ret add 64 mul rd 8 4 48 |
| 32 | end |
| 33 | fn mutate m ulong to ulong |
| 34 | note returns the mutant's length |
| 35 | n = get st 0 |
| 36 | fresh |
| 37 | if eq m 0 |
| 38 | put work 0 xor get img 0 1 |
| 39 | end |
| 40 | if eq m 1 |
| 41 | putle 4 2 2 |
| 42 | end |
| 43 | if eq m 2 |
| 44 | putle 6 40 2 |
| 45 | end |
| 46 | if eq m 3 |
| 47 | putle 20 2 4 |
| 48 | end |
| 49 | if eq m 4 |
| 50 | n = sub n 1 |
| 51 | end |
| 52 | if eq m 5 |
| 53 | putle 44 300 4 |
| 54 | end |
| 55 | if eq m 6 |
| 56 | putle 64 12 2 |
| 57 | end |
| 58 | if eq m 7 |
| 59 | putle 66 2 2 |
| 60 | end |
| 61 | if eq m 8 |
| 62 | putle 80 0 8 |
| 63 | end |
| 64 | if eq m 9 |
| 65 | put work add namepos 6 32 |
| 66 | end |
| 67 | if eq m 10 |
| 68 | putle 68 9999 4 |
| 69 | end |
| 70 | if eq m 11 |
| 71 | putle 48 1 4 |
| 72 | end |
| 73 | if eq m 12 |
| 74 | r = ulong 160 |
| 75 | putle add r 16 add rd add r 8 8 1 8 |
| 76 | end |
| 77 | ret n |
| 78 | end |
| 79 | fn save m ulong n ulong to bool |
| 80 | p = get st 1 |
| 81 | put path p 46 |
| 82 | d = p |
| 83 | if ge m 10 |
| 84 | put path add p 1 49 |
| 85 | d = add p 1 |
| 86 | end |
| 87 | put path add d 1 uchar add 48 rem m 10 |
| 88 | put path add d 2 46 |
| 89 | put path add d 3 111 |
| 90 | put path add d 4 116 |
| 91 | put path add d 5 114 |
| 92 | fd = fopen path 0 add d 6 577 384 |
| 93 | if lt fd 0 |
| 94 | ret false |
| 95 | end |
| 96 | w = write int fd work 0 n |
| 97 | c = fclose int fd |
| 98 | ret eq w long n |
| 99 | end |
| 100 | fn main to int |
| 101 | if ne argcnt 3 |
| 102 | ret 2 |
| 103 | end |
| 104 | k = argread 1 path 0 4095 |
| 105 | if le k 0 |
| 106 | ret 2 |
| 107 | end |
| 108 | fd = fopen path 0 ulong k 0 0 |
| 109 | if lt fd 0 |
| 110 | ret 2 |
| 111 | end |
| 112 | r = read int fd img 0 len img |
| 113 | c = fclose int fd |
| 114 | if lt r 64 |
| 115 | ret 2 |
| 116 | end |
| 117 | put st 0 ulong r |
| 118 | if ne rd 160 2 5 |
| 119 | ret 3 |
| 120 | end |
| 121 | p = argread 2 path 0 4000 |
| 122 | if le p 0 |
| 123 | ret 2 |
| 124 | end |
| 125 | put st 1 ulong p |
| 126 | for m ulong 13 |
| 127 | if not save m mutate m |
| 128 | ret 4 |
| 129 | end |
| 130 | end |
| 131 | ret 0 |
| 132 | end |