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
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note The k-part sum of one tile row (or, without block scales, of adjacent rows packed as one) of the general GEMM |
| 3 | note (CUDApp#144, src/omega_gpu_gemm_ex.c l.421-423): |
| 4 | note acc[j] += (f64 P[j]) * f, f = (f64 sa) * (f64 sb[kb][(n0 + j) / bn]) under block scales; without them f is 1.0 |
| 5 | note and the product is (f64 P[j]) itself (x * 1.0 = x exactly, a NaN x already quiet from the widening), so it is skipped. |
| 6 | note q: 0 nc (<= 4096), 1 block scales, 2 n0, 3 bn; s holds binary32 values: s[0] the row's sa, s[1 + c] the sb of |
| 7 | note column block n0 / bn + c (the C shell copies that window). pv: the nc P values of the row. |
| 8 | note The factor is found once per column block, not per element: r counts the columns of the block so far. |
| 9 | |
| 10 | note the block factor of column j: sa times the sb of column block (n0 + j) / bn |
| 11 | fn gx_bf q view ulong 8 s view f32 16384 j ulong to f64 |
| 12 | ix = div add get q 2 j get q 3 |
| 13 | ix = sub ix div get q 2 get q 3 |
| 14 | f = f64 get s add ix 1 |
| 15 | z = ulong 0 |
| 16 | ret mul f64 get s z f |
| 17 | end |
| 18 | |
| 19 | fn gemm_ex_acc q view ulong 8 pv view f32 16384 s view f32 16384 acc edit ulong 4096 to ulong |
| 20 | if eq get q 1 0 |
| 21 | for j ulong get q 0 |
| 22 | put acc j bitcast ulong add bitcast f64 get acc j f64 get pv j |
| 23 | end |
| 24 | ret get q 0 |
| 25 | end |
| 26 | r = rem get q 2 get q 3 |
| 27 | f = gx_bf view q view s ulong 0 |
| 28 | for j ulong get q 0 |
| 29 | x = mul f64 get pv j f |
| 30 | put acc j bitcast ulong add bitcast f64 get acc j x |
| 31 | r = add r 1 |
| 32 | if eq r get q 3 |
| 33 | r = ulong 0 |
| 34 | f = gx_bf view q view s add j 1 |
| 35 | end |
| 36 | end |
| 37 | ret get q 0 |
| 38 | end |