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 / components / cases.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Native host acceptance only; C references and numerical executables are verification oracles. |
| 3 | note Concatenate into the OM2 conductor after proc.om; no standalone main. |
| 4 | global KCActual uchar 256 |
| 5 | global KCAn ulong 1 |
| 6 | global KCCode uchar 256 |
| 7 | global KCCn ulong 1 |
| 8 | global KCBytes ulong 1 |
| 9 | global KCNum uchar 256 |
| 10 | global KCNn ulong 1 |
| 11 | global KCCfg ulong 16 |
| 12 | global KCFrame uchar 262144 |
| 13 | global KCSize ulong 1 |
| 14 | text KCPrefix "build/components/" |
| 15 | text KCDirect "direct" |
| 16 | text KCRow "rowpipe" |
| 17 | text KCStaged "staged" |
| 18 | text KCDash "-" |
| 19 | text KCActExt ".actual" |
| 20 | text KCExpExt ".expected" |
| 21 | text KCBinExt ".bin" |
| 22 | text KCSasExt ".sass" |
| 23 | text KCNumExt ".numeric" |
| 24 | text KCOracle "-oracle" |
| 25 | text KCInput "build/components/input" |
| 26 | text KCBadOut "build/components/control.actual" |
| 27 | text KCBadRef "build/components/control.expected" |
| 28 | text KCRef0 "build/components/rowpipe-0.actual" |
| 29 | text KCUnit "build/components/component-unit" |
| 30 | text KCCmp "build/components/compose-unit" |
| 31 | text KCGemv "build/components/numerical-gemv" |
| 32 | text KCStageN "build/components/numerical-staged" |
| 33 | text KCDisB "-b" |
| 34 | text KCSM "SM121" |
| 35 | text KCZero "0" |
| 36 | text KCOne "1" |
| 37 | text KCTwo "2" |
| 38 | text KCInv "INVALID" |
| 39 | text KCUnk "UNKNOWN" |
| 40 | text KCSbB "--sb-b" |
| 41 | text KCSbRd "--sb-rd" |
| 42 | text KCBranch "--branch" |
| 43 | text KCRText ".record" |
| 44 | text KCRBad ".record-mutant" |
| 45 | text KCRec "build/components/record-unit" |
| 46 | text KCRecMut "build/components/record-mutant" |
| 47 | text KCDSpecs "256 8 1 4 0\n256 8 1 4 1\n512 16 1 4 0\n512 16 1 4 1\n2048 8 2 8 0\n2048 8 2 8 1\n4096 16 4 16 0\n4096 16 4 16 1\n" |
| 48 | text KCRSpecs "256 8 1 1\n768 8 1 5\n512 16 8 16\n4096 16 1 32\n256 8 2 1\n256 8 4 1\n256 8 8 1\n512 16 1 1\n512 16 2 3\n512 16 4 3\n1024 8 1 2\n2048 16 1 4\n1536 16 1 5\n1024 16 2 3\n" |
| 49 | text KCSSpecs "2048 16 4 16 0\n2048 16 8 16 0\n2048 16 4 16 1\n768 8 4 8 0\n1024 16 4 16 0\n256 8 4 8 0\n" |
| 50 | |
| 51 | fn kc_piece dst edit uchar * pos ulong src view uchar * used ulong to ulong |
| 52 | hp_require le used sub len dst pos |
| 53 | for j ulong used |
| 54 | put dst add pos j get src j |
| 55 | end |
| 56 | ret add pos used |
| 57 | end |
| 58 | fn kc_family fam ulong dst edit uchar * pos ulong to ulong |
| 59 | if eq fam 1 |
| 60 | ret kc_piece dst pos KCDirect len KCDirect |
| 61 | end |
| 62 | if eq fam 2 |
| 63 | ret kc_piece dst pos KCRow len KCRow |
| 64 | end |
| 65 | hp_require eq fam 3 |
| 66 | ret kc_piece dst pos KCStaged len KCStaged |
| 67 | end |
| 68 | fn kc_name fam ulong idx ulong suffix view uchar * dst edit uchar * to ulong |
| 69 | num = new uchar 32 0 |
| 70 | pos = kc_piece dst 0 KCPrefix len KCPrefix |
| 71 | pos = kc_family fam dst pos |
| 72 | pos = kc_piece dst pos KCDash len KCDash |
| 73 | used = hp_num idx num |
| 74 | pos = kc_piece dst pos num used |
| 75 | ret kc_piece dst pos suffix len suffix |
| 76 | end |
| 77 | fn kc_binary fam ulong suffix view uchar * used ulong dst edit uchar * to ulong |
| 78 | pos = kc_piece dst 0 KCPrefix len KCPrefix |
| 79 | pos = kc_family fam dst pos |
| 80 | ret kc_piece dst pos suffix used |
| 81 | end |
| 82 | fn kc_load table view uchar * idx ulong fields ulong to void |
| 83 | for j ulong 16 |
| 84 | put KCCfg j 0 |
| 85 | end |
| 86 | pos = ulong 0 |
| 87 | line = ulong 0 |
| 88 | while lt line idx bound 1024 |
| 89 | hp_require lt pos len table |
| 90 | if eq get table pos 10 |
| 91 | line = add line 1 |
| 92 | end |
| 93 | pos = add pos 1 |
| 94 | end |
| 95 | for j ulong fields |
| 96 | v = ulong 0 |
| 97 | digits = ulong 0 |
| 98 | while lt pos len table bound 20 |
| 99 | c = get table pos |
| 100 | pos = add pos 1 |
| 101 | if or eq c 32 eq c 10 |
| 102 | break |
| 103 | end |
| 104 | hp_require and ge c 48 le c 57 |
| 105 | v = add mul v 10 sub ulong c 48 |
| 106 | digits = add digits 1 |
| 107 | end |
| 108 | hp_require gt digits 0 |
| 109 | put KCCfg j v |
| 110 | end |
| 111 | end |
| 112 | fn kc_spec fam ulong idx ulong to void |
| 113 | if eq fam 1 |
| 114 | kc_load KCDSpecs idx 5 |
| 115 | else |
| 116 | if eq fam 2 |
| 117 | kc_load KCRSpecs idx 4 |
| 118 | else |
| 119 | hp_require eq fam 3 |
| 120 | kc_load KCSSpecs idx 5 |
| 121 | end |
| 122 | end |
| 123 | end |
| 124 | note Globals are never function arguments at the pinned compiler. Copy paths locally. |
| 125 | fn kc_save which ulong path view uchar * used ulong to void |
| 126 | hp_require le used 256 |
| 127 | for j ulong used |
| 128 | if eq which 0 |
| 129 | put KCActual j get path j |
| 130 | else |
| 131 | if eq which 1 |
| 132 | put KCCode j get path j |
| 133 | else |
| 134 | put KCNum j get path j |
| 135 | end |
| 136 | end |
| 137 | end |
| 138 | if eq which 0 |
| 139 | put KCAn 0 used |
| 140 | else |
| 141 | if eq which 1 |
| 142 | put KCCn 0 used |
| 143 | else |
| 144 | put KCNn 0 used |
| 145 | end |
| 146 | end |
| 147 | end |
| 148 | fn kc_path which ulong path edit uchar * to ulong |
| 149 | used = get KCAn 0 |
| 150 | if eq which 1 |
| 151 | used = get KCCn 0 |
| 152 | end |
| 153 | if eq which 2 |
| 154 | used = get KCNn 0 |
| 155 | end |
| 156 | hp_require le used len path |
| 157 | for j ulong used |
| 158 | if eq which 0 |
| 159 | put path j get KCActual j |
| 160 | else |
| 161 | if eq which 1 |
| 162 | put path j get KCCode j |
| 163 | else |
| 164 | put path j get KCNum j |
| 165 | end |
| 166 | end |
| 167 | end |
| 168 | ret used |
| 169 | end |
| 170 | fn kc_read path view uchar * used ulong to ulong |
| 171 | buf = new uchar 262144 0 |
| 172 | n = hp_read path used buf len buf |
| 173 | for j ulong n |
| 174 | put KCFrame j get buf j |
| 175 | end |
| 176 | put KCSize 0 n |
| 177 | ret n |
| 178 | end |
| 179 | fn kc_store path view uchar * used ulong count ulong to void |
| 180 | fd = int fopen path 0 used 578 420 |
| 181 | hp_require ge fd 0 |
| 182 | pos = ulong 0 |
| 183 | while lt pos count bound 262144 |
| 184 | n = write fd KCFrame pos sub count pos |
| 185 | if eq n -4 |
| 186 | continue |
| 187 | end |
| 188 | hp_require gt n 0 |
| 189 | pos = add pos ulong n |
| 190 | end |
| 191 | hp_require eq fclose fd 0 |
| 192 | end |
| 193 | fn kc_pack words ulong to void |
| 194 | for j ulong words |
| 195 | v = get KCCfg j |
| 196 | base = mul j 8 |
| 197 | for k ulong 8 |
| 198 | shift = mul k 8 |
| 199 | octet = uchar and shr v shift 255 |
| 200 | pos = add base k |
| 201 | put KCFrame pos octet |
| 202 | end |
| 203 | end |
| 204 | end |
| 205 | fn kc_input fam ulong used ulong to void |
| 206 | for j ulong 129 |
| 207 | put KCFrame j 0 |
| 208 | end |
| 209 | words = ulong 8 |
| 210 | if eq fam 3 |
| 211 | words = 16 |
| 212 | end |
| 213 | kc_pack words |
| 214 | kc_store KCInput len KCInput used |
| 215 | end |
| 216 | fn kc_run infd int path view uchar * used ulong status long to void |
| 217 | fd = int fopen path 0 used 578 420 |
| 218 | hp_require ge fd 0 |
| 219 | hp_exec infd fd status |
| 220 | hp_require eq fclose fd 0 |
| 221 | end |
| 222 | fn kc_native fam ulong used ulong status long to void |
| 223 | path = new uchar 256 0 |
| 224 | n = kc_binary fam KCOracle 0 path |
| 225 | kc_input fam used |
| 226 | fd = int fopen KCInput 0 len KCInput 0 0 |
| 227 | hp_require ge fd 0 |
| 228 | hp_start path n |
| 229 | kc_run fd KCBadOut len KCBadOut status |
| 230 | hp_require eq fclose fd 0 |
| 231 | end |
| 232 | fn kc_args fam ulong to void |
| 233 | num = new uchar 32 0 |
| 234 | fields = ulong 5 |
| 235 | if eq fam 2 |
| 236 | fields = 4 |
| 237 | end |
| 238 | for j ulong fields |
| 239 | n = hp_num get KCCfg j num |
| 240 | hp_arg num n |
| 241 | end |
| 242 | end |
| 243 | fn kc_ref fam ulong path view uchar * used ulong to void |
| 244 | bin = new uchar 256 0 |
| 245 | n = kc_binary fam KCOracle len KCOracle bin |
| 246 | hp_start bin n |
| 247 | kc_args fam |
| 248 | kc_run -1 path used 0 |
| 249 | end |
| 250 | fn kc_word off ulong to ulong |
| 251 | hp_require le add off 8 get KCSize 0 |
| 252 | v = ulong 0 |
| 253 | for j ulong 8 |
| 254 | v = or v shl ulong get KCFrame add off j mul j 8 |
| 255 | end |
| 256 | ret v |
| 257 | end |
| 258 | fn kc_offset fam ulong to ulong |
| 259 | prefix = ulong 0 |
| 260 | if eq fam 3 |
| 261 | prefix = 8 |
| 262 | hp_require eq kc_word 0 0 |
| 263 | end |
| 264 | n = kc_word prefix |
| 265 | nv = kc_word add prefix 8 |
| 266 | nu = kc_word add prefix 16 |
| 267 | hp_require and gt n 0 le n 1024 |
| 268 | hp_require and le nv 256 le nu 64 |
| 269 | regs = mul add nv nu 16 |
| 270 | start = add add prefix 48 regs |
| 271 | start = add start mul n 64 |
| 272 | hp_require le start get KCSize 0 |
| 273 | ret start |
| 274 | end |
| 275 | fn kc_code start ulong to void |
| 276 | code = new uchar 16384 0 |
| 277 | path = new uchar 256 0 |
| 278 | used = sub get KCSize 0 start |
| 279 | hp_require and gt used 0 le used len code |
| 280 | for j ulong used |
| 281 | put code j get KCFrame add start j |
| 282 | end |
| 283 | pn = kc_path 1 path |
| 284 | hp_write path pn code used |
| 285 | put KCBytes 0 used |
| 286 | end |
| 287 | fn kc_extract fam ulong to void |
| 288 | path = new uchar 256 0 |
| 289 | pn = kc_path 0 path |
| 290 | n = kc_read path pn |
| 291 | start = kc_offset fam |
| 292 | kc_code start |
| 293 | end |
| 294 | fn kc_match sass view uchar * pos ulong word view uchar * used ulong to bool |
| 295 | if gt len word sub used pos |
| 296 | ret false |
| 297 | end |
| 298 | for j ulong len word |
| 299 | c = get sass add pos j |
| 300 | if and ge c 97 le c 122 |
| 301 | c = sub c 32 |
| 302 | end |
| 303 | if ne c get word j |
| 304 | ret false |
| 305 | end |
| 306 | end |
| 307 | ret true |
| 308 | end |
| 309 | fn kc_dis fam ulong idx ulong to void |
| 310 | path = new uchar 256 0 |
| 311 | codepath = new uchar 256 0 |
| 312 | sass = new uchar 1048576 0 |
| 313 | n = kc_name fam idx KCSasExt path |
| 314 | cn = kc_path 1 codepath |
| 315 | hp_tool 2 |
| 316 | hp_arg KCDisB len KCDisB |
| 317 | hp_arg KCSM len KCSM |
| 318 | hp_arg codepath cn |
| 319 | kc_run -1 path n 0 |
| 320 | used = hp_read path n sass len sass |
| 321 | for j ulong used |
| 322 | hp_require not kc_match sass j KCInv used |
| 323 | hp_require not kc_match sass j KCUnk used |
| 324 | end |
| 325 | end |
| 326 | fn kc_numeric fam ulong to void |
| 327 | path = new uchar 256 0 |
| 328 | output = new uchar 256 0 |
| 329 | pn = kc_path 0 path |
| 330 | on = kc_path 2 output |
| 331 | if eq fam 3 |
| 332 | hp_start KCStageN len KCStageN |
| 333 | else |
| 334 | hp_start KCGemv len KCGemv |
| 335 | end |
| 336 | hp_arg path pn |
| 337 | kc_args fam |
| 338 | if eq fam 2 |
| 339 | hp_arg KCZero len KCZero |
| 340 | hp_arg KCTwo len KCTwo |
| 341 | else |
| 342 | hp_arg KCOne len KCOne |
| 343 | end |
| 344 | kc_run -1 output on 0 |
| 345 | end |
| 346 | fn kc_record fam ulong idx ulong expect view uchar * en ulong to void |
| 347 | path = new uchar 256 0 |
| 348 | for mutant ulong 2 |
| 349 | fd = int fopen expect 0 en 0 0 |
| 350 | hp_require ge fd 0 |
| 351 | status = long 0 |
| 352 | n = ulong 0 |
| 353 | if eq mutant 0 |
| 354 | n = kc_name fam idx KCRText path |
| 355 | hp_start KCRec len KCRec |
| 356 | else |
| 357 | n = kc_name fam idx KCRBad path |
| 358 | hp_start KCRecMut len KCRecMut |
| 359 | status = 70 |
| 360 | end |
| 361 | kc_args fam |
| 362 | kc_run fd path n status |
| 363 | hp_require eq fclose fd 0 |
| 364 | end |
| 365 | end |
| 366 | fn kc_positive fam ulong idx ulong to void |
| 367 | path = new uchar 256 0 |
| 368 | expect = new uchar 256 0 |
| 369 | cfg = new ulong 16 0 |
| 370 | actual = new uchar 256 0 |
| 371 | n = kc_name fam idx KCActExt actual |
| 372 | kc_save 0 actual n |
| 373 | n = kc_name fam idx KCBinExt path |
| 374 | kc_save 1 path n |
| 375 | n = kc_name fam idx KCNumExt path |
| 376 | kc_save 2 path n |
| 377 | n = kc_binary fam KCOracle 0 path |
| 378 | used = ulong 64 |
| 379 | if eq fam 3 |
| 380 | used = 128 |
| 381 | end |
| 382 | kc_input fam used |
| 383 | fd = int fopen KCInput 0 len KCInput 0 0 |
| 384 | hp_require ge fd 0 |
| 385 | hp_start path n |
| 386 | kc_run fd actual get KCAn 0 0 |
| 387 | hp_require eq fclose fd 0 |
| 388 | en = kc_name fam idx KCExpExt expect |
| 389 | kc_ref fam expect en |
| 390 | hp_require hp_cmp actual get KCAn 0 expect en |
| 391 | kc_extract fam |
| 392 | kc_dis fam idx |
| 393 | kc_numeric fam |
| 394 | if eq fam 3 |
| 395 | kc_record fam idx expect en |
| 396 | end |
| 397 | for j ulong 16 |
| 398 | put cfg j get KCCfg j |
| 399 | end |
| 400 | rc_case fam idx cfg |
| 401 | end |
| 402 | fn kc_empty path view uchar * used ulong to void |
| 403 | n = kc_read path used |
| 404 | hp_require eq n 0 |
| 405 | end |
| 406 | fn kc_reserved fam ulong to void |
| 407 | kc_spec fam 0 |
| 408 | used = ulong 64 |
| 409 | status = long 66 |
| 410 | slot = ulong 5 |
| 411 | if eq fam 3 |
| 412 | used = 128 |
| 413 | status = 0 |
| 414 | slot = 6 |
| 415 | end |
| 416 | put KCCfg slot 1 |
| 417 | kc_native fam used status |
| 418 | if eq fam 3 |
| 419 | n = kc_read KCBadOut len KCBadOut |
| 420 | hp_require eq n 8 |
| 421 | hp_require eq kc_word 0 1 |
| 422 | else |
| 423 | kc_empty KCBadOut len KCBadOut |
| 424 | end |
| 425 | end |
| 426 | fn kc_mutant mutation view uchar * to void |
| 427 | path = new uchar 256 0 |
| 428 | n = kc_binary 2 KCOracle len KCOracle path |
| 429 | hp_start path n |
| 430 | kc_args 2 |
| 431 | hp_arg mutation len mutation |
| 432 | kc_run -1 KCBadRef len KCBadRef 0 |
| 433 | hp_require not hp_cmp KCRef0 len KCRef0 KCBadRef len KCBadRef |
| 434 | end |
| 435 | fn kc_resource to void |
| 436 | path = new uchar 256 0 |
| 437 | kc_spec 2 0 |
| 438 | put KCCfg 0 4096 |
| 439 | put KCCfg 3 16 |
| 440 | kc_native 2 64 67 |
| 441 | kc_empty KCBadOut len KCBadOut |
| 442 | n = kc_binary 2 KCOracle len KCOracle path |
| 443 | fd = int fopen KCInput 0 len KCInput 0 0 |
| 444 | hp_require ge fd 0 |
| 445 | hp_start path n |
| 446 | kc_run fd KCBadRef len KCBadRef 66 |
| 447 | hp_require eq fclose fd 0 |
| 448 | kc_empty KCBadRef len KCBadRef |
| 449 | kc_native 2 63 65 |
| 450 | kc_empty KCBadOut len KCBadOut |
| 451 | kc_native 2 65 65 |
| 452 | kc_empty KCBadOut len KCBadOut |
| 453 | end |
| 454 | fn kc_cases to void |
| 455 | hp_start KCUnit len KCUnit |
| 456 | hp_exec -1 -1 0 |
| 457 | hp_start KCCmp len KCCmp |
| 458 | hp_exec -1 -1 0 |
| 459 | for fam ulong 3 |
| 460 | family = add fam 1 |
| 461 | count = ulong 8 |
| 462 | if eq family 2 |
| 463 | count = 14 |
| 464 | end |
| 465 | if eq family 3 |
| 466 | count = 6 |
| 467 | end |
| 468 | for idx ulong count |
| 469 | kc_spec family idx |
| 470 | kc_positive family idx |
| 471 | end |
| 472 | kc_reserved family |
| 473 | end |
| 474 | kc_spec 2 0 |
| 475 | kc_mutant KCSbB |
| 476 | kc_mutant KCSbRd |
| 477 | kc_mutant KCBranch |
| 478 | kc_resource |
| 479 | end |