interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / gpu / nvidia / om / graph / hello-plan.om

147 lines · 2549 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note mode 0 chunk plan, mode 1 scoreboard control. Parameters are source constants.
3fn hplan mode ulong c view ulong 16 d edit ulong 16 to ulong
4if eq mode 0
5base = get c 0
6n = sub get c 1 base
7if gt n get c 2
8n = get c 2
9end
10if and ne get c 4 0 eq add base n get c 1
11if eq get c 4 1
12n = add n 1
13else
14n = sub n 1
15end
16end
17put d 0 mul base 4
18put d 1 n
19put d 2 div sub add n get c 3 1 get c 3
20put d 3 div sub add get c 1 get c 2 1 get c 2
21put d 4 mul n 8
22put d 5 mul n 4
23ret 1
24end
25if eq mode 1
26kind = get c 0
27pend = get c 1
28stall = ulong 6
29wb = ulong 7
30rb = ulong 7
31np = ulong 0
32if eq kind 1
33stall = 14
34end
35if eq kind 2
36stall = 4
37wb = 0
38np = 1
39end
40if eq kind 3
41stall = 4
42wb = 2
43np = 4
44end
45if eq kind 4
46stall = 4
47rb = 1
48np = 2
49end
50if or eq kind 5 eq kind 6
51stall = 5
52end
53if eq kind 6
54np = pend
55end
56v = or shl stall 9 shl wb 14
57v = or v shl rb 17
58v = or v shl pend 20
59if and ge kind 2 le kind 4
60v = or v 8192
61end
62put d 0 v
63put d 1 np
64ret 1
65end
66if eq mode 2
67total = add get c 1 get c 2
68floor = f64 0
69if eq get c 0 121
70floor = div f64 total mul 195.1f64 1000.0f64
71end
72measured = bitcast f64 get c 3
73pct = f64 0
74if gt measured 0.0f64
75pct = div mul 100.0f64 floor measured
76end
77put d 0 total
78put d 1 bitcast ulong floor
79put d 2 bitcast ulong pct
80ret 1
81end
82if eq mode 3
83elem = sub add get c 0 get c 1 1
84rel = sub elem get c 0
85put d 0 elem
86put d 1 div rel get c 2
87put d 2 rem rel get c 2
88put d 3 add get c 3 mul elem 4
89ret 1
90end
91if eq mode 4
92near = ulong 0
93dist = ulong 18446744073709551615
94past = ulong 1
95for k ulong 3
96lo = get c mul k 2
97hi = get c add mul k 2 1
98dd = ulong 0
99pst = ulong 1
100if ge get c 6 hi
101dd = sub get c 6 hi
102else
103if le add get c 6 get c 7 lo
104dd = sub lo add get c 6 get c 7
105pst = 0
106end
107end
108if lt dd dist
109dist = dd
110near = k
111past = pst
112end
113end
114put d 0 near
115put d 1 dist
116put d 2 past
117pos = mul near 2
118low = get c pos
119high = get c add pos 1
120put d 3 div sub high add low get c 8 4
121ret 1
122end
123note mode 5 D8 overhead: c0..c2 resident KiB before open, after open, with buffers; c3 own buffer bytes; c4 driver allocation bytes.
124note d0 own KiB rounded up, d1 d2 open cost magnitude and sign (1 negative), d3 d4 resident beyond own buffers, d5 driver KiB.
125if eq mode 5
126ownk = div add get c 3 1023 1024
127put d 0 ownk
128if ge get c 1 get c 0
129put d 1 sub get c 1 get c 0
130put d 2 0
131else
132put d 1 sub get c 0 get c 1
133put d 2 1
134end
135kb = add get c 0 ownk
136if ge get c 2 kb
137put d 3 sub get c 2 kb
138put d 4 0
139else
140put d 3 sub kb get c 2
141put d 4 1
142end
143put d 5 div add get c 4 1023 1024
144ret 1
145end
146ret 0
147end