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 / graph / residue.om

150 lines · 2279 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Scalar graph metadata and admission; fixed descriptors avoid object ABI coupling.
3fn grshape c view ulong 16 d edit ulong 16 to ulong
4hd = get c 0
5iw = get c 1
6qh = get c 2
7kv = get c 3
8gh = get c 4
9if eq hd 0
10hd = 5120
11end
12if eq iw 0
13iw = 17408
14end
15if eq qh 0
16qh = 24
17end
18if eq kv 0
19kv = 4
20end
21if eq gh 0
22gh = 48
23end
24if or ne rem hd 1024 0 gt hd 5120
25ret 0
26end
27if or eq iw 0 or ne rem iw 256 0 gt iw 17408
28ret 0
29end
30if or gt qh 24 ne rem qh kv 0
31ret 0
32end
33if gt div qh kv 8
34ret 0
35end
36if and ne gh 32 ne gh 48
37ret 0
38end
39if ne mul qh 256 mul gh 128
40ret 0
41end
42put d 0 hd
43put d 1 iw
44put d 2 qh
45put d 3 kv
46put d 4 gh
47put d 5 mul add 32 gh 128
48put d 6 add get d 5 mul gh 128
49put d 7 mul 2 gh
50put d 8 mul add qh kv 512
51put d 9 add mul qh 256 mul kv 512
52put d 10 mul qh 256
53ret 1
54end
55fn grmeta mode ulong c view ulong 16 d edit ulong 16 to ulong
56if eq mode 0
57ret grshape c d
58end
59if eq mode 1
60note layers,maxlayers,vocab,span,heads,maxheads,mask,usesmask
61if or eq get c 0 0 gt get c 0 get c 1
62ret 0
63end
64if or eq get c 2 0 gt get c 2 mul get c 3 get c 3
65ret 0
66end
67if or eq get c 4 0 gt get c 4 get c 5
68ret 0
69end
70if and ne get c 7 0 lt get c 0 64
71if ne shr get c 6 get c 0 0
72ret 0
73end
74end
75put d 0 div sub add get c 2 get c 3 1 get c 3
76ret 1
77end
78if eq mode 2
79note mask,layer,attention count,gdn count -> bit,index,updated counts
80bit = and shr get c 0 get c 1 1
81na = get c 2
82ng = get c 3
83idx = ng
84if ne bit 0
85idx = na
86na = add na 1
87else
88ng = add ng 1
89end
90put d 0 bit
91put d 1 idx
92put d 2 na
93put d 3 ng
94ret 1
95end
96if eq mode 3
97note normalize barrier: dependency chains refuse NONE
98b = get c 0
99if or gt b 4 eq b 1
100ret 0
101end
102ret b
103end
104if eq mode 4
105note Prefill device allocation round-up preserving size_t arithmetic.
106ret and add get c 0 4095 18446744073709547520
107end
108if eq mode 5
109if ne get c 0 get c 3
110ret 0
111end
112if ne get c 1 get c 4
113ret 0
114end
115if ne get c 2 get c 5
116ret 0
117end
118ret 1
119end
120if eq mode 6
121skip = ulong 0
122if ne get c 0 0
123skip = 1
124end
125if gt get c 0 get c 2
126ret 0
127end
128if gt get c 1 skip
129if gt sub get c 1 skip sub get c 2 get c 0
130ret 0
131end
132end
133put d 0 skip
134ret 1
135end
136if eq mode 7
137limit = get c 1
138if eq limit 0
139limit = sub get c 2 2
140end
141if gt limit get c 3
142ret 0
143end
144if gt get c 0 limit
145ret 0
146end
147ret get c 4
148end
149ret 0
150end