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 / staged-caller.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Concat bw_alloc,bw_effect,bw_project,staged,bw_enc_sm121 then this caller. |
| 3 | note stdin exact128 bytes LE64 spec16. stdout LE64 rc then successful payload. |
| 4 | note Payload stats4,GPRpeak,UGPRpeak,(width,phys) GPRs then UGPRs,IR8cells,padded code. |
| 5 | note Compare entire stdout with staged-oracle built against existing C generator. |
| 6 | note Filed algorithm provenance src/omega_blackwell_codegen_gemm.c at b759afc3. |
| 7 | note First/changed components:K2048,LB16,MT4,W16,RM0 then MT8; also RM1 MT4. |
| 8 | note Exercise LB8 K768 MT4 W8 oddKS3 and K1024 LB16 MT4 W16 evenKS2. |
| 9 | note Mutants1..4,reserved6..15,rowmap2,K0,oddKS5,MT3,W3,NJ>8 must refuse. |
| 10 | global SGInput uchar 128 |
| 11 | global SGOutput uchar 8 |
| 12 | fn sg_word v ulong to void |
| 13 | for j ulong 8 |
| 14 | put SGOutput j uchar and shr v mul j 8 255 |
| 15 | end |
| 16 | pos = ulong 0 |
| 17 | while lt pos 8 bound 8 |
| 18 | n = write 1 SGOutput pos sub ulong 8 pos |
| 19 | if le n 0 |
| 20 | exit 74 |
| 21 | end |
| 22 | pos = add pos ulong n |
| 23 | end |
| 24 | end |
| 25 | fn sg_input to bool |
| 26 | pos = ulong 0 |
| 27 | while lt pos 128 bound 128 |
| 28 | n = read 0 SGInput pos sub ulong 128 pos |
| 29 | if le n 0 |
| 30 | ret false |
| 31 | end |
| 32 | pos = add pos ulong n |
| 33 | end |
| 34 | ret true |
| 35 | end |
| 36 | fn sg_parse spec edit ulong 16 to void |
| 37 | for k ulong 16 |
| 38 | v = ulong 0 |
| 39 | for j ulong 8 |
| 40 | v = or v shl ulong get SGInput add mul k 8 j mul j 8 |
| 41 | end |
| 42 | put spec k v |
| 43 | end |
| 44 | end |
| 45 | fn sg_stats st view ulong 4 rs view ulong 4 to void |
| 46 | sg_word 0 |
| 47 | for k ulong 4 |
| 48 | sg_word get st k |
| 49 | end |
| 50 | sg_word get rs 1 |
| 51 | sg_word get rs 2 |
| 52 | end |
| 53 | fn sg_regsout meta view ulong 2048 phys view ulong 288 nv ulong nu ulong to void |
| 54 | for k ulong nv |
| 55 | sg_word get meta k |
| 56 | sg_word get phys k |
| 57 | end |
| 58 | for k ulong nu |
| 59 | sg_word get meta add k 256 |
| 60 | sg_word get phys add k 256 |
| 61 | end |
| 62 | end |
| 63 | fn sg_irout ins view ulong 8192 n ulong to void |
| 64 | for k ulong mul n 8 |
| 65 | sg_word get ins k |
| 66 | end |
| 67 | end |
| 68 | fn sg_codeout code view uchar 16384 nbytes ulong to bool |
| 69 | pos = ulong 0 |
| 70 | while lt pos nbytes bound 16384 |
| 71 | n = write 1 code pos sub nbytes pos |
| 72 | if le n 0 |
| 73 | ret false |
| 74 | end |
| 75 | pos = add pos ulong n |
| 76 | end |
| 77 | ret true |
| 78 | end |
| 79 | fn main to int |
| 80 | spec = new ulong 16 0 |
| 81 | ins = new ulong 8192 99 |
| 82 | meta = new ulong 2048 99 |
| 83 | phys = new ulong 288 0 |
| 84 | st = new ulong 4 99 |
| 85 | rs = new ulong 4 0 |
| 86 | code = new uchar 16384 0 |
| 87 | if not sg_input |
| 88 | ret 65 |
| 89 | end |
| 90 | sg_parse spec |
| 91 | rc = bc_staged spec ins meta st |
| 92 | if ne rc 0 |
| 93 | for k ulong 8192 |
| 94 | if ne get ins k 0 |
| 95 | ret 70 |
| 96 | end |
| 97 | end |
| 98 | for k ulong 2048 |
| 99 | if ne get meta k 0 |
| 100 | ret 71 |
| 101 | end |
| 102 | end |
| 103 | for k ulong 4 |
| 104 | if ne get st k 0 |
| 105 | ret 72 |
| 106 | end |
| 107 | end |
| 108 | sg_word ulong rc |
| 109 | ret 0 |
| 110 | end |
| 111 | if ne bc_regalloc ins get st 0 meta phys rs 128 0 |
| 112 | ret 67 |
| 113 | end |
| 114 | nbytes = bc_encode ins phys get st 0 1 code |
| 115 | if eq nbytes 0 |
| 116 | ret 68 |
| 117 | end |
| 118 | sg_stats st rs |
| 119 | sg_regsout meta phys get st 1 get st 2 |
| 120 | sg_irout ins get st 0 |
| 121 | if not sg_codeout code nbytes |
| 122 | ret 74 |
| 123 | end |
| 124 | ret 0 |
| 125 | end |