interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / native / fsum.om

18 lines · 541 bytes Raw Blame History
1note fsum: d[i] = a[i] + f16 h[i] in f32 for 4 lanes (h binary16 bits, converted here; zero and normal
2note inputs), and returns the f32 bit pattern of d[0] + d[3]: an f32 view, a ushort view and an f32 edit array.
3fn h2b h ushort to uint
4v = uint h
5s = shl and shr v 15 1 31
6e = and shr v 10 31
7m = and v 1023
8if eq e 0
9ret s
10end
11ret or or s shl add e 112 23 shl m 13
12end
13fn fsum a view f32 4 h view ushort 4 d edit f32 4 to ulong
14for i ulong 4
15put d i add get a i bitcast f32 h2b get h i
16end
17ret ulong bitcast uint add get d 0 get d 3
18end