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/omega-mv/blob/main/seed/kflow/sm121/tmatmul16.s2 # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / kflow / sm121 / tmatmul16.s2` 261 lines ยท 6587 bytes Raw Blame History 1 ; tmatmul16.s2 -- one 16x16x16 tile matmul D = A x B on the tensor cores of sm_121 (GB10), written by hand 2 ; for asm2 with seed/sm121/sm121.tbl. A and B are f16 row-major 16x16 (A 0x380, B 0x388), D is f32 3 ; row-major 16x16 (D 0x390); one CTA of one warp (32 threads). Two HMMA.16816.F32 (m16n8k16) instructions 4 ; cover the two 8-column halves of D; the accumulator input is RZ (C = 0). 5 ; Fragment layout (PTX ISA 9.4, mma.m16n8k16 .f16, "Matrix Fragments for mma.m16n8k16"): lane l, 6 ; g = l >> 2, t = l & 3. A: a0 = A[g][2t..2t+1], a1 = A[g+8][2t..], a2 = A[g][2t+8..], a3 = A[g+8][2t+8..], 7 ; one 32-bit load each (two f16, low half first) at byte g*32 + t*4 (+256 rows+8, +16 cols+8). 8 ; B for column half j (col = 8j + g): b0 = {B[2t][col], B[2t+1][col]}, b1 = {B[2t+8][col], B[2t+9][col]}; 9 ; the two f16 of a register are in different rows, so each is one LDG.E.U16 at t*64 + g*2 + 16j (+32 for the 10 ; odd row, +256 for rows+8) and the pair is packed with IMAD (hi * 0x10000 + lo). 11 ; D for half j: d0 d1 = D[g][2t+8j], D[g][2t+1+8j]; d2 d3 = D[g+8][...]: byte g*64 + t*8 + 32j (+512). 12 ; Each ";=" line is the instruction text expected from nvdisasm -b SM121 for the next instruction (kflow's 13 ; intent check, written before the first disassembly). Two texts were corrected after it: nvdisasm 13.0 14 ; prints IMAD with a power-of-two number and RZ as IMAD.SHL (predicted IMAD.SHL.U32), and the BRA target 15 ; is the absolute byte address 0x2d0 (left open in the prediction). 16 ; Control words (stall, yield, write-sb, read-sb, wait mask) are MODELED and unmeasured: every 17 ; variable-latency instruction (S2R LDC LDCU LDG) sets scoreboard 0 (0x000e2200) and the first reader after 18 ; them waits on it (wait mask bit 20); fixed-latency ALU steps stall 6 (0x000fcc00). HMMA stalls 15 like 19 ; nvcc 13.0's sm_121 HMMA (0x...fde00) and two NOP stall-15 slots separate the second HMMA from the stores 20 ; (nvcc uses one NOP); the HMMA latency of GB10 is not measured here. No GPU ran this (NOT_RUN). 21 ;= S2R R0, SR_TID.X 22 s2r.0 0 23 s2r.1 24 s2r.2 33 25 ctl 0x000e2200 26 ;= LDCU.64 UR4, c[0x0][0x358] 27 ldcu.64.0 4 28 ldcu.64.1 107 29 ldcu.64.2 30 ctl 0x000e2200 31 ;= LDC.64 R2, c[0x0][0x380] 32 ldc.64.0 2 33 ldc.64.1 224 34 ldc.64.2 35 ctl 0x000e2200 36 ;= LDC.64 R4, c[0x0][0x388] 37 ldc.64.0 4 38 ldc.64.1 226 39 ldc.64.2 40 ctl 0x000e2200 41 ;= LDC.64 R6, c[0x0][0x390] 42 ldc.64.0 6 43 ldc.64.1 228 44 ldc.64.2 45 ctl 0x000e2200 46 ; g = tid >> 2 (R8), t = tid & 3 (R9) 47 ;= SHF.R.U32.HI R8, RZ, 0x2, R0 48 shf.r.hi.0 8 49 n.1 0x00000002 50 shf.r.hi.2 0 51 ctl 0x001fcc00 52 ;= LOP3.LUT R9, R0, 0x3, RZ, 0xc0, !PT 53 lop3.and.i.0 9 0 54 n.1 0x00000003 55 lop3.and.i.2 56 ctl 0x000fcc00 57 ; A byte offset g*32 + t*4 (R10), address R12:R13 58 ;= IMAD.SHL R10, R8, 0x20, RZ 59 imad.i.0 10 8 60 imad.i.1 0x00000020 61 imad.i.2 255 62 ctl 0x000fcc00 63 ;= IMAD R10, R9, 0x4, R10 64 imad.i.0 10 9 65 imad.i.1 0x00000004 66 imad.i.2 10 67 ctl 0x000fcc00 68 ;= IMAD.WIDE.U32 R12, R10, 0x1, R2 69 imad.wide.0 12 10 70 imad.wide.1 0x00000001 71 imad.wide.2 2 72 ctl 0x000fcc00 73 ; B byte offset t*64 + g*2 (R11), address R14:R15 74 ;= IMAD.SHL R11, R9, 0x40, RZ 75 imad.i.0 11 9 76 imad.i.1 0x00000040 77 imad.i.2 255 78 ctl 0x000fcc00 79 ;= IMAD R11, R8, 0x2, R11 80 imad.i.0 11 8 81 imad.i.1 0x00000002 82 imad.i.2 11 83 ctl 0x000fcc00 84 ;= IMAD.WIDE.U32 R14, R11, 0x1, R4 85 imad.wide.0 14 11 86 imad.wide.1 0x00000001 87 imad.wide.2 4 88 ctl 0x000fcc00 89 ; A fragment a0..a3 -> R16..R19 90 ;= LDG.E R16, desc[UR4][R12.64] 91 ldg.0 16 12 92 ldg.w.1 4 0 93 ldg.2 94 ctl 0x000e2200 95 ;= LDG.E R17, desc[UR4][R12.64+0x100] 96 ldg.0 17 12 97 ldg.w.1 4 256 98 ldg.2 99 ctl 0x000e2200 100 ;= LDG.E R18, desc[UR4][R12.64+0x10] 101 ldg.0 18 12 102 ldg.w.1 4 16 103 ldg.2 104 ctl 0x000e2200 105 ;= LDG.E R19, desc[UR4][R12.64+0x110] 106 ldg.0 19 12 107 ldg.w.1 4 272 108 ldg.2 109 ctl 0x000e2200 110 ; B halves for j = 0 (R24..R27) and j = 1 (R28..R31): b0 lo, b0 hi, b1 lo, b1 hi 111 ;= LDG.E.U16 R24, desc[UR4][R14.64] 112 ldg.0 24 14 113 ldg.w.1 4 0 114 ldg.u16.2 115 ctl 0x000e2200 116 ;= LDG.E.U16 R25, desc[UR4][R14.64+0x20] 117 ldg.0 25 14 118 ldg.w.1 4 32 119 ldg.u16.2 120 ctl 0x000e2200 121 ;= LDG.E.U16 R26, desc[UR4][R14.64+0x100] 122 ldg.0 26 14 123 ldg.w.1 4 256 124 ldg.u16.2 125 ctl 0x000e2200 126 ;= LDG.E.U16 R27, desc[UR4][R14.64+0x120] 127 ldg.0 27 14 128 ldg.w.1 4 288 129 ldg.u16.2 130 ctl 0x000e2200 131 ;= LDG.E.U16 R28, desc[UR4][R14.64+0x10] 132 ldg.0 28 14 133 ldg.w.1 4 16 134 ldg.u16.2 135 ctl 0x000e2200 136 ;= LDG.E.U16 R29, desc[UR4][R14.64+0x30] 137 ldg.0 29 14 138 ldg.w.1 4 48 139 ldg.u16.2 140 ctl 0x000e2200 141 ;= LDG.E.U16 R30, desc[UR4][R14.64+0x110] 142 ldg.0 30 14 143 ldg.w.1 4 272 144 ldg.u16.2 145 ctl 0x000e2200 146 ;= LDG.E.U16 R31, desc[UR4][R14.64+0x130] 147 ldg.0 31 14 148 ldg.w.1 4 304 149 ldg.u16.2 150 ctl 0x000e2200 151 ; D byte offset g*64 + t*8 (R10, A's offset is dead), address R38:R39 (overlaps the loads' latency) 152 ;= IMAD.SHL R10, R8, 0x40, RZ 153 imad.i.0 10 8 154 imad.i.1 0x00000040 155 imad.i.2 255 156 ctl 0x000fcc00 157 ;= IMAD R10, R9, 0x8, R10 158 imad.i.0 10 9 159 imad.i.1 0x00000008 160 imad.i.2 10 161 ctl 0x000fcc00 162 ;= IMAD.WIDE.U32 R38, R10, 0x1, R6 163 imad.wide.0 38 10 164 imad.wide.1 0x00000001 165 imad.wide.2 6 166 ctl 0x000fcc00 167 ; pack B registers: R32 R33 (j = 0), R34 R35 (j = 1); the first waits for all loads (scoreboard 0) 168 ;= IMAD R32, R25, 0x10000, R24 169 imad.i.0 32 25 170 imad.i.1 0x00010000 171 imad.i.2 24 172 ctl 0x001fcc00 173 ;= IMAD R33, R27, 0x10000, R26 174 imad.i.0 33 27 175 imad.i.1 0x00010000 176 imad.i.2 26 177 ctl 0x000fcc00 178 ;= IMAD R34, R29, 0x10000, R28 179 imad.i.0 34 29 180 imad.i.1 0x00010000 181 imad.i.2 28 182 ctl 0x000fcc00 183 ;= IMAD R35, R31, 0x10000, R30 184 imad.i.0 35 31 185 imad.i.1 0x00010000 186 imad.i.2 30 187 ctl 0x000fcc00 188 ;= HMMA.16816.F32 R40, R16, R32, RZ 189 hmma.0 40 16 190 r.1 32 191 hmma.f16.2 255 192 ctl 0x000fde00 193 ;= HMMA.16816.F32 R44, R16, R34, RZ 194 hmma.0 44 16 195 r.1 34 196 hmma.f16.2 255 197 ctl 0x000fde00 198 ;= NOP 199 nop.0 200 nop.1 201 nop.2 202 ctl 0x000fde00 203 ;= NOP 204 nop.0 205 nop.1 206 nop.2 207 ctl 0x000fde00 208 ;= STG.E desc[UR4][R38.64], R40 209 stg.0 38 210 stg.1 40 0 211 stg.2 4 212 stg.3 213 ;= STG.E desc[UR4][R38.64+0x4], R41 214 stg.0 38 215 stg.1 41 4 216 stg.2 4 217 stg.3 218 ;= STG.E desc[UR4][R38.64+0x200], R42 219 stg.0 38 220 stg.1 42 512 221 stg.2 4 222 stg.3 223 ;= STG.E desc[UR4][R38.64+0x204], R43 224 stg.0 38 225 stg.1 43 516 226 stg.2 4 227 stg.3 228 ;= STG.E desc[UR4][R38.64+0x20], R44 229 stg.0 38 230 stg.1 44 32 231 stg.2 4 232 stg.3 233 ;= STG.E desc[UR4][R38.64+0x24], R45 234 stg.0 38 235 stg.1 45 36 236 stg.2 4 237 stg.3 238 ;= STG.E desc[UR4][R38.64+0x220], R46 239 stg.0 38 240 stg.1 46 544 241 stg.2 4 242 stg.3 243 ;= STG.E desc[UR4][R38.64+0x224], R47 244 stg.0 38 245 stg.1 47 548 246 stg.2 4 247 stg.3 248 ;= EXIT 249 exit.0 250 z.1 251 exit.2 252 exit.3 253 ;= BRA 0x2d0 254 bra.0 7 63 255 bra.1 -1 256 bra.back.2 257 bra.self.3 258 nop.0 259 nop.1 260 nop.2 261 nop.3