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 / om / graph / layout.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note c model,heads,layers,ctas,H,I,groups,qkv,attn,mix,ab,attmix,mout,routerbytes,segbytes,span,maxheads,pad,copyrow,tokenstride,cap. |
| 3 | fn gl_dec c view ulong 32 p ulong to ulong |
| 4 | if or or eq p 0 eq p 1 or eq p 4 or eq p 8 eq p 14 |
| 5 | ret mul get c 4 4 |
| 6 | end |
| 7 | if eq p 2 |
| 8 | ret mul get c 7 4 |
| 9 | end |
| 10 | if or eq p 3 eq p 16 |
| 11 | ret mul get c 8 4 |
| 12 | end |
| 13 | if eq p 5 |
| 14 | ret mul mul mul get c 6 2 get c 5 4 |
| 15 | end |
| 16 | if eq p 6 |
| 17 | ret mul mul get c 6 get c 5 4 |
| 18 | end |
| 19 | if eq p 7 |
| 20 | ret mul mul get c 6 get c 4 4 |
| 21 | end |
| 22 | if eq p 9 |
| 23 | ret mul mul get c 3 get c 15 4 |
| 24 | end |
| 25 | if or eq p 10 eq p 11 |
| 26 | ret mul get c 15 4 |
| 27 | end |
| 28 | if eq p 12 |
| 29 | ret 16 |
| 30 | end |
| 31 | if eq p 13 |
| 32 | ret mul mul get c 2 get c 4 4 |
| 33 | end |
| 34 | if eq p 15 |
| 35 | ret mul get c 2 32 |
| 36 | end |
| 37 | ret mul get c 4 4 |
| 38 | end |
| 39 | fn gl_dense c view ulong 32 p ulong to ulong |
| 40 | if or or eq p 0 eq p 2 or eq p 8 or eq p 13 eq p 17 |
| 41 | ret mul get c 4 4 |
| 42 | end |
| 43 | if eq p 1 |
| 44 | ret mul get c 10 4 |
| 45 | end |
| 46 | if eq p 3 |
| 47 | ret mul mul get c 3 get c 15 4 |
| 48 | end |
| 49 | if or eq p 4 eq p 5 |
| 50 | ret mul get c 15 4 |
| 51 | end |
| 52 | if eq p 6 |
| 53 | ret 16 |
| 54 | end |
| 55 | if eq p 7 |
| 56 | ret mul mul mul get c 2 2 get c 4 4 |
| 57 | end |
| 58 | if eq p 9 |
| 59 | ret add mul get c 2 64 16 |
| 60 | end |
| 61 | if or eq p 10 eq p 15 |
| 62 | ret mul get c 11 4 |
| 63 | end |
| 64 | if eq p 11 |
| 65 | ret mul get c 18 4 |
| 66 | end |
| 67 | if or eq p 12 eq p 18 |
| 68 | ret mul mul 2 get c 5 4 |
| 69 | end |
| 70 | if eq p 14 |
| 71 | ret mul get c 9 4 |
| 72 | end |
| 73 | if eq p 16 |
| 74 | ret mul get c 12 4 |
| 75 | end |
| 76 | ret mul get c 5 4 |
| 77 | end |
| 78 | fn gl_q36 c view ulong 32 p ulong to ulong |
| 79 | if or or eq p 0 eq p 2 eq p 15 |
| 80 | ret mul mul get c 4 4 get c 1 |
| 81 | end |
| 82 | if eq p 1 |
| 83 | ret mul get c 10 4 |
| 84 | end |
| 85 | if eq p 3 |
| 86 | ret mul mul mul get c 3 get c 15 4 get c 1 |
| 87 | end |
| 88 | if or eq p 4 eq p 5 |
| 89 | ret mul get c 15 4 |
| 90 | end |
| 91 | if eq p 6 |
| 92 | ret mul get c 19 get c 1 |
| 93 | end |
| 94 | if eq p 7 |
| 95 | ret mul mul get c 2 get c 4 4 |
| 96 | end |
| 97 | if eq p 8 |
| 98 | ret mul get c 4 4 |
| 99 | end |
| 100 | if eq p 9 |
| 101 | ret add mul get c 2 64 16 |
| 102 | end |
| 103 | if or eq p 10 eq p 17 |
| 104 | ret mul get c 11 4 |
| 105 | end |
| 106 | if eq p 11 |
| 107 | ret mul get c 18 4 |
| 108 | end |
| 109 | if or eq p 12 eq p 22 |
| 110 | ret mul mul get c 6 get c 4 4 |
| 111 | end |
| 112 | if eq p 13 |
| 113 | ret mul mul get c 2 2 get c 14 |
| 114 | end |
| 115 | if eq p 14 |
| 116 | ret mul add add get c 4 get c 12 get c 5 4 |
| 117 | end |
| 118 | if eq p 16 |
| 119 | ret mul get c 9 4 |
| 120 | end |
| 121 | if eq p 18 |
| 122 | ret mul get c 12 4 |
| 123 | end |
| 124 | if eq p 19 |
| 125 | ret mul get c 4 4 |
| 126 | end |
| 127 | if eq p 20 |
| 128 | ret mul mul mul get c 6 2 get c 5 4 |
| 129 | end |
| 130 | if eq p 21 |
| 131 | ret mul mul get c 6 get c 5 4 |
| 132 | end |
| 133 | if or eq p 23 eq p 35 |
| 134 | ret mul mul get c 16 get c 4 4 |
| 135 | end |
| 136 | if eq p 24 |
| 137 | ret mul mul get c 1 get c 9 4 |
| 138 | end |
| 139 | if eq p 25 |
| 140 | ret mul mul get c 1 get c 10 4 |
| 141 | end |
| 142 | if eq p 26 |
| 143 | ret mul mul get c 1 get c 11 4 |
| 144 | end |
| 145 | if eq p 27 |
| 146 | ret mul mul get c 1 get c 12 4 |
| 147 | end |
| 148 | if eq p 28 |
| 149 | ret mul mul get c 16 get c 12 4 |
| 150 | end |
| 151 | if eq p 29 |
| 152 | ret mul mul get c 1 get c 4 4 |
| 153 | end |
| 154 | if eq p 30 |
| 155 | ret mul get c 1 graph_align get c 13 |
| 156 | end |
| 157 | if or eq p 31 eq p 32 |
| 158 | ret mul mul get c 1 get c 6 get c 14 |
| 159 | end |
| 160 | if or eq p 33 eq p 34 |
| 161 | ret mul add mul get c 1 get c 6 get c 17 4 |
| 162 | end |
| 163 | if eq p 36 |
| 164 | ret mul mul mul mul get c 1 get c 6 2 get c 5 4 |
| 165 | end |
| 166 | if or eq p 37 eq p 38 |
| 167 | ret mul mul mul get c 1 get c 6 get c 5 4 |
| 168 | end |
| 169 | ret mul mul mul get c 1 get c 6 get c 4 4 |
| 170 | end |
| 171 | fn gl_pf c view ulong 32 p ulong to ulong |
| 172 | if or eq p 0 or eq p 10 eq p 17 |
| 173 | ret mul mul get c 20 get c 4 4 |
| 174 | end |
| 175 | if eq p 1 |
| 176 | ret mul get c 20 get c 13 |
| 177 | end |
| 178 | if or eq p 2 eq p 3 |
| 179 | ret mul 256 get c 14 |
| 180 | end |
| 181 | if or eq p 4 eq p 5 |
| 182 | ret get c 14 |
| 183 | end |
| 184 | if or eq p 6 eq p 7 |
| 185 | ret mul add mul get c 20 get c 6 get c 17 4 |
| 186 | end |
| 187 | if or eq p 8 eq p 9 |
| 188 | ret mul add get c 20 get c 17 4 |
| 189 | end |
| 190 | if or eq p 11 eq p 18 |
| 191 | ret mul mul add get c 20 get c 17 get c 4 4 |
| 192 | end |
| 193 | if eq p 12 |
| 194 | ret mul mul get c 20 get c 9 4 |
| 195 | end |
| 196 | if eq p 13 |
| 197 | ret mul mul get c 20 get c 10 4 |
| 198 | end |
| 199 | if eq p 14 |
| 200 | ret mul mul get c 20 get c 11 4 |
| 201 | end |
| 202 | if eq p 15 |
| 203 | ret mul mul get c 20 get c 12 4 |
| 204 | end |
| 205 | if eq p 16 |
| 206 | ret mul mul add get c 20 get c 17 get c 12 4 |
| 207 | end |
| 208 | if eq p 19 |
| 209 | ret mul mul mul mul get c 20 get c 6 2 get c 5 4 |
| 210 | end |
| 211 | if eq p 20 |
| 212 | ret mul mul mul get c 20 get c 6 get c 5 4 |
| 213 | end |
| 214 | if eq p 21 |
| 215 | ret mul mul add mul get c 20 get c 6 get c 17 get c 5 4 |
| 216 | end |
| 217 | ret mul mul mul get c 20 get c 6 get c 4 4 |
| 218 | end |
| 219 | fn mg_layout c view ulong 32 d edit ulong 64 to ulong |
| 220 | for i ulong 64 |
| 221 | put d i 0 |
| 222 | end |
| 223 | n = ulong 18 |
| 224 | if eq get c 0 1 |
| 225 | n = 40 |
| 226 | end |
| 227 | if eq get c 0 2 |
| 228 | n = 20 |
| 229 | end |
| 230 | if eq get c 0 3 |
| 231 | n = 23 |
| 232 | end |
| 233 | o = ulong 0 |
| 234 | for p ulong n |
| 235 | if eq get c 0 1 |
| 236 | if eq p 15 |
| 237 | put d 60 o |
| 238 | end |
| 239 | end |
| 240 | if eq get c 0 2 |
| 241 | if eq p 13 |
| 242 | put d 60 o |
| 243 | end |
| 244 | end |
| 245 | if eq get c 0 3 |
| 246 | if eq p 10 |
| 247 | put d 61 o |
| 248 | o = 0 |
| 249 | end |
| 250 | end |
| 251 | put d p o |
| 252 | b = gl_dec c p |
| 253 | if eq get c 0 1 |
| 254 | b = gl_q36 c p |
| 255 | end |
| 256 | if eq get c 0 2 |
| 257 | b = gl_dense c p |
| 258 | end |
| 259 | if eq get c 0 3 |
| 260 | b = gl_pf c p |
| 261 | end |
| 262 | o = graph_align add o b |
| 263 | end |
| 264 | if eq get c 0 3 |
| 265 | put d 63 o |
| 266 | else |
| 267 | put d 61 o |
| 268 | end |
| 269 | put d 62 graph_align get c 13 |
| 270 | ret 1 |
| 271 | end |