interplane.Get Omega
Read in your language

omega-tool-model

First-party Omega tool-use model source, serving harnesses, and verification records

Brought by drakestapleton

branch main Branches Tags History

omega-tool-model / deployment / fast / cache.om

79 lines · 1434 bytes Raw Blame History
1note Reuse host-built launch bytes only for the same slot, kernel, grid, argument words and invalidate flag.
2note The checked variant rebuilds every hit and compares every byte before the unchanged submit/wait.
3fn cachekey id uint gx uint gy uint gz uint to void
4put ckey 0 id
5put ckey 1 gx
6put ckey 2 gy
7put ckey 3 gz
8put ckey 4 get gkna 0
9put ckey 5 get gkinv 0
10for i uint get gkna 0
11put ckey add i 6 get gkarg i
12end
13end
14
15fn cachematch slot ulong to bool
16if eq get clen slot 0
17ret false
18end
19base = mul slot 40
20for i ulong add 6 ulong get gkna 0
21if ne get ckeys add base i get ckey i
22ret false
23end
24end
25ret true
26end
27
28fn cacheverify slot ulong to void
29n = get gbused 0
30if ne n get clen slot
31exit 89
32end
33for i ulong n
34if ne get gbcmd i get cbytes add mul slot 4096 i
35exit 89
36end
37end
38end
39
40fn cachestore slot ulong to void
41n = get gbused 0
42if gt n 4096
43ret
44end
45for i ulong n
46put cbytes add mul slot 4096 i get gbcmd i
47end
48for i ulong add 6 ulong get gkna 0
49put ckeys add mul slot 40 i get ckey i
50end
51put clen slot n
52put cslot 1 1
53end
54
55fn cachebuild id uint gx uint gy uint gz uint to void
56slot = get cslot 0
57put cslot 1 0
58if ge slot 256
59gkbuild id gx gy gz
60ret
61end
62cachekey id gx gy gz
63hit = cachematch slot
64if hit
65put ccnt 0 add get ccnt 0 1
66if eq CACHECHK 1
67gkbuild id gx gy gz
68cacheverify slot
69else
70put gbused 0 get clen slot
71put gkinv 0 0
72end
73put cslot 1 1
74else
75put ccnt 1 add get ccnt 1 1
76gkbuild id gx gy gz
77cachestore slot
78end
79end