interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / om / gemmex / acc.om

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