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 / d8_mutants.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note tests/d8_mutants.om -- the D8 semantic mutants of om/graph/hello-plan.om (developer bar D8, |
| 3 | note docs/issues/D8-process-tax.md). Make concatenates tests/d8_lib.om in front and compiles with the pinned |
| 4 | note seeded omc; mk/graph-residue.mk runs it as part of test-graph-residue-mutants, after om/graph/residue-mutants.py. |
| 5 | note usage: d8_mutants OUT_DIR CC [CFLAG ...] (environment: OMEGA_OMC, OMEGA_BRIDGE, PATH, HOME, TMPDIR) |
| 6 | note For each mutant: the site must occur exactly once; the mutant source goes through om/units.sh (the |
| 7 | note bridge's checked converter, OMEGA_UNITS=hello_plan=<mutant> into the lane), tests/test_graph_residue.c is |
| 8 | note linked against the mutant's cudapp_om_hello_plan.c, and the result must exit nonzero or print other bytes |
| 9 | note than OUT_DIR/graph-residue does. A surviving mutant is a FAIL (exit 1). Lanes: |
| 10 | note OUT_DIR/graph-residue-mutants/<name>/{mutant.om,generate.log,compile.log,test,run.log}. |
| 11 | note Regions: 1 message, 4 OUT_DIR (absolute), 5 CC, 6 lane, 7 file path, 8 log path, 9 lane file, 31 cwd. |
| 12 | note execprog gives children an empty environment, so om/units.sh and CC run under /usr/bin/env with the |
| 13 | note variables named above (until omega-mv has an execprog form that takes an environment). |
| 14 | global X uchar 524288 |
| 15 | global Xn ulong 1 |
| 16 | global P ulong 1 |
| 17 | |
| 18 | text TUse "usage: d8_mutants OUT_DIR CC [CFLAG ...]\n" |
| 19 | text TLanes "/graph-residue-mutants" |
| 20 | text TExp "/graph-residue-mutants/d8-expected.log" |
| 21 | text TRef "/graph-residue" |
| 22 | text TLib "/libomega_gpu.a" |
| 23 | text TPlan "om/graph/hello-plan.om" |
| 24 | text TMut "/mutant.om" |
| 25 | text TGen "/generate.log" |
| 26 | text TCmp "/compile.log" |
| 27 | text TBin "/test" |
| 28 | text TRun "/run.log" |
| 29 | text TUnitC "/cudapp_om_hello_plan.c" |
| 30 | text TEnvB "/usr/bin/env" |
| 31 | text THomeV "HOME=" |
| 32 | text TTmpV "TMPDIR=" |
| 33 | text TOmcV "OMEGA_OMC=" |
| 34 | text TBriV "OMEGA_BRIDGE=" |
| 35 | text TUnitsV "OMEGA_UNITS=hello_plan=" |
| 36 | text TDestV "OMEGA_UNITS_DEST=" |
| 37 | text TSh "/bin/sh" |
| 38 | text TUnitsSh "om/units.sh" |
| 39 | text TTest "tests/test_graph_residue.c" |
| 40 | text TPth "-lpthread" |
| 41 | text TLm "-lm" |
| 42 | text TOut "-o" |
| 43 | text TFail "FAIL " |
| 44 | text TSite ": mutation site count " |
| 45 | text TGenF ": om/units.sh exit " |
| 46 | text TCmpF ": compile exit " |
| 47 | text TSurv "FAIL mutant " |
| 48 | text TSurv2 " survived" |
| 49 | text TKill "mutant " |
| 50 | text TKill2 " killed rc=" |
| 51 | text TRefF "FAIL graph-residue reference: exit " |
| 52 | text TPass "PASS graph residue D8: 3 compiled semantic mutants killed" |
| 53 | text TN1 "d8-own-round" |
| 54 | text TO1 "ownk = div add get c 3 1023 1024" |
| 55 | text TW1 "ownk = div get c 3 1024" |
| 56 | text TN2 "d8-beyond-sign" |
| 57 | text TO2 "put d 4 1" |
| 58 | text TW2 "put d 4 0" |
| 59 | text TN3 "d8-driver-kib" |
| 60 | text TO3 "put d 5 div add get c 4 1023 1024" |
| 61 | text TW3 "put d 5 div get c 4 1000" |
| 62 | |
| 63 | note region d = OUT_DIR t |
| 64 | fn opath d ulong t view uchar * to void |
| 65 | bclr d |
| 66 | bb d 4 |
| 67 | bt d t |
| 68 | end |
| 69 | |
| 70 | note region d = lane t |
| 71 | fn lpath d ulong t view uchar * to void |
| 72 | bclr d |
| 73 | bb d 6 |
| 74 | bt d t |
| 75 | end |
| 76 | |
| 77 | note truncates the file named by region r |
| 78 | fn trunc r ulong to void |
| 79 | bclr 3 |
| 80 | bfile r 3 578 |
| 81 | end |
| 82 | |
| 83 | note sites of t in L; the last one in P |
| 84 | fn lfind t view uchar * to ulong |
| 85 | n = get Ln 0 |
| 86 | k = ulong 0 |
| 87 | if lt n len t |
| 88 | ret k |
| 89 | end |
| 90 | for p ulong add sub n len t 1 |
| 91 | if lat p t |
| 92 | k = add k 1 |
| 93 | put P 0 p |
| 94 | end |
| 95 | end |
| 96 | ret k |
| 97 | end |
| 98 | |
| 99 | note writes L[a, e) to fd |
| 100 | fn lwr fd int a ulong e ulong to void |
| 101 | while lt a e bound 999999 |
| 102 | w = write fd L a sub e a |
| 103 | if le w 0 |
| 104 | bfail |
| 105 | end |
| 106 | a = add a ulong w |
| 107 | end |
| 108 | end |
| 109 | |
| 110 | fn say1 t view uchar * to void |
| 111 | bs 1 t |
| 112 | bc 1 10 |
| 113 | bout 1 1 |
| 114 | end |
| 115 | |
| 116 | note the message region 1 gets "FAIL <nm><b><rc>" (or "mutant <nm><b><rc>" when not fail) and is printed |
| 117 | fn sayrc fail bool nm view uchar * b view uchar * rc long to void |
| 118 | bs 1 TKill |
| 119 | if fail |
| 120 | bs 1 TFail |
| 121 | end |
| 122 | bt 1 nm |
| 123 | bt 1 b |
| 124 | bl 1 rc |
| 125 | bc 1 10 |
| 126 | bout 1 1 |
| 127 | end |
| 128 | |
| 129 | note writes the mutant (L with the one site of old replaced by new) to lane/mutant.om |
| 130 | fn wmut old view uchar * rep view uchar * to void |
| 131 | lpath 7 TMut |
| 132 | fd = bopen 7 578 |
| 133 | if lt fd 0 |
| 134 | bfail |
| 135 | end |
| 136 | p = get P 0 |
| 137 | lwr int fd 0 p |
| 138 | bs 3 rep |
| 139 | bout int fd 3 |
| 140 | lwr int fd add p len old get Ln 0 |
| 141 | c = fclose int fd |
| 142 | end |
| 143 | |
| 144 | fn gen to long |
| 145 | alclr |
| 146 | alt TEnvB |
| 147 | envkv TPathV |
| 148 | envkv THomeV |
| 149 | envkv TTmpV |
| 150 | envkv TOmcV |
| 151 | envkv TBriV |
| 152 | bs 9 TUnitsV |
| 153 | bb 9 7 |
| 154 | alb 9 |
| 155 | bs 9 TDestV |
| 156 | bb 9 6 |
| 157 | alb 9 |
| 158 | alt TSh |
| 159 | alt TUnitsSh |
| 160 | lpath 8 TGen |
| 161 | trunc 8 |
| 162 | ret runwait 1 8 |
| 163 | end |
| 164 | |
| 165 | fn build to long |
| 166 | alclr |
| 167 | alt TEnvB |
| 168 | envkv TPathV |
| 169 | envkv THomeV |
| 170 | envkv TTmpV |
| 171 | alb 5 |
| 172 | for i ulong sub ulong argcnt 3 |
| 173 | barg add i 3 9 |
| 174 | alb 9 |
| 175 | end |
| 176 | alt TTest |
| 177 | lpath 9 TUnitC |
| 178 | alb 9 |
| 179 | opath 9 TLib |
| 180 | alb 9 |
| 181 | alt TPth |
| 182 | alt TLm |
| 183 | alt TOut |
| 184 | lpath 9 TBin |
| 185 | alb 9 |
| 186 | lpath 8 TCmp |
| 187 | trunc 8 |
| 188 | ret runwait 1 8 |
| 189 | end |
| 190 | |
| 191 | note the run log (region 8) against the reference X |
| 192 | fn same to bool |
| 193 | if not fload 8 |
| 194 | ret false |
| 195 | end |
| 196 | n = get Ln 0 |
| 197 | if ne n get Xn 0 |
| 198 | ret false |
| 199 | end |
| 200 | for i ulong n |
| 201 | if ne get L i get X i |
| 202 | ret false |
| 203 | end |
| 204 | end |
| 205 | ret true |
| 206 | end |
| 207 | |
| 208 | fn mutant nm view uchar * old view uchar * rep view uchar * to bool |
| 209 | bclr 8 |
| 210 | bt 8 TPlan |
| 211 | if not fload 8 |
| 212 | bfail |
| 213 | end |
| 214 | k = lfind old |
| 215 | if ne k 1 |
| 216 | sayrc true nm TSite long k |
| 217 | ret false |
| 218 | end |
| 219 | opath 6 TLanes |
| 220 | bt 6 TSl |
| 221 | bt 6 nm |
| 222 | mkdirp 6 |
| 223 | wmut old rep |
| 224 | rc = gen |
| 225 | if ne rc 0 |
| 226 | sayrc true nm TGenF rc |
| 227 | ret false |
| 228 | end |
| 229 | rc = build |
| 230 | if ne rc 0 |
| 231 | sayrc true nm TCmpF rc |
| 232 | ret false |
| 233 | end |
| 234 | alclr |
| 235 | lpath 9 TBin |
| 236 | alb 9 |
| 237 | lpath 8 TRun |
| 238 | trunc 8 |
| 239 | rc = runwait 1 8 |
| 240 | if and eq rc 0 same |
| 241 | bs 1 TSurv |
| 242 | bt 1 nm |
| 243 | bt 1 TSurv2 |
| 244 | bc 1 10 |
| 245 | bout 1 1 |
| 246 | ret false |
| 247 | end |
| 248 | sayrc false nm TKill2 rc |
| 249 | ret true |
| 250 | end |
| 251 | |
| 252 | note runs OUT_DIR/graph-residue once and keeps its output in X |
| 253 | fn reference to bool |
| 254 | opath 6 TLanes |
| 255 | mkdirp 6 |
| 256 | alclr |
| 257 | opath 9 TRef |
| 258 | alb 9 |
| 259 | opath 8 TExp |
| 260 | trunc 8 |
| 261 | rc = runwait 1 8 |
| 262 | if ne rc 0 |
| 263 | bs 1 TRefF |
| 264 | bl 1 rc |
| 265 | bc 1 10 |
| 266 | bout 1 1 |
| 267 | ret false |
| 268 | end |
| 269 | if not fload 8 |
| 270 | bfail |
| 271 | end |
| 272 | n = get Ln 0 |
| 273 | for i ulong n |
| 274 | put X i get L i |
| 275 | end |
| 276 | put Xn 0 n |
| 277 | ret true |
| 278 | end |
| 279 | |
| 280 | fn main to int |
| 281 | if lt argcnt 3 |
| 282 | r = write 2 TUse 0 len TUse |
| 283 | ret 2 |
| 284 | end |
| 285 | barg 1 4 |
| 286 | barg 2 5 |
| 287 | if ne get B mul ulong 4 4096 47 |
| 288 | k = cwd B mul ulong 31 4096 4095 |
| 289 | if le k 0 |
| 290 | bfail |
| 291 | end |
| 292 | put Bn 31 sub ulong k 1 |
| 293 | bt 31 TSl |
| 294 | bb 31 4 |
| 295 | bclr 4 |
| 296 | bb 4 31 |
| 297 | end |
| 298 | if not reference |
| 299 | ret 1 |
| 300 | end |
| 301 | if not mutant TN1 TO1 TW1 |
| 302 | ret 1 |
| 303 | end |
| 304 | if not mutant TN2 TO2 TW2 |
| 305 | ret 1 |
| 306 | end |
| 307 | if not mutant TN3 TO3 TW3 |
| 308 | ret 1 |
| 309 | end |
| 310 | say1 TPass |
| 311 | ret 0 |
| 312 | end |