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 / tests / arboris / sparse-packet.om

214 lines · 4817 bytes Raw Blame History
1note Reconstruct the Arboris command packet with an owned anonymous marker.
2note No device descriptors exist. Inspect both constant-bank DMA payloads.
3fn packet_word i ulong to ulong
4 v = ulong 0
5 for j ulong 4
6 v = or v shl ulong get gbcmd add mul i 4 j mul j 8
7 end
8 ret v
9end
10fn packet_route to bool
11 m = new ulong 16 0
12 put m 0 arboris_sparse_magic
13 put m 1 2
14 put m 2 1
15 put m 3 1
16 put m 4 1
17 costs = new ulong 38 0
18 graph = new uint 7 0
19 scores = new uint 8 0
20 put graph 0 ar_topo_v1
21 put graph 1 2
22 put graph 2 1
23 put graph 5 1
24 weights = new uint 1 ar_one
25 put scores 0 1
26 put scores 2 0x3f000000
27 put scores 4 ar_one
28 put costs 36 0x3f000000
29 if or ne ar_prepare_sparse m costs 0 ne ar_execute_sparse graph weights scores 0
30 ret false
31 end
32 if or ne get scores 1 1 ne get scores 7 0x3f000000
33 ret false
34 end
35 put m 6 1
36 if or ne ar_prepare_sparse_wave m costs 2 2 0 ne ar_execute_sparse graph weights scores 0
37 ret false
38 end
39 if or ne get scores 1 1 ne get scores 7 0x3f000000
40 ret false
41 end
42 put m 6 0
43 put costs 0 1234
44 put costs 4 2
45 put costs 5 1
46 put costs 6 1
47 for i ulong 8
48 put costs add 8 i get costs i
49 put costs add 20 i get costs i
50 end
51 put costs 28 1
52 put costs 17 3
53 put costs 29 3
54 put costs 18 100
55 put costs 30 20
56 put costs 19 80
57 put costs 31 40
58 if or ne ar_prepare_sparse m costs 1 ne ar_execute_sparse graph weights scores 4
59 ret false
60 end
61 put m 1 3
62 ret and eq ar_prepare_sparse m costs 0 eq ar_execute_sparse graph weights scores 3
63end
64fn packet_contender to bool
65 pid = fork
66 if eq pid 0
67 inherited = fclose int get ar_compute_fd 0
68 put ar_compute_kind 0 0
69 if ar_claim_compute 1
70 exit 1
71 end
72 exit 0
73 end
74 status = new uchar 4 0
75 if le pid 0
76 ret false
77 end
78 if ne waitpid int pid status 0 4 0 pid
79 ret false
80 end
81 ret and eq get status 0 0 eq get status 1 0
82end
83
84fn packet_retry_blocked marker long to bool
85 if not ar_claim_compute 2
86 ret false
87 end
88 put nvstate 0 1
89 put gbmem 3 marker
90 put ar_maps 5 marker
91 wrote = mapset marker 32 4 0x2345
92 wrote = mapset marker 56 8 0x789
93 put nvput 0 2
94 put nvret 0 1
95 put nvfault 0 1
96 ok = and not ar_step_send not ar_step_close
97 put nvret 0 2
98 ok = and ok and not ar_step_send not ar_step_close
99 ok = and ok packet_contender
100 put nvstate 0 0
101 ok = and ok ar_step_close
102 ok = and ok ar_claim_compute 1
103 ar_drop_compute
104 put nvfault 0 0
105 put nvput 0 0
106 put nvret 0 0
107 put gbmem 3 0
108 put ar_maps 5 0
109 ret and ok and eq mapget marker 32 4 0x2345 eq mapget marker 56 8 0x789
110end
111
112fn main to int
113 if not packet_route
114 ret 23
115 end
116 shape = new ulong 7 0
117 slots = new ulong 20 0
118 for i ulong 10
119 put slots mul i 2 add 0x500000000 mul i 65536
120 put slots add mul i 2 1 65536
121 end
122 put shape 0 129
123 put shape 1 129
124 put shape 2 64
125 put shape 3 2
126 put shape 5 0x3f000000
127 marker = mapnew neg int 1 0 4096 3 34
128 if le marker 0
129 ret 1
130 end
131 put gbmem 3 marker
132 if not ar_step_pack shape slots 1
133 ret 2
134 end
135 note gbsetup 18 words, DMA prefix 9 words, then 224 driver words.
136 if ne packet_word 22 896
137 ret 3
138 end
139 if or ne packet_word 243 128 ne packet_word 248 2
140 ret 4
141 end
142 if ne packet_word 255 48
143 ret 5
144 end
145 if or ne packet_word 260 0x6000c ne packet_word 261 5
146 ret 6
147 end
148 if ne packet_word 270 0x3f000000
149 ret 7
150 end
151 if or ne get gbq1 39 2 ne get gbq1 40 2
152 ret 8
153 end
154 meta = new ulong 16 0
155 put meta 1 5
156 put meta 2 9
157 put meta 3 9
158 put meta 4 8
159 put meta 6 1
160 put meta 13 512
161 if not ar_gv_packet meta slots 4
162 ret 10
163 end
164 if or ne get gbq1 39 2 ne get gbq1 40 1
165 ret 11
166 end
167 if or ne and shr get gbq1 35 8 511 96 ne and get gbq1 36 2047 4
168 ret 12
169 end
170 if or ne packet_word 255 80 ne packet_word 260 0x60000
171 ret 13
172 end
173 if or ne packet_word 276 0x90000 ne packet_word 278 0x80000
174 ret 14
175 end
176 put meta 4 264
177 if not ar_gv_packet meta slots 4
178 ret 21
179 end
180 if or ne get gbq1 40 2 ne packet_word 248 2
181 ret 22
182 end
183 seq = ulong 0x10000000a
184 put gbused 0 0
185 ar_release_receipt 0x500006000 seq 0x50000a000
186 if or ne packet_word 1 5 or ne packet_word 2 0x6030 ne packet_word 4 16
187 ret 15
188 end
189 if or ne packet_word 9 10 or ne packet_word 10 1 or ne packet_word 11 6 ne packet_word 12 0
190 ret 16
191 end
192 if or ne packet_word 17 0x80000000 or ne packet_word 19 0xa020 ne packet_word 21 ulong ar_completion_word seq
193 ret 17
194 end
195 r = mapset marker 48 8 seq
196 r = mapset marker 56 8 6
197 if not ar_device_receipt marker seq
198 ret 18
199 end
200 if ar_device_receipt marker sub seq 1
201 ret 19
202 end
203 r = mapset marker 0 8 1
204 if ar_device_receipt marker seq
205 ret 20
206 end
207 if not packet_retry_blocked marker
208 ret 23
209 end
210 if ne mapdrop marker 0
211 ret 9
212 end
213 ret 0
214end