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 / attn_oracle.om

67 lines · 1650 bytes Raw Blame History
1om2
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3fn ar_abs u ulong to ulong
4x = bitcast f64 u
5if lt x 0.0
6ret bitcast ulong neg x
7end
8ret u
9end
10note q = row, column, k, n; preserve double operation order and float maxima.
11fn ar_term a view ushort * b view ushort * q view ulong 6 t ulong to ulong
12x = f64 bitcast f32 shl uint get a add mul get q 0 get q 2 t 16
13y = f64 bitcast f32 shl uint get b add mul t get q 3 get q 1 16
14ret bitcast ulong mul x y
15end
16fn ar_seg a view ushort * b view ushort * q view ulong 6 d edit ulong 2 to ulong
17for z ulong get q 5
18p = bitcast f64 ar_term a b q add get q 4 z
19put d 0 bitcast ulong add bitcast f64 get d 0 p
20put d 1 bitcast ulong add bitcast f64 get d 1 bitcast f64 ar_abs bitcast ulong p
21end
22ret 0
23end
24fn ar_dot a view ushort * b view ushort * q view ulong 4 d edit ulong 2 to ulong
25qq = new ulong 6 0
26for i ulong 4
27put qq i get q i
28end
29put d 0 bitcast ulong f64 0.0
30put d 1 bitcast ulong f64 0.0
31for bb ulong add div get q 2 1000000 1
32put qq 4 mul bb 1000000
33cnt = sub get q 2 get qq 4
34if gt cnt 1000000
35cnt = ulong 1000000
36end
37put qq 5 cnt
38rc = ar_seg a b qq d
39if ne rc 0
40ret rc
41end
42end
43ret 0
44end
45fn ar_err d view ulong 2 c uint z edit ulong 4 to ulong
46diff = bitcast f64 ar_abs bitcast ulong sub bitcast f64 get d 0 f64 bitcast f32 c
47scale = bitcast f64 get d 1
48if not gt scale 0.000001
49scale = f64 0.000001
50end
51rel = div diff scale
52if gt f32 diff bitcast f32 uint get z 0
53put z 0 ulong bitcast uint f32 diff
54end
55if gt f32 rel bitcast f32 uint get z 1
56put z 1 ulong bitcast uint f32 rel
57end
58if gt rel 0.00001
59put z 2 add get z 2 1
60end
61if eq get z 2 0
62put z 3 1
63else
64put z 3 0
65end
66ret 0
67end