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 / api / apish_blk.om

46 lines · 1138 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note One 128-wide FP8 e4m3 block product. w is the weight row, x is f32 bits, sc is bf16 bits.
3note The sum is left-associative f64, one rounding per mul and add. Returns the f64 bits.
4
5fn refb b uint to f32
6s = and b 128
7e = and shr b 3 15
8m = and b 7
9if and eq e 15 eq m 7
10ret bitcast f32 uint 2143289344
11end
12if eq e 0
13z = mul f32 m bitcast f32 shl sub uint 127 9 23
14if ne s 0
15ret bitcast f32 xor bitcast uint z shl uint 1 31
16end
17ret z
18end
19base = add bitcast f32 shl uint 127 23 div f32 m 8.0f32
20val = mul base bitcast f32 shl add uint 120 e 23
21if ne s 0
22ret bitcast f32 xor bitcast uint val shl uint 1 31
23end
24ret val
25end
26
27fn u32le x view uchar 512 i ulong to uint
28o = mul i 4
29b0 = uint get x o
30b1 = uint get x add o 1
31b2 = uint get x add o 2
32b3 = uint get x add o 3
33ret or or or b0 shl b1 8 shl b2 16 shl b3 24
34end
35
36fn apishb w view uchar 128 x view uchar 512 sc uint to ulong
37sf = bitcast f32 shl and sc 65535 16
38sd = f64 sf
39acc = 0.0f64
40for i ulong 128
41rd = f64 refb uint get w i
42xd = f64 bitcast f32 u32le x i
43acc = add acc mul mul rd xd sd
44end
45ret bitcast ulong acc
46end