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/om/disasm/opmove_test.om # 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 / om / disasm / opmove_test.om` 238 lines · 5869 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note opmove_test.om: BlackwellIR ops 64..79 after the #280 numbering move (evidence/INTEG-280-`20261110`/numbering.txt), 3 note through the seeded encoder and Omega's own sm_121 decoder (C6). Concatenate after om/encoder/bw_enc_sm121.om 4 note and om/disasm/sm121_dis.om; mk/sm121dis.mk test-sm121dis-opmove compiles it with the pinned omc. 5 note No arguments: encode one row of each op 64..79 with enc1 and decode its word with sm121_dis. Every word must 6 note decode (no ??) and its mnemonic, the text before the first space, must equal the op's entry of omnem. 7 note Exit 0; 10 + (op - 64) when the encoder refuses the row or the decoder does not know the word; 40 + (op - 64) 8 note when the mnemonic differs. 9 note Three arguments: the same check with the rows numbered as before the move (I2FP_U32 .. S32_F64 at 64..78, the 10 note stale numbering, no ATOMG row). It must fail: the I2FP_U32 row then encodes op 64, ATOMG, so the exit is 41. 11 note One argument: write the sixteen instructions (256 bytes) on stdout for the ORACLE. 12 note Two arguments: read the ORACLE's text on stdin and require the decoder's text of each instruction, followed by 13 note " ;", in order. Exit 0, 4 when a line is missing or out of order, 70 on a read error, 71 when the text is too long. 14 note Four arguments: print the decoder's text of each instruction, one line each (a word it does not know prints ??). 15 note ORACLE (independent, not first-party, never shipped): NVIDIA nvdisasm 13.0.85 -b SM121 -hex, run on these 16 note encoder bytes only. omnem holds the mnemonics it printed for them (evidence/INTEG-280-`20261110`/opmove-nvdisasm.txt). 17 note Rows (op: dst, src1, src2, src3), all unguarded, default control: 18 note 64 ATOMG_MIN_U64_STRONG_SYS R4, R2, R6, UR8 65 I2FP_U32 R4, R2 66 F2I_U32 R4, R2 67 F16_TO_F32 R4, R2 19 note 68 F32_TO_F16 R4, R2 69 DADD R4, R2, R6 70 DMUL R4, R2, R6 71 DFMA R4, R2, R6, R8 20 note 72 DSETP (no destination register) R2, R6 73 MUFU_RCP64H R4, R3 74 MUFU_RSQ64H R4, R3 21 note 75 F64_F32 R4, R2 76 F32_F64 R4, R2 77 F64_S32 R4, R2 78 F64_U32 R4, R2 79 S32_F64 R4, R2 22 text omnem "ATOMG.E.MIN.64.STRONG.SYS|I2FP.F32.U32|F2I.U32.TRUNC.NTZ|HADD2.F32|F2F.F16.F32|DADD|DMUL|DFMA|DSETP.GE.AND|MUFU.RCP64H|MUFU.RSQ64H|F2F.F64.F32|F2F.F32.F64|I2F.F64|I2F.F64.U32|F2I.F64.TRUNC|" 23 24 note the record of row i (op 64 + i) in enc1's operand layout; the caller sets the op number 25 fn om_row i ulong o edit ulong 16 to void 26 for k ulong 16 27 put o k 0 28 end 29 put o 1 4 30 put o 2 2 31 put o 3 6 32 put o 4 255 33 put o 15 1 34 if eq i 0 35 put o 5 8 36 end 37 if eq i 7 38 put o 4 8 39 end 40 if eq i 8 41 put o 15 0 42 end 43 if or eq i 9 eq i 10 44 put o 2 3 45 end 46 end 47 48 note the start of entry i of omnem 49 fn om_tok i ulong to ulong 50 s = ulong 0 51 c = ulong 0 52 while lt c i 53 if eq get omnem s 124 54 c = add c 1 55 end 56 s = add s 1 57 end 58 ret s 59 end 60 61 note is the text t[0..n) up to its first space entry i of omnem? 62 fn om_mnem t view uchar 256 n ulong i ulong to bool 63 s = om_tok i 64 k = ulong 0 65 while lt add s k len omnem 66 c = get omnem add s k 67 if eq c 124 68 if eq k n 69 ret true 70 end 71 ret eq get t k 32 72 end 73 if ge k n 74 ret false 75 end 76 if ne get t k c 77 ret false 78 end 79 k = add k 1 80 end 81 ret false 82 end 83 84 note decode the encoded words w of instruction i (byte address i * 16) into t; sm121_dis's result 85 fn om_dis w view ulong 4 i ulong t edit uchar 256 to ulong 86 lo = or get w 0 shl get w 1 32 87 hi = or get w 2 shl get w 3 32 88 ret sm121_dis lo hi mul i 16 t 89 end 90 91 note rows st..15; st 0 numbers row i as op 64 + i (the move), st 1 as op 63 + i (the stale numbering) 92 fn om_self st ulong to int 93 o = new ulong 16 0 94 w = new ulong 4 0 95 t = new uchar 256 0 96 i = st 97 while lt i 16 98 om_row i edit o 99 put o 0 sub add 64 i st 100 if ne enc1 view o edit w 0 101 ret int add 10 i 102 end 103 r = om_dis view w i edit t 104 if ne and r 327680 0 105 ret int add 10 i 106 end 107 if not om_mnem view t and r 65535 i 108 ret int add 40 i 109 end 110 i = add i 1 111 end 112 ret 0 113 end 114 115 note the decoder's text of every row, one line each; 10 + (op - 64) when the encoder refuses a row 116 fn om_list to int 117 o = new ulong 16 0 118 w = new ulong 4 0 119 t = new uchar 256 0 120 for i ulong 16 121 om_row i edit o 122 put o 0 add 64 i 123 if ne enc1 view o edit w 0 124 ret int add 10 i 125 end 126 r = om_dis view w i edit t 127 n = and r 65535 128 put t n 10 129 if le write 1 t 0 add n 1 0 130 ret 3 131 end 132 end 133 ret 0 134 end 135 136 fn om_bin to int 137 o = new ulong 16 0 138 w = new ulong 4 0 139 code = new uchar 16384 0 140 for i ulong 16 141 om_row i edit o 142 put o 0 add 64 i 143 if ne enc1 view o edit w 0 144 ret int add 10 i 145 end 146 store edit code i view w 147 end 148 off = ulong 0 149 while lt off 256 150 n = write 1 code off sub 256 off 151 if le n 0 152 ret 3 153 end 154 off = add off ulong n 155 end 156 ret 0 157 end 158 159 note is buf[p..) the text t[0..n) followed by " ;"? The caller keeps p + n + 2 within buf's bytes. 160 fn om_at buf view uchar 65536 p ulong t view uchar 256 n ulong to bool 161 for j ulong n 162 if ne get buf add p j get t j 163 ret false 164 end 165 end 166 if ne get buf add p n 32 167 ret false 168 end 169 ret eq get buf add p add n 1 59 170 end 171 172 note the end of the first match of t[0..n) " ;" in buf[p..bn), or bn + 1 when absent 173 fn om_find buf view uchar 65536 bn ulong p ulong t view uchar 256 n ulong to ulong 174 while le add p add n 2 bn 175 if om_at buf p t n 176 ret add p add n 2 177 end 178 p = add p 1 179 end 180 ret add bn 1 181 end 182 183 fn om_check to int 184 buf = new uchar 65536 0 185 bn = ulong 0 186 while lt bn 65536 187 k = read 0 buf bn sub 65536 bn 188 if lt k 0 189 ret 70 190 end 191 if eq k 0 192 break 193 end 194 bn = add bn ulong k 195 end 196 if eq bn 65536 197 ret 71 198 end 199 o = new ulong 16 0 200 w = new ulong 4 0 201 t = new uchar 256 0 202 pos = ulong 0 203 for i ulong 16 204 om_row i edit o 205 put o 0 add 64 i 206 if ne enc1 view o edit w 0 207 ret int add 10 i 208 end 209 r = om_dis view w i edit t 210 if ne and r 327680 0 211 ret int add 10 i 212 end 213 pos = om_find view buf bn pos view t and r 65535 214 if gt pos bn 215 ret 4 216 end 217 end 218 ret 0 219 end 220 221 fn main to int 222 if gt argcnt 5 223 ret 64 224 end 225 if eq argcnt 5 226 ret om_list 227 end 228 if eq argcnt 4 229 ret om_self 1 230 end 231 if eq argcnt 3 232 ret om_check 233 end 234 if eq argcnt 2 235 ret om_bin 236 end 237 ret om_self 0 238 end