Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/arboris/spread_v2_host.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / arboris / spread_v2_host.om` 482 lines ยท 10812 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note Host verification suite for Arboris 5-region ontology, planner, CPU oracle, and QMD/emitter. 3 note Compose after: om/arboris_ontology.om, om/arboris_spread_plan.om, om/arboris_spread_cpu.om, 4 note om/encoder/bw_enc_sm121.om, om/gpu/bw_qmd.om, om/bw_arboris_spread_emit.om. 5 6 fn test_ontology_and_csr to ulong 7 note Build valid infrastructure-0.1.0 graph: 8 note V=4: node 0 = Pod (kind 7, props=name|phase=5), node 1 = Node (kind 6, props=name|schedulable=3), 9 note node 2 = Service (kind 2, props=name=1), node 3 = Cluster (kind 5, props=name=1) 10 note E=3: (0 -> 1, scheduled_on=1, w=0.5), (2 -> 0, selects=3, w=0.8), (1 -> 3, part_of=0, w=0.75) 11 rec = new uint 30 0 12 put rec 0 0x41523031 13 put rec 1 2 14 put rec 2 4 15 put rec 3 3 16 put rec 4 5 17 put rec 5 0x3f400000 18 note Nodes 19 put rec 6 7 20 put rec 7 5 21 put rec 8 1 22 put rec 9 6 23 put rec 10 3 24 put rec 11 1 25 put rec 12 2 26 put rec 13 1 27 put rec 14 1 28 put rec 15 5 29 put rec 16 1 30 put rec 17 0 31 note Edges (4 words each starting at 18) 32 put rec 18 0 33 put rec 19 1 34 put rec 20 1 35 put rec 21 0x3f000000 36 put rec 22 2 37 put rec 23 3 38 put rec 24 0 39 put rec 25 0x3f4ccccd 40 put rec 26 1 41 put rec 27 0 42 put rec 28 3 43 put rec 29 0x3f400000 44 45 hdr = new ulong 16 0 46 offs = new ulong 5 0 47 msz = new ulong 5 0 48 put hdr 0 0x4152425300000001 49 put hdr 1 4 50 put hdr 2 3 51 put hdr 3 1 52 put hdr 5 5 53 put hdr 6 0x3f400000 54 put hdr 7 0 55 if ne arboris_spread_plan hdr 0x10000000 4096 offs msz 0 56 ret 9 57 end 58 csr = new uint 96 0 59 if ne arboris_compile_in_csr rec hdr csr 0 60 ret 10 61 end 62 note Incoming counts: v0 has 1 (from 2), v1 has 1 (from 0), v2 has 0, v3 has 1 (from 1) 63 if ne get csr 0 0 64 ret 11 65 end 66 if ne get csr 1 1 67 ret 11 68 end 69 if ne get csr 2 2 70 ret 11 71 end 72 if ne get csr 3 2 73 ret 11 74 end 75 if ne get csr 4 3 76 ret 11 77 end 78 if ne get csr 32 2 79 ret 12 80 end 81 if ne get csr 33 0 82 ret 12 83 end 84 if ne get csr 34 1 85 ret 12 86 end 87 if ne arboris_validate_in_csr hdr csr 0 88 ret 13 89 end 90 91 note Negative 1: exclusive state (Running|Stopped = 3) 92 put rec 8 3 93 if eq arboris_compile_in_csr rec hdr csr 0 94 ret 14 95 end 96 put rec 8 1 97 98 note Negative 2: missing required property (Pod missing phase) 99 put rec 7 1 100 if eq arboris_compile_in_csr rec hdr csr 0 101 ret 15 102 end 103 put rec 7 5 104 105 note Negative 3: illegal ontology edge (Cluster -> Pod via scheduled_on) 106 put rec 18 3 107 if eq arboris_compile_in_csr rec hdr csr 0 108 ret 16 109 end 110 put rec 18 0 111 112 note Negative 4: negative edge weight (-0.5 = 0xbf000000) 113 put rec 21 0xbf000000 114 if eq arboris_compile_in_csr rec hdr csr 0 115 ret 17 116 end 117 note Negative 5: NaN edge weight (0x7fc00000) and +Inf (0x7f800000) 118 put rec 21 0x7fc00000 119 if eq arboris_compile_in_csr rec hdr csr 0 120 ret 18 121 end 122 put rec 21 0x7f800000 123 if eq arboris_compile_in_csr rec hdr csr 0 124 ret 19 125 end 126 put rec 21 0x3f000000 127 128 note Negative 6: out-of-range in_src >= V 129 put csr 32 4 130 if eq arboris_validate_in_csr hdr csr 0 131 ret 20 132 end 133 put csr 32 2 134 ret 0 135 end 136 137 fn test_arena_planner to ulong 138 hdr = new ulong 16 0 139 offs = new ulong 5 0 140 msz = new ulong 5 0 141 budget = ulong 0x40000000 142 143 note Mode 0: V=100, E=250, B=1, H=8, gamma=0.5 144 put hdr 0 0x4152425300000001 145 put hdr 1 100 146 put hdr 2 250 147 put hdr 3 1 148 put hdr 5 8 149 put hdr 6 0x3f000000 150 put hdr 7 0 151 put hdr 8 0 152 put hdr 9 42 153 put hdr 10 7 154 put hdr 15 0 155 if ne arboris_spread_plan hdr budget 4096 offs msz 0 156 ret 30 157 end 158 if or ne get hdr 4 1 ne get offs 0 0 159 ret 31 160 end 161 note Verify 4 KiB guard page between every adjacent slab 162 for i ulong 4 163 gap = sub get offs add i 1 add get offs i get msz i 164 if ne gap 4096 165 ret 32 166 end 167 end 168 if ne arboris_spread_verify_header hdr budget 4096 0 169 ret 33 170 end 171 172 note Mode 1: B=37 -> batch_stride = 64 173 put hdr 3 37 174 put hdr 4 0 175 put hdr 7 1 176 if ne arboris_spread_plan hdr budget 4096 offs msz 0 177 ret 34 178 end 179 if ne get hdr 4 64 180 ret 35 181 end 182 183 note Negative 1: non-zero reserved_zero 184 put hdr 15 1 185 if eq arboris_spread_plan hdr budget 4096 offs msz 0 186 ret 36 187 end 188 put hdr 15 0 189 190 note Negative 2: 64-bit overflow / budget exceeded 191 put hdr 1 0x1fffffff 192 put hdr 3 65535 193 put hdr 4 0 194 if eq arboris_spread_plan hdr budget 4096 offs msz 0 195 ret 37 196 end 197 198 note Negative 3: high 32b of decay non-zero 199 put hdr 1 100 200 put hdr 3 1 201 put hdr 4 0 202 put hdr 7 0 203 put hdr 6 0x100000000 204 if eq arboris_spread_plan hdr budget 4096 offs msz 0 205 ret 38 206 end 207 note Negative 4: NaN decay 208 put hdr 6 0x7fc00000 209 if eq arboris_spread_plan hdr budget 4096 offs msz 0 210 ret 39 211 end 212 ret 0 213 end 214 215 fn test_cpu_oracle to ulong 216 note Graph: V=5 (0->1->2->0 cycle, 3 isolated, 2->4), E=4 217 note Incoming: v0<-{2:0.5}, v1<-{0:0.5}, v2<-{1:0.5}, v3<-{}, v4<-{2:1.0} 218 note Slab 1 CSR layout: row_off at word 0, in_src at word 32 (byte 128), in_weight at word 64 (byte 256) 219 csr = new uint 96 0 220 put csr 0 0 221 put csr 1 1 222 put csr 2 2 223 put csr 3 3 224 put csr 4 3 225 put csr 5 4 226 put csr 32 2 227 put csr 33 0 228 put csr 34 1 229 put csr 35 2 230 put csr 64 0x3f000000 231 put csr 65 0x3f000000 232 put csr 66 0x3f000000 233 put csr 67 0x3f800000 234 235 hdr = new ulong 16 0 236 offs = new ulong 5 0 237 msz = new ulong 5 0 238 put hdr 0 0x4152425300000001 239 put hdr 1 5 240 put hdr 2 4 241 put hdr 3 1 242 put hdr 5 10 243 put hdr 6 0x3f000000 244 put hdr 7 0 245 put hdr 8 0 246 put hdr 15 0 247 if ne arboris_spread_plan hdr 0x10000000 4096 offs msz 0 248 ret 40 249 end 250 251 state = new uint 10 0 252 receipt = new ulong 8 0 253 note Seed node 0 = 1.0 in bank 0 (ping = state[0..4]) 254 put state 0 0x3f800000 255 256 if ne arboris_spread_cpu_run hdr csr state receipt 0 257 ret 40 258 end 259 note Hop 1: v1 = 0.25 (0x3e800000), changed=1 260 note Hop 2: v2 = 0.0625 (0x3d800000), changed=1 261 note Hop 3: v4 = 0.03125 (0x3d000000), v0 stays 1.0, changed=1 262 note Hop 4: changed=0 -> early stop at hop_completed == 4! 263 if ne get receipt 2 4 264 ret 41 265 end 266 if ne get receipt 0 0 267 ret 42 268 end 269 note Active bank after 4 hops is 0 (state[0..4]): v0=1.0, v1=0.25, v2=0.0625, v3=0.0, v4=0.03125 270 if or ne get state 0 0x3f800000 ne get state 1 0x3e800000 271 ret 43 272 end 273 if or ne get state 2 0x3d800000 or ne get state 3 0 ne get state 4 0x3d000000 274 ret 44 275 end 276 ret 0 277 end 278 279 fn test_sum_mode to ulong 280 note Diamond graph: V=3, E=2: (0 -> 2, w=0.5), (1 -> 2, w=0.5), gamma=0.5, hops=1 281 note Seed v0=1.0, v1=0.5 -> v2 = (0.5*0.5)*1.0 + (0.5*0.5)*0.5 = 0.25 + 0.125 = 0.375 (0x3ec00000) 282 csr = new uint 96 0 283 put csr 0 0 284 put csr 1 0 285 put csr 2 0 286 put csr 3 2 287 put csr 32 0 288 put csr 33 1 289 put csr 64 0x3f000000 290 put csr 65 0x3f000000 291 292 hdr = new ulong 16 0 293 offs = new ulong 5 0 294 msz = new ulong 5 0 295 put hdr 0 0x4152425300000001 296 put hdr 1 3 297 put hdr 2 2 298 put hdr 3 1 299 put hdr 5 1 300 put hdr 6 0x3f000000 301 put hdr 7 2 302 put hdr 8 0 303 put hdr 15 0 304 if ne arboris_spread_plan hdr 0x10000000 4096 offs msz 0 305 ret 70 306 end 307 state = new uint 6 0 308 receipt = new ulong 8 0 309 put state 0 0x3f800000 310 put state 1 0x3f000000 311 if ne arboris_spread_cpu_run hdr csr state receipt 0 312 ret 71 313 end 314 note Active bank after 1 hop is 1 (state[3..5]): v2 == 0.375 (0x3ec00000) 315 if ne get state 5 0x3ec00000 316 ret 72 317 end 318 note Reject mode=3 with B=1 and mode=4 319 put hdr 7 3 320 if eq arboris_spread_plan hdr 0x10000000 4096 offs msz 0 321 ret 73 322 end 323 put hdr 7 4 324 if eq arboris_spread_plan hdr 0x10000000 4096 offs msz 0 325 ret 74 326 end 327 ret 0 328 end 329 330 fn test_emit to ulong 331 code0 = new uchar 16384 0 332 code1 = new uchar 16384 0 333 code2 = new uchar 16384 0 334 code3 = new uchar 16384 0 335 sz0 = bw_arboris_spread_emit_mode0 code0 336 sz1 = bw_arboris_spread_emit_mode1 code1 337 sz2 = bw_arboris_spread_emit_mode2 code2 338 sz3 = bw_arboris_spread_emit_mode3 code3 339 if or eq sz0 0 eq sz1 0 340 ret 50 341 end 342 if or ne sz2 sz0 ne sz3 sz1 343 ret 75 344 end 345 ret 0 346 end 347 348 fn test_csr_bounds hdr edit ulong 16 vas edit ulong 10 drv view uint 224 bank edit uint 240 q0 edit uint 96 q1 edit uint 96 to ulong 349 src = get hdr 11 350 weights = get hdr 12 351 put hdr 11 add src 1 352 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 2 353 ret 58 354 end 355 put hdr 11 src 356 put hdr 12 sub src 128 357 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 2 358 ret 59 359 end 360 put hdr 12 add weights 4096 361 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 2 362 ret 63 363 end 364 put hdr 12 weights 365 base = get vas 6 366 put vas 6 sub 0x10000000000 weights 367 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 2 368 ret 60 369 end 370 put vas 6 base 371 ret 0 372 end 373 374 fn test_qmd to ulong 375 hdr = new ulong 16 0 376 offs = new ulong 5 0 377 msz = new ulong 5 0 378 put hdr 0 0x4152425300000001 379 put hdr 1 129 380 put hdr 2 64 381 put hdr 3 37 382 put hdr 5 4 383 put hdr 6 0x3f000000 384 put hdr 7 1 385 if ne arboris_spread_plan hdr 0x10000000 4096 offs msz 0 386 ret 51 387 end 388 vas = new ulong 10 0 389 for i ulong 10 390 put vas i add 0x500000000 mul i 65536 391 end 392 drv = new uint 224 0 393 bank = new uint 240 0 394 q0 = new uint 96 0 395 q1 = new uint 96 0 396 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 0 397 ret 52 398 end 399 note Mode 1: stride=64 -> gx=2, V=129 -> gy=ceil(129/4)=33, gpr=24, smem=0 400 if or ne get q1 39 2 ne get q1 40 33 401 ret 53 402 end 403 for i ulong 2 404 k = add i 1 405 addr = get vas k 406 put vas k add addr 1 407 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 3 408 ret 57 409 end 410 put vas k addr 411 end 412 if ne test_csr_bounds hdr vas drv bank q0 q1 0 413 ret 58 414 end 415 put hdr 7 0 416 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 2 417 ret 54 418 end 419 put hdr 7 2 420 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 2 421 ret 76 422 end 423 put hdr 7 4 424 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 2 425 ret 77 426 end 427 put hdr 7 3 428 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 0 429 ret 78 430 end 431 put hdr 7 1 432 put hdr 4 32 433 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 2 434 ret 55 435 end 436 put hdr 4 64 437 note Spread v2 shares the CPU oracle's bounded batch loop (65535). 438 put hdr 3 65535 439 put hdr 4 65536 440 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 0 441 ret 61 442 end 443 put hdr 3 65536 444 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 2 445 ret 62 446 end 447 put hdr 3 37 448 put hdr 4 64 449 put hdr 1 `67108865` 450 if ne bw_arboris_spread_pack_qmd hdr vas drv bank q0 q1 2 451 ret 56 452 end 453 ret 0 454 end 455 456 fn main to int 457 rc = test_ontology_and_csr 458 if ne rc 0 459 ret int rc 460 end 461 rc = test_arena_planner 462 if ne rc 0 463 ret int rc 464 end 465 rc = test_cpu_oracle 466 if ne rc 0 467 ret int rc 468 end 469 rc = test_sum_mode 470 if ne rc 0 471 ret int rc 472 end 473 rc = test_emit 474 if ne rc 0 475 ret int rc 476 end 477 rc = test_qmd 478 if ne rc 0 479 ret int rc 480 end 481 ret 0 482 end