v4 fabric: each pass of a step walks only the places that hold a node (mechanism A)

The fabric keeps its occupied places as a list in ascending order, and
the step's nine passes walk that list in the same order as before. A
place removed mid-walk keeps its link, so the walk goes on to the next
node.

Test first: test_fabric_walk.c, 13 checks.

Every existing fabric and mesh test passes with the same checks, and so
do test-32 and ASan/UBSan. The host mesh boot runs POST 990/990. Over
five alternating runs its median falls from 11.695 s to 7.999 s.

Logs are in logs/20261117-mechanism-a.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-17 22:23:58 +00:00
parent d34fa415c3
commit edbb79e2af
9 changed files with 802 additions and 11 deletions
@@ -89,3 +89,34 @@ births come later). f10d2bc8 did, for each instruction word, one have-mask and o
## 6. For ruling
Run Step 0 (measure only), then bring back the data and the choice among A, B and C?
## 7. As built: mechanism A (2026-11-17, Captain Bob: "Go")
**What changed:**
- The fabric keeps the places that hold a node as a list in ascending order (`v4_place.next`,
`v4_fabric.first`; `v4_fabric_first` and `v4_fabric_next` in `fabric.h`). `v4_fabric_add` puts a node
into the list and `v4_fabric_remove` takes it out.
- Each of the step's nine passes walks this list, not every place, in the same order as before.
- A place removed while a pass is at it keeps its link, so the walk goes on to the next node, as the loop
over every place did. A node added in a step after the place being walked is walked in that step, as
before.
**Test first:** `v4/tests/test_fabric_walk.c`, 13 checks. It failed to build before the change (no walk)
and passes after.
**Verified** (`logs/20261117-mechanism-a/`):
- Semantics unchanged, every check as before: `test_fabric` 334, `test_host_mesh` 244 (with its
disturbances), `test_host_unit` 126, `test_host_depth`, `test_manage` 78, and all 52 tests at 64 bits.
- The 32-bit build (`test-32`) passes.
- ASan and UBSan are clean on the fabric tests and the mesh boot.
- The host mesh boot runs POST 990 of 990, with 103 checks.
- **The cost** (`timing.txt`, five runs each, alternating OLD = d34fa415 and NEW):
| | Median | Change |
|---|---|---|
| OLD | 11.695 s | |
| NEW | 7.999 s | 32% less |
POST was 990 of 990 in every run. Instruction counts are not given: there is no `perf` in this
container.
- **The gate:** the protocol, next.
+82
View File
@@ -0,0 +1,82 @@
mkcapsule: checking for block conflicts...
mkcapsule: scanning /home/user/LithosAnanke/capsules
[p] zuse.4th (1684 bytes, hash=0x490ded9be257a90b)
[p] font.4th (17688 bytes, hash=0x3f305911500c78f6)
[p] MANIFEST_AUTO.md (11687 bytes, hash=0xe022545a0755960f)
[p] multiuser-doe.4th (3942 bytes, hash=0x22140588ee7c39e6)
[p] hestia:init.4th (891 bytes, hash=0x64e111990fbc45ff)
[p] contrib:README.md (1855 bytes, hash=0x4212e52b927793e7)
[p] ACL.4th (4318 bytes, hash=0xf8890c05c0d8f921)
[p] workload-3.4th (2189 bytes, hash=0x62b7a71576ad1041)
[p] init-l8-diverse.4th (430 bytes, hash=0xaa293201a6c91838)
[p] user-font-demo.4th (1674 bytes, hash=0xce1fd7d1b581a56d)
[p] workload-9.4th (1321 bytes, hash=0x3f2bec73142aa424)
[p] lib.4th (619 bytes, hash=0x4b216635c359ef73)
[p] workload-calib1.4th (304 bytes, hash=0x3b9f2d17b554fabc)
[m] init.4th (669 bytes, hash=0xd09db9461b336431)
[p] workload-1-lite.4th (540 bytes, hash=0x44a7a7e3176dcc8d)
[p] init-l8-stable.4th (278 bytes, hash=0xdc3830f189063a9a)
[p] v4:physics.4th (2937 bytes, hash=0x747d89ca8d57e29c)
[p] v4:forth79.4th (1208 bytes, hash=0x4055641ee17d176b)
[p] v4:sys:log.f18 (4535 bytes, hash=0x544cd004233dff62)
[p] v4:sys:qmath.f18 (8607 bytes, hash=0xa93783c2c8f9b7db)
[p] v4:sys:map-32.f18 (3162 bytes, hash=0x5bdf8cbbebdd3c8f)
[p] v4:sys:blocks.f18 (6112 bytes, hash=0x09d361dbe6174236)
[p] v4:sys:input.f18 (10692 bytes, hash=0x0f13c3f9d5fd07fc)
[p] v4:sys:dict.f18 (13816 bytes, hash=0xe3453808afd5a0af)
[p] v4:sys:forth.f18 (12617 bytes, hash=0xc4c0ad315c95eda4)
[p] v4:sys:quit.f18 (32141 bytes, hash=0x7fa7a7668b6bf1ed)
[p] v4:sys:map-64.f18 (3201 bytes, hash=0x06cb44832df2b8fd)
[p] v4:sys:codegen.f18 (4999 bytes, hash=0x36d2ae84d2911b90)
[p] v4:sys:acl.f18 (4100 bytes, hash=0x76e7e746befa2733)
[p] v4:sys:core.f18 (24370 bytes, hash=0x0f415502fccc3fba)
[p] v4:sys:system.f18 (9757 bytes, hash=0x69f5840a57afdf83)
[p] v4:sys:numout.f18 (6641 bytes, hash=0xca0fb0f9c1589e20)
[p] v4:sys:words.f18 (9642 bytes, hash=0x2f4e5f7f3e7f736f)
[p] v4:sys:compile.f18 (23099 bytes, hash=0xb46bf77ceee7245a)
[p] v4:sys:end.f18 (1452 bytes, hash=0x98fd33b1c431cfe7)
[p] v4:starshipos.4th (702 bytes, hash=0xb74bfa51f8d4719a)
[p] v4:hera.4th (1372 bytes, hash=0x85300ad4e6e8b86b)
[p] v4:rom:sym.f18 (5610 bytes, hash=0xbbad5748f5bbf863)
[p] v4:rom:main.f18 (2284 bytes, hash=0x6994f1f1d567e163)
[p] v4:rom:math.f18 (5108 bytes, hash=0x9be63ad87934622f)
[p] v4:rom:dir.f18 (5112 bytes, hash=0x51b069f0623ded16)
[p] v4:rom:num.f18 (2634 bytes, hash=0x08b76f1b058cac17)
[p] v4:rom:pack.f18 (4583 bytes, hash=0x65a944d8eb7de7f2)
[p] v4:rom:word.f18 (12966 bytes, hash=0x9210d6c2ac424d11)
[p] v4:rom:in.f18 (4230 bytes, hash=0x65798bed38a09f0f)
[p] v4:rom:mesh.f18 (449 bytes, hash=0x83723d76b9620c2c)
[p] v4:centre.4th (3899 bytes, hash=0xccd1b28a101c78b2)
[p] README.md (1633 bytes, hash=0x4b67c994f566e951)
[p] block-acl.4th (980 bytes, hash=0xf6cc2a59e3a6734e)
[p] sdk.4th (2295 bytes, hash=0x008fdbbb62c94a3a)
[p] pki:starshipos-intermediate.der (408 bytes, hash=0xb40aab540c19f877)
[p] init-l8-omni.4th (1986 bytes, hash=0x5979e314d6452045)
[p] acl-std79.4th (5040 bytes, hash=0x773bf9209df191d1)
[p] doe-campaign.4th (2369 bytes, hash=0x26fb485e5c9dc6ff)
[p] init-l8-volatile.4th (718 bytes, hash=0x98caabbbd92abac4)
[p] doe.4th (3244 bytes, hash=0xf154616d248e861f)
[p] fabric.4th (10359 bytes, hash=0x9d9489cbeca4099b)
[p] workload-4.4th (469 bytes, hash=0x099619264e650b1c)
[p] init-l8-temporal.4th (363 bytes, hash=0x51abd4c138246651)
[p] workload-5.4th (480 bytes, hash=0x526964c7c9506a11)
[p] fonts:README.md (1846 bytes, hash=0xf628c2b7a49f4d46)
[p] fonts:JetBrainsMono-Regular.ttf (270224 bytes, hash=0xf4b7077dab274e6b)
[p] init-l8-transition.4th (529 bytes, hash=0xbcc1a81976f0a4c9)
[p] workload-2.4th (1321 bytes, hash=0xf113b3d0bcccae47)
[p] workload-1.4th (1041 bytes, hash=0x63e251adb0a03613)
[p] workload-5-lite.4th (468 bytes, hash=0xea0303f38824f254)
[p] workload-0.4th (290 bytes, hash=0x93f86f60aeba8feb)
[p] artemis:init.4th (16782 bytes, hash=0x7ba120e2a6aab239)
[p] MANIFEST.md (35813 bytes, hash=0x9d3a6fdb7415d224)
[p] workload-7.4th (206 bytes, hash=0x02862291387eb7ac)
[p] BLOCK_MAP.md (22910 bytes, hash=0xd77b316d073bf870)
[p] turtle.4th (3254 bytes, hash=0x4d470418ca543365)
[p] workload-8.4th (172 bytes, hash=0x56b7f2f0efa000df)
[p] workload-6.4th (1986 bytes, hash=0x06fc0ce1e369ef5a)
mkcapsule: 74 capsule(s) collected
mkcapsule: wrote /home/user/LithosAnanke/v4/build/capsule_generated.c
[mesh boot, V4_CELL_BITS=64]
v4 mesh boot: V4_CELL_BITS=64
PARITY:V4_POST tests=990 pass=990 fail=0
103 checks, 0 failures
+6
View File
@@ -0,0 +1,6 @@
13 checks, 0 failures
334 checks, 0 failures
244 checks, 0 failures
v4 mesh boot: V4_CELL_BITS=64
PARITY:V4_POST tests=990 pass=990 fail=0
103 checks, 0 failures
+274
View File
@@ -0,0 +1,274 @@
[V4_CELL_BITS=32 run-32-test_asm.c]
v4 asm tests: V4_CELL_BITS=32
32 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_cells.c]
v4 single-cell word tests: V4_CELL_BITS=32
code: 99 of 1024 words
NIP headroom: data 7 below canary, return 7 below its return address
SWAP headroom: data 6 below canary, return 6 below its return address
ROT headroom: data 5 below canary, return 4 below its return address
-ROT headroom: data 5 below canary, return 5 below its return address
?DUP headroom: data 7 below canary, return 8 below its return address
+! headroom: data 7 below canary, return 8 below its return address
-! headroom: data 7 below canary, return 8 below its return address
2@ headroom: data 7 below canary, return 8 below its return address
2! headroom: data 6 below canary, return 6 below its return address
- headroom: data 6 below canary, return 8 below its return address
MIN headroom: data 3 below canary, return 6 below its return address
MAX headroom: data 3 below canary, return 6 below its return address
OR headroom: data 6 below canary, return 8 below its return address
0> headroom: data 8 below canary, return 8 below its return address
<> headroom: data 7 below canary, return 8 below its return address
< headroom: data 5 below canary, return 7 below its return address
> headroom: data 5 below canary, return 6 below its return address
<= headroom: data 5 below canary, return 6 below its return address
>= headroom: data 5 below canary, return 6 below its return address
U< headroom: data 5 below canary, return 7 below its return address
WITHIN headroom: data 3 below canary, return 5 below its return address
21420 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_console.c]
v4 console tests: V4_CELL_BITS=32, capture 4096 characters
312 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_dump.c]
test_dump: 15 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_exec.c]
v4 exec tests: V4_CELL_BITS=32
3107 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_fabric.c]
v4 fabric tests: V4_CELL_BITS=32, 8 ports to a node
334 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_fabric_walk.c]
v4 fabric walk tests
13 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_foundation.c]
v4 foundation tests: V4_CELL_BITS=32
code: 949 of 1024 words
Q.+ random cases that overflow Q48.16: 2682 of 20000
Q.> as written (SWAP D<): 11702 wrong of 20169
(UQ/) cases run: 8687
UM* headroom: data 5 below canary, return 6 below its return address
UM/MOD headroom: data 5 below canary, return 6 below its return address
ABS headroom: data 7 below canary, return 7 below its return address
U> headroom: data 5 below canary, return 5 below its return address
D+ headroom: data 5 below canary, return 5 below its return address
DNEGATE headroom: data 6 below canary, return 7 below its return address
DABS headroom: data 6 below canary, return 6 below its return address
M+ headroom: data 5 below canary, return 4 below its return address
M- headroom: data 4 below canary, return 5 below its return address
M* headroom: data 5 below canary, return 4 below its return address
M/MOD headroom: data 4 below canary, return 3 below its return address
MOD headroom: data 4 below canary, return 2 below its return address
*/MOD headroom: data 4 below canary, return 2 below its return address
*/ headroom: data 4 below canary, return 2 below its return address
D0< headroom: data 7 below canary, return 7 below its return address
D2* headroom: data 6 below canary, return 7 below its return address
D2/ headroom: data 7 below canary, return 7 below its return address
2ROT headroom: data 2 below canary, return 1 below its return address
D- headroom: data 4 below canary, return 4 below its return address
D0= headroom: data 6 below canary, return 7 below its return address
D= headroom: data 4 below canary, return 3 below its return address
< headroom: data 5 below canary, return 7 below its return address
= headroom: data 7 below canary, return 7 below its return address
D< headroom: data 3 below canary, return 3 below its return address
(D<) headroom: data 2 below canary, return 5 below its return address
2SWAP headroom: data 4 below canary, return 4 below its return address
2OVER headroom: data 2 below canary, return 3 below its return address
DMAX headroom: data 2 below canary, return 4 below its return address
DMIN headroom: data 2 below canary, return 4 below its return address
Q.> (2SWAP D<) headroom: data 3 below canary, return 2 below its return address
Q.* headroom: data 2 below canary, return 3 below its return address
(UQ/) headroom: data 3 below canary, return 4 below its return address
Q./ headroom: data 2 below canary, return 3 below its return address
Q.EXP headroom: data 2 below canary, return 2 below its return address
Q.SQRT headroom: data 2 below canary, return 2 below its return address
Q.LOG headroom: data 2 below canary, return 2 below its return address
(Q.REDUCE) headroom: data 4 below canary, return 5 below its return address
Q.SIN headroom: data 2 below canary, return 2 below its return address
Q.COS headroom: data 2 below canary, return 2 below its return address
LSHIFT headroom: data 6 below canary, return 5 below its return address
RSHIFT headroom: data 6 below canary, return 5 below its return address
C@ headroom: data 7 below canary, return 7 below its return address
C! headroom: data 6 below canary, return 7 below its return address
SM/REM headroom: data 4 below canary, return 3 below its return address
/MOD headroom: data 4 below canary, return 2 below its return address
/ headroom: data 4 below canary, return 2 below its return address
* headroom: data 5 below canary, return 5 below its return address
1023754 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_guard.c]
v4 guard tests: V4_CELL_BITS=32, data bound 1, return bound 1
60 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_heat.c]
v4 heat tests: V4_CELL_BITS=32
67 checks, 0 failures
mkrom: rom, 2383 words, 32-bit cells -> /home/user/LithosAnanke/v4/build/rom-32.c
mkrom: mesh_rom, 265 words, 32-bit cells -> /home/user/LithosAnanke/v4/build/mesh-rom-32.c
[V4_CELL_BITS=32 run-32-test_host_blocks.c]
v4 block request tests: V4_CELL_BITS=32, V4_NODE_WORDS=32768
46 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_codegen.c]
v4 host code generator tests: V4_CELL_BITS=32, V4_NODE_WORDS=32768
code: 1728 words
856 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_compile.c]
v4 host compiler tests: V4_CELL_BITS=32, V4_NODE_WORDS=32768
capsule: 4559 words
a line may have 270 values on the stack while the interpreter reads its next word
a word run from the interpreter has 29 return entries to itself
defining and running a word leaves 1017 data cells under it untouched
1096 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_depth.c]
v4 mesh depth tests: V4_CELL_BITS=32, V4_NODE_WORDS=32768
a text that prints 1012..1024 values: works to 1020, then a stack error and nothing else; calls: works to 23 deep; 19 worked, 14 clean errors, 0 failures
SEND 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 26 deep; 20 worked, 13 clean errors, 0 failures
SEND with no way 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 27 deep; 21 worked, 12 clean errors, 0 failures
AWAIT answered 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 24 deep; 18 worked, 15 clean errors, 0 failures
AWAIT ended by a GONE 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 24 deep; 18 worked, 15 clean errors, 0 failures
passing on while its text waits for room 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 17 deep; 11 worked, 22 clean errors, 0 failures
AWAIT broken by a line from the console 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 24 deep; 18 worked, 15 clean errors, 0 failures
a refusal while its text waits for room 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 17 deep; 11 worked, 22 clean errors, 0 failures
GONE 1012..1024 values: works to 1019, then a stack error and nothing else; calls: works to 26 deep; 21 worked, 12 clean errors, 0 failures
a spent message refused while its text waits 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 17 deep; 11 worked, 22 clean errors, 0 failures
330 runs: 168 worked, 162 ended in a stack error and nothing else, 0 did neither
397 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_dict.c]
v4 host dictionary tests: V4_CELL_BITS=32, V4_NODE_WORDS=32768
code: 1633 words
300 entries in 2218 cells
FIND headroom: data 1020 below canary, return 28 below its return address
(') headroom: data 1020 below canary, return 28 below its return address
MAKE headroom: data 1020 below canary, return 28 below its return address
, headroom: data 1020 below canary, return 31 below its return address
ALLOT headroom: data 1020 below canary, return 30 below its return address
708 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_input.c]
v4 host input tests: V4_CELL_BITS=32, V4_NODE_WORDS=32768
code: 1108 words
WORD headroom: data 1020 below canary, return 29 below its return address
NUMBER headroom: data 1016 below canary, return 25 below its return address
EXPECT headroom: data 1020 below canary, return 30 below its return address
ENCLOSE headroom: data 1017 below canary, return 28 below its return address
6569 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_mesh.c]
v4 mesh tests: V4_CELL_BITS=32, V4_NODE_WORDS=32768
the flood: 268 sends tried: 2 refused at once, 121 let go on the way, 145 done; 1 of the two texts that set a node sending let go; (LOST) 122, (REFUSED) 124
between texts the nucleus used at most 3 cells of the data stack and 4 entries of the return stack
a node removed or a wire cut: 19983 times in all
244 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_node.c]
v4 host node tests: V4_CELL_BITS=32, V4_NODE_WORDS=32768
45 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_quit.c]
v4 host prompt tests: V4_CELL_BITS=32, V4_NODE_WORDS=32768
capsule: 7377 words
from the prompt, words may call each other 30 deep
1020 values may wait on the stack while the next line is typed and interpreted
defining and running a word from the prompt leaves 1017 data cells under it untouched
.S prints a stack of up to 1018 values; it needs 6 cells free
WORDS: 318 names, longest line 74 columns
1356 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_rom_asm.c]
test_host_rom_asm: 466 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_rom_in.c]
test_host_rom_in: 26 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_rom_math.c]
v4 ROM math tests: V4_CELL_BITS=32
the host ROM: 2383 words; the mesh ROM: 265 words
156 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_rom_nucleus.c]
the ROM assembled the system: 63351811 instructions, 16522776 instruction words, 0.69 s (32-bit cells)
test_host_rom_nucleus: 6 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_rom_num.c]
test_host_rom_num: 31 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_rom_pack.c]
test_host_rom_pack: 7 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_rom_range.c]
test_host_rom_range: 19 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_rom_sym.c]
test_host_rom_sym: 81 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_host_unit.c]
v4 unit tests: V4_CELL_BITS=32, V4_NODE_WORDS=32768
not run at this width: the capsules are the 64-bit products'
[V4_CELL_BITS=32 run-32-test_iword.c]
v4 iword tests: V4_CELL_BITS=32
1763 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_loops.c]
v4 loop tests: V4_CELL_BITS=32
code: 298 of 1024 words
loops run against C: 3008 (1696 more would run past 63 times and were left out)
DO .. LOOP headroom: data 5 below canary, return 6 below its return address
DO .. +LOOP headroom: data 5 below canary, return 6 below its return address
?DO .. LOOP headroom: data 5 below canary, return 6 below its return address
DO .. LEAVE .. LOOP headroom: data 5 below canary, return 6 below its return address
nested DO, I and J headroom: data 5 below canary, return 4 below its return address
3104 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_manage.c]
v4 manage tests: V4_CELL_BITS=32
78 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_node.c]
v4 node tests: V4_CELL_BITS=32, 1024 words
node: 1024 words + 52 head + 52 tail boundary (10.2% overhead)
1078 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_numout.c]
v4 number-output tests: V4_CELL_BITS=32
code: 382 of 1024 words
SPACES headroom: data 6 below canary, return 7 below its return address
. headroom: data 3 below canary, return 2 below its return address
.R headroom: data 3 below canary, return 2 below its return address
U. headroom: data 3 below canary, return 3 below its return address
U.R headroom: data 3 below canary, return 3 below its return address
D. headroom: data 3 below canary, return 2 below its return address
D.R headroom: data 3 below canary, return 2 below its return address
25242 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_pictured.c]
v4 pictured-output tests: V4_CELL_BITS=32
<# #S #> headroom: data 3 below canary, return 3 below its return address
signed picture headroom: data 3 below canary, return 2 below its return address
4716 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_port.c]
v4 port tests: V4_CELL_BITS=32
25 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_printing.c]
v4 printing tests (? Q.PRINT DUMP BASE HLD): V4_CELL_BITS=32
code: 506 of 1024 words
DECIMAL headroom: data 7 below canary, return 8 below its return address
? headroom: data 3 below canary, return 2 below its return address
Q.PRINT headroom: data 3 below canary, return 3 below its return address
DUMP headroom: data 3 below canary, return 4 below its return address
13439 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_stack.c]
v4 stack tests: V4_CELL_BITS=32, data depth 10, return depth 9
exhaustive: 2046 sequences of length <= 10
differential: 200000 ops
730137 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_strings.c]
v4 string tests: V4_CELL_BITS=32
code: 234 of 1024 words
COUNT headroom: data 6 below canary, return 6 below its return address
CMOVE headroom: data 4 below canary, return 5 below its return address
CMOVE> headroom: data 3 below canary, return 5 below its return address
MOVE headroom: data 5 below canary, return 6 below its return address
FILL headroom: data 4 below canary, return 5 below its return address
BLANK headroom: data 4 below canary, return 5 below its return address
-TRAILING headroom: data 5 below canary, return 6 below its return address
COMPARE headroom: data 3 below canary, return 5 below its return address
SEARCH headroom: data 2 below canary, return 5 below its return address
SCAN headroom: data 4 below canary, return 5 below its return address
SKIP headroom: data 4 below canary, return 5 below its return address
16729 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_terminal.c]
v4 terminal-output tests: V4_CELL_BITS=32
KEY headroom: data 8 below canary
EMIT headroom: data 7 below canary, return 8 below its return address
CR headroom: data 7 below canary, return 8 below its return address
TYPE headroom: data 5 below canary, return 6 below its return address
1212 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_text.c]
v4 text assembler tests: V4_CELL_BITS=32
240 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_umul.c]
v4 umul tests: V4_CELL_BITS=32
2009 checks, 0 failures
[V4_CELL_BITS=32 run-32-test_wire.c]
v4 wire tests: V4_CELL_BITS=32, 1024 cells to a queue
112 checks, 0 failures
rc=0
+273
View File
@@ -0,0 +1,273 @@
[V4_CELL_BITS=64 run-64-test_asm.c]
v4 asm tests: V4_CELL_BITS=64
32 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_cells.c]
v4 single-cell word tests: V4_CELL_BITS=64
code: 99 of 1024 words
NIP headroom: data 7 below canary, return 7 below its return address
SWAP headroom: data 6 below canary, return 6 below its return address
ROT headroom: data 5 below canary, return 4 below its return address
-ROT headroom: data 5 below canary, return 5 below its return address
?DUP headroom: data 7 below canary, return 8 below its return address
+! headroom: data 7 below canary, return 8 below its return address
-! headroom: data 7 below canary, return 8 below its return address
2@ headroom: data 7 below canary, return 8 below its return address
2! headroom: data 6 below canary, return 6 below its return address
- headroom: data 6 below canary, return 8 below its return address
MIN headroom: data 3 below canary, return 6 below its return address
MAX headroom: data 3 below canary, return 6 below its return address
OR headroom: data 6 below canary, return 8 below its return address
0> headroom: data 8 below canary, return 8 below its return address
<> headroom: data 7 below canary, return 8 below its return address
< headroom: data 5 below canary, return 7 below its return address
> headroom: data 5 below canary, return 6 below its return address
<= headroom: data 5 below canary, return 6 below its return address
>= headroom: data 5 below canary, return 6 below its return address
U< headroom: data 5 below canary, return 7 below its return address
WITHIN headroom: data 3 below canary, return 5 below its return address
21420 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_console.c]
v4 console tests: V4_CELL_BITS=64, capture 4096 characters
312 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_dump.c]
test_dump: 15 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_exec.c]
v4 exec tests: V4_CELL_BITS=64
3110 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_fabric.c]
v4 fabric tests: V4_CELL_BITS=64, 8 ports to a node
334 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_fabric_walk.c]
v4 fabric walk tests
13 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_foundation.c]
v4 foundation tests: V4_CELL_BITS=64
code: 949 of 1024 words
Q.+ random cases that overflow Q48.16: 2682 of 20000
Q.> as written (SWAP D<): 12834 wrong of 20169
(UQ/) cases run: 9000
UM* headroom: data 5 below canary, return 6 below its return address
UM/MOD headroom: data 5 below canary, return 6 below its return address
ABS headroom: data 7 below canary, return 7 below its return address
U> headroom: data 5 below canary, return 5 below its return address
D+ headroom: data 5 below canary, return 5 below its return address
DNEGATE headroom: data 6 below canary, return 7 below its return address
DABS headroom: data 6 below canary, return 6 below its return address
M+ headroom: data 5 below canary, return 4 below its return address
M- headroom: data 4 below canary, return 5 below its return address
M* headroom: data 5 below canary, return 4 below its return address
M/MOD headroom: data 4 below canary, return 3 below its return address
MOD headroom: data 4 below canary, return 2 below its return address
*/MOD headroom: data 4 below canary, return 2 below its return address
*/ headroom: data 4 below canary, return 2 below its return address
D0< headroom: data 7 below canary, return 7 below its return address
D2* headroom: data 6 below canary, return 7 below its return address
D2/ headroom: data 7 below canary, return 7 below its return address
2ROT headroom: data 2 below canary, return 1 below its return address
D- headroom: data 4 below canary, return 4 below its return address
D0= headroom: data 6 below canary, return 7 below its return address
D= headroom: data 4 below canary, return 3 below its return address
< headroom: data 5 below canary, return 7 below its return address
= headroom: data 7 below canary, return 7 below its return address
D< headroom: data 3 below canary, return 3 below its return address
(D<) headroom: data 2 below canary, return 5 below its return address
2SWAP headroom: data 4 below canary, return 4 below its return address
2OVER headroom: data 2 below canary, return 3 below its return address
DMAX headroom: data 2 below canary, return 4 below its return address
DMIN headroom: data 2 below canary, return 4 below its return address
Q.> (2SWAP D<) headroom: data 3 below canary, return 2 below its return address
Q.* headroom: data 2 below canary, return 3 below its return address
(UQ/) headroom: data 3 below canary, return 4 below its return address
Q./ headroom: data 2 below canary, return 3 below its return address
Q.EXP headroom: data 2 below canary, return 2 below its return address
Q.SQRT headroom: data 2 below canary, return 2 below its return address
Q.LOG headroom: data 2 below canary, return 2 below its return address
(Q.REDUCE) headroom: data 4 below canary, return 5 below its return address
Q.SIN headroom: data 2 below canary, return 2 below its return address
Q.COS headroom: data 2 below canary, return 2 below its return address
LSHIFT headroom: data 6 below canary, return 5 below its return address
RSHIFT headroom: data 6 below canary, return 5 below its return address
C@ headroom: data 7 below canary, return 7 below its return address
C! headroom: data 6 below canary, return 7 below its return address
SM/REM headroom: data 4 below canary, return 3 below its return address
/MOD headroom: data 4 below canary, return 2 below its return address
/ headroom: data 4 below canary, return 2 below its return address
* headroom: data 5 below canary, return 5 below its return address
1024904 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_guard.c]
v4 guard tests: V4_CELL_BITS=64, data bound 1, return bound 1
60 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_heat.c]
v4 heat tests: V4_CELL_BITS=64
67 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_blocks.c]
v4 block request tests: V4_CELL_BITS=64, V4_NODE_WORDS=32768
48 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_codegen.c]
v4 host code generator tests: V4_CELL_BITS=64, V4_NODE_WORDS=32768
code: 1728 words
856 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_compile.c]
v4 host compiler tests: V4_CELL_BITS=64, V4_NODE_WORDS=32768
capsule: 4559 words
a line may have 270 values on the stack while the interpreter reads its next word
a word run from the interpreter has 29 return entries to itself
defining and running a word leaves 1017 data cells under it untouched
1096 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_depth.c]
v4 mesh depth tests: V4_CELL_BITS=64, V4_NODE_WORDS=32768
a text that prints 1012..1024 values: works to 1020, then a stack error and nothing else; calls: works to 23 deep; 19 worked, 14 clean errors, 0 failures
SEND 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 26 deep; 20 worked, 13 clean errors, 0 failures
SEND with no way 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 27 deep; 21 worked, 12 clean errors, 0 failures
AWAIT answered 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 24 deep; 18 worked, 15 clean errors, 0 failures
AWAIT ended by a GONE 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 24 deep; 18 worked, 15 clean errors, 0 failures
passing on while its text waits for room 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 17 deep; 11 worked, 22 clean errors, 0 failures
AWAIT broken by a line from the console 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 24 deep; 18 worked, 15 clean errors, 0 failures
a refusal while its text waits for room 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 17 deep; 11 worked, 22 clean errors, 0 failures
GONE 1012..1024 values: works to 1019, then a stack error and nothing else; calls: works to 26 deep; 21 worked, 12 clean errors, 0 failures
a spent message refused while its text waits 1012..1024 values: works to 1018, then a stack error and nothing else; calls: works to 17 deep; 11 worked, 22 clean errors, 0 failures
330 runs: 168 worked, 162 ended in a stack error and nothing else, 0 did neither
397 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_dict.c]
v4 host dictionary tests: V4_CELL_BITS=64, V4_NODE_WORDS=32768
code: 1633 words
300 entries in 2218 cells
FIND headroom: data 1020 below canary, return 28 below its return address
(') headroom: data 1020 below canary, return 28 below its return address
MAKE headroom: data 1020 below canary, return 28 below its return address
, headroom: data 1020 below canary, return 31 below its return address
ALLOT headroom: data 1020 below canary, return 30 below its return address
708 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_input.c]
v4 host input tests: V4_CELL_BITS=64, V4_NODE_WORDS=32768
code: 1108 words
WORD headroom: data 1020 below canary, return 29 below its return address
NUMBER headroom: data 1016 below canary, return 25 below its return address
EXPECT headroom: data 1020 below canary, return 30 below its return address
ENCLOSE headroom: data 1017 below canary, return 28 below its return address
6569 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_mesh.c]
v4 mesh tests: V4_CELL_BITS=64, V4_NODE_WORDS=32768
the flood: 268 sends tried: 2 refused at once, 121 let go on the way, 145 done; 1 of the two texts that set a node sending let go; (LOST) 122, (REFUSED) 124
between texts the nucleus used at most 3 cells of the data stack and 4 entries of the return stack
a node removed or a wire cut: 26895 times in all
244 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_node.c]
v4 host node tests: V4_CELL_BITS=64, V4_NODE_WORDS=32768
45 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_quit.c]
v4 host prompt tests: V4_CELL_BITS=64, V4_NODE_WORDS=32768
capsule: 7377 words
from the prompt, words may call each other 30 deep
1020 values may wait on the stack while the next line is typed and interpreted
defining and running a word from the prompt leaves 1017 data cells under it untouched
.S prints a stack of up to 1018 values; it needs 6 cells free
WORDS: 318 names, longest line 74 columns
1360 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_rom_asm.c]
test_host_rom_asm: 472 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_rom_in.c]
test_host_rom_in: 26 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_rom_math.c]
v4 ROM math tests: V4_CELL_BITS=64
the host ROM: 2383 words; the mesh ROM: 265 words
156 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_rom_nucleus.c]
the ROM assembled the system: 63361433 instructions, 16525498 instruction words, 0.63 s (64-bit cells)
test_host_rom_nucleus: 6 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_rom_num.c]
test_host_rom_num: 31 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_rom_pack.c]
test_host_rom_pack: 7 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_rom_range.c]
test_host_rom_range: 19 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_rom_sym.c]
test_host_rom_sym: 81 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_host_unit.c]
v4 unit tests: V4_CELL_BITS=64, V4_NODE_WORDS=32768
after POST and COLD: 225 of the 8302 cells below HERE differ from before POST (the first at 25); dict_hash differs
the four outer nodes: dict_hash=0x82d7793ad6fdb89c
126 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_iword.c]
v4 iword tests: V4_CELL_BITS=64
1763 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_loops.c]
v4 loop tests: V4_CELL_BITS=64
code: 298 of 1024 words
loops run against C: 3008 (1696 more would run past 63 times and were left out)
DO .. LOOP headroom: data 5 below canary, return 6 below its return address
DO .. +LOOP headroom: data 5 below canary, return 6 below its return address
?DO .. LOOP headroom: data 5 below canary, return 6 below its return address
DO .. LEAVE .. LOOP headroom: data 5 below canary, return 6 below its return address
nested DO, I and J headroom: data 5 below canary, return 4 below its return address
3104 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_manage.c]
v4 manage tests: V4_CELL_BITS=64
78 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_node.c]
v4 node tests: V4_CELL_BITS=64, 1024 words
node: 1024 words + 52 head + 52 tail boundary (10.2% overhead)
1078 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_numout.c]
v4 number-output tests: V4_CELL_BITS=64
code: 382 of 1024 words
SPACES headroom: data 6 below canary, return 7 below its return address
. headroom: data 3 below canary, return 2 below its return address
.R headroom: data 3 below canary, return 2 below its return address
U. headroom: data 3 below canary, return 3 below its return address
U.R headroom: data 3 below canary, return 3 below its return address
D. headroom: data 3 below canary, return 2 below its return address
D.R headroom: data 3 below canary, return 2 below its return address
25242 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_pictured.c]
v4 pictured-output tests: V4_CELL_BITS=64
<# #S #> headroom: data 3 below canary, return 3 below its return address
signed picture headroom: data 3 below canary, return 2 below its return address
4716 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_port.c]
v4 port tests: V4_CELL_BITS=64
25 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_printing.c]
v4 printing tests (? Q.PRINT DUMP BASE HLD): V4_CELL_BITS=64
code: 506 of 1024 words
DECIMAL headroom: data 7 below canary, return 8 below its return address
? headroom: data 3 below canary, return 2 below its return address
Q.PRINT headroom: data 3 below canary, return 3 below its return address
DUMP headroom: data 3 below canary, return 4 below its return address
13439 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_stack.c]
v4 stack tests: V4_CELL_BITS=64, data depth 10, return depth 9
exhaustive: 2046 sequences of length <= 10
differential: 200000 ops
730137 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_strings.c]
v4 string tests: V4_CELL_BITS=64
code: 234 of 1024 words
COUNT headroom: data 6 below canary, return 6 below its return address
CMOVE headroom: data 4 below canary, return 5 below its return address
CMOVE> headroom: data 3 below canary, return 5 below its return address
MOVE headroom: data 5 below canary, return 6 below its return address
FILL headroom: data 4 below canary, return 5 below its return address
BLANK headroom: data 4 below canary, return 5 below its return address
-TRAILING headroom: data 5 below canary, return 6 below its return address
COMPARE headroom: data 3 below canary, return 5 below its return address
SEARCH headroom: data 2 below canary, return 5 below its return address
SCAN headroom: data 4 below canary, return 5 below its return address
SKIP headroom: data 4 below canary, return 5 below its return address
16729 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_terminal.c]
v4 terminal-output tests: V4_CELL_BITS=64
KEY headroom: data 8 below canary
EMIT headroom: data 7 below canary, return 8 below its return address
CR headroom: data 7 below canary, return 8 below its return address
TYPE headroom: data 5 below canary, return 6 below its return address
1212 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_text.c]
v4 text assembler tests: V4_CELL_BITS=64
240 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_umul.c]
v4 umul tests: V4_CELL_BITS=64
2808 checks, 0 failures
[V4_CELL_BITS=64 run-64-test_wire.c]
v4 wire tests: V4_CELL_BITS=64, 1024 cells to a queue
112 checks, 0 failures
+10
View File
@@ -0,0 +1,10 @@
OLD 1 11.512 s V4_POST tests=990 pass=990 103 checks, 0 failures
NEW 1 7.7645 s V4_POST tests=990 pass=990 103 checks, 0 failures
OLD 2 11.687 s V4_POST tests=990 pass=990 103 checks, 0 failures
NEW 2 8.0796 s V4_POST tests=990 pass=990 103 checks, 0 failures
OLD 3 11.695 s V4_POST tests=990 pass=990 103 checks, 0 failures
NEW 3 7.7671 s V4_POST tests=990 pass=990 103 checks, 0 failures
OLD 4 11.789 s V4_POST tests=990 pass=990 103 checks, 0 failures
NEW 4 7.9986 s V4_POST tests=990 pass=990 103 checks, 0 failures
OLD 5 11.920 s V4_POST tests=990 pass=990 103 checks, 0 failures
NEW 5 8.1347 s V4_POST tests=990 pass=990 103 checks, 0 failures
+9
View File
@@ -56,6 +56,7 @@ typedef struct {
int asleep;
int cut; /* not 0: a wire of this node's has been cut since it was last woken by that (operation 9) */
v4_wire wire[V4_PORTS];
unsigned next; /* the walk (mechanism A): the next place that holds a node, plus one; 0: none. The fabric's own. */
} v4_place;
typedef struct {
@@ -65,6 +66,7 @@ typedef struct {
unsigned queue_count, queue_free; /* how many, and how many are not on a wire */
unsigned queue_first; /* the first that is not, and the index plus one; 0: none. Each links to the next by its `head`. */
v4_cell gone_error; /* see v4_fabric_gone_error; 0: none */
unsigned first; /* the walk: the first place that holds a node, plus one; 0: none */
} v4_fabric;
/* An empty fabric with room for `capacity` nodes, in `places`. */
@@ -115,6 +117,13 @@ void v4_fabric_gone_error(v4_fabric *f, v4_cell code);
* a word at a time, which executes from its ports and has asked nothing of
* a wire. */
/* THE WALK (mechanism A, docs/v4.0.0/plans/2026-11-17-the-fabric-step-cost.md). The places that hold
* a node, in ascending number: each pass of a step walks these, not every place, in the same order.
* v4_fabric_first gives the first, v4_fabric_next the one after `id` -- also when `id` has just been
* removed -- and each gives the capacity when there are no more. */
unsigned v4_fabric_first(const v4_fabric *f);
unsigned v4_fabric_next(const v4_fabric *f, unsigned id);
/* More room: `places`, of `capacity` no less than before, takes over; every
* node keeps its number and its wiring. */
void v4_fabric_grow(v4_fabric *f, v4_place *places, unsigned capacity);
+44 -11
View File
@@ -29,7 +29,38 @@ void v4_fabric_init(v4_fabric *f, v4_place *places, unsigned capacity)
f->queue_free = 0;
f->queue_first = 0;
f->gone_error = 0;
for (i = 0; i < capacity; i++) clear_place(&places[i]);
f->first = 0;
for (i = 0; i < capacity; i++) { clear_place(&places[i]); places[i].next = 0; }
}
unsigned v4_fabric_first(const v4_fabric *f)
{
return f->first ? f->first - 1u : f->capacity;
}
unsigned v4_fabric_next(const v4_fabric *f, unsigned id)
{
if (id >= f->capacity) return f->capacity;
if (f->place[id].node) return f->place[id].next ? f->place[id].next - 1u : f->capacity;
for (id++; id < f->capacity && !f->place[id].node; id++) { } /* removed while walked: the next that holds one */
return id;
}
/* a node is now at `id`: into the walk, in order */
static void walk_in(v4_fabric *f, unsigned id)
{
unsigned *at = &f->first;
while (*at && *at - 1u < id) at = &f->place[*at - 1u].next;
f->place[id].next = *at;
*at = id + 1u;
}
/* the node at `id` is going: out of the walk. Its own link is kept, so a walk at it goes on. */
static void walk_out(v4_fabric *f, unsigned id)
{
unsigned *at = &f->first;
while (*at && *at - 1u != id) at = &f->place[*at - 1u].next;
if (*at) *at = f->place[id].next;
}
void v4_fabric_gone_error(v4_fabric *f, v4_cell code)
@@ -42,7 +73,7 @@ void v4_fabric_grow(v4_fabric *f, v4_place *places, unsigned capacity)
unsigned i;
if (capacity < f->capacity) return;
for (i = 0; i < f->capacity; i++) places[i] = f->place[i];
for (; i < capacity; i++) clear_place(&places[i]);
for (; i < capacity; i++) { clear_place(&places[i]); places[i].next = 0; }
f->place = places;
f->capacity = capacity;
}
@@ -54,6 +85,7 @@ int v4_fabric_add(v4_fabric *f, v4_fabric_node *storage, v4_cell port_base)
if (i == f->capacity || !storage) return -1;
clear_place(&f->place[i]);
f->place[i].node = storage;
walk_in(f, i);
v4_node_born(&storage->n, port_base);
v4_exec_reset(&storage->es);
v4_heat_reset(&storage->h);
@@ -213,6 +245,7 @@ v4_fabric_node *v4_fabric_remove(v4_fabric *f, unsigned id)
if (id >= f->capacity || !f->place[id].node) return 0;
for (k = 0; k < V4_PORTS; k++) cut(f, id, k);
storage = f->place[id].node;
walk_out(f, id);
clear_place(&f->place[id]);
return storage;
}
@@ -425,7 +458,7 @@ unsigned v4_fabric_step(v4_fabric *f)
unsigned i, k, done = 0;
/* which of its wires have a message waiting, for each node to fetch */
for (i = 0; i < f->capacity; i++)
for (i = v4_fabric_first(f); i < f->capacity; i = v4_fabric_next(f, i))
if (awake(f, i)) {
unsigned have = 0;
for (k = 0; k < V4_PORTS; k++) {
@@ -437,17 +470,17 @@ unsigned v4_fabric_step(v4_fabric *f)
/* a node that is blocked fetches nothing, and is looked about for when
* it is next to execute */
for (i = 0; i < f->capacity; i++)
for (i = v4_fabric_first(f); i < f->capacity; i = v4_fabric_next(f, i))
if (awake(f, i)) {
const v4_node *n = &f->place[i].node->n;
if (!n->stopped && !n->asking && !n->doing && !(n->reading && !n->given)) look_about(f, i);
}
for (i = 0; i < f->capacity; i++)
for (i = v4_fabric_first(f); i < f->capacity; i = v4_fabric_next(f, i))
if (awake(f, i)) done += v4_exec_step_word(&f->place[i].node->n, &f->place[i].node->es, &f->place[i].node->h);
/* a node that fetched which wires have a message has seen what had come */
for (i = 0; i < f->capacity; i++)
for (i = v4_fabric_first(f); i < f->capacity; i = v4_fabric_next(f, i))
if (awake(f, i) && f->place[i].node->n.have_fetched) {
for (k = 0; k < V4_PORTS; k++)
if (f->place[i].wire[k].rx) f->place[i].wire[k].rx->arrived = 0;
@@ -456,28 +489,28 @@ unsigned v4_fabric_step(v4_fabric *f)
/* the operations on the wires, each whole; the two that wait are looked at last, so that
* what every other node has put or taken this step has been, whatever their numbers */
for (i = 0; i < f->capacity; i++)
for (i = v4_fabric_first(f); i < f->capacity; i = v4_fabric_next(f, i))
if (awake(f, i) && f->place[i].node->n.doing && f->place[i].node->n.do_op != 8 && f->place[i].node->n.do_op != 9) {
v4_cell how;
(void)operate(f, i, &how);
v4_node_done(&f->place[i].node->n, how);
done++;
}
for (i = 0; i < f->capacity; i++)
for (i = v4_fabric_first(f); i < f->capacity; i = v4_fabric_next(f, i))
if (awake(f, i) && f->place[i].node->n.doing) {
v4_cell how;
if (operate(f, i, &how)) { v4_node_done(&f->place[i].node->n, how); done++; }
}
for (i = 0; i < f->capacity; i++)
for (i = v4_fabric_first(f); i < f->capacity; i = v4_fabric_next(f, i))
if (awake(f, i) && f->place[i].node->n.asking) done += hand_over_write(f, i);
for (i = 0; i < f->capacity; i++)
for (i = v4_fabric_first(f); i < f->capacity; i = v4_fabric_next(f, i))
if (awake(f, i) && f->place[i].node->n.reading && !f->place[i].node->n.given) done += hand_over_read(f, i);
/* a node blocked at one port that nothing is wired to; or blocked writing a
* word to what will not read one (fabric.h, A WORD NO ONE WILL READ) */
if (f->gone_error != 0)
for (i = 0; i < f->capacity; i++) {
for (i = v4_fabric_first(f); i < f->capacity; i = v4_fabric_next(f, i)) {
v4_node *n;
if (!awake(f, i)) continue;
n = &f->place[i].node->n;
+73
View File
@@ -0,0 +1,73 @@
/* SPDX-License-Identifier: LicenseRef-Starship-1.0
* Copyright (c) 2023-2026 Robert A. James
*/
/* test_fabric_walk.c -- mechanism A (docs/v4.0.0/plans/2026-11-17-the-fabric-step-cost.md 4): the fabric
* keeps the places that hold a node, and a step walks them, not every place. Their order is the places'
* order, as before: v4_fabric_first and v4_fabric_next give the occupied places in ascending number, and
* the capacity when there are no more. Checked: empty; nodes added, removed and added again (the order kept);
* a node removed while the walk is at it (the walk goes on to the next); one node in sixteen places (a walk
* of one, the boot's case); and grown room (the walk kept).
*/
#include "v4/fabric.h"
#include <stdio.h>
#include <string.h>
static int failures = 0, checks = 0;
#define CHECK(c,...) do{checks++; if(!(c)){failures++; printf("FAIL %s:%d: ",__FILE__,__LINE__); printf(__VA_ARGS__); printf("\n");}}while(0)
#define PB ((v4_cell)(V4_NODE_WORDS - 24u))
static v4_fabric_node pool[6];
static v4_place places[16], more[24];
static v4_fabric f;
/* the walk as a string of place numbers, e.g. "0 2 " */
static const char *walk(void)
{
static char s[128];
unsigned i, n = 0, guard = 0;
s[0] = 0;
for (i = v4_fabric_first(&f); i < f.capacity && guard < 64; i = v4_fabric_next(&f, i), guard++)
n += (unsigned)sprintf(s + n, "%u ", i);
return s;
}
int main(void)
{
unsigned k;
printf("v4 fabric walk tests\n");
v4_fabric_init(&f, places, 4);
CHECK(v4_fabric_first(&f) == f.capacity, "an empty fabric: nothing to walk");
for (k = 0; k < 3; k++) (void)v4_fabric_add(&f, &pool[k], PB);
CHECK(strcmp(walk(), "0 1 2 ") == 0, "three nodes: walked 0 1 2 (%s)", walk());
(void)v4_fabric_remove(&f, 1);
CHECK(strcmp(walk(), "0 2 ") == 0, "the middle one removed: 0 2 (%s)", walk());
CHECK(v4_fabric_add(&f, &pool[3], PB) == 1 && strcmp(walk(), "0 1 2 ") == 0, "one added takes place 1, and the order is kept (%s)", walk());
CHECK(v4_fabric_add(&f, &pool[4], PB) == 3 && strcmp(walk(), "0 1 2 3 ") == 0, "and one more at the end (%s)", walk());
(void)v4_fabric_remove(&f, 0);
CHECK(strcmp(walk(), "1 2 3 ") == 0, "the first removed: 1 2 3 (%s)", walk());
/* removed while the walk is at it: the walk goes on to the next, as the loop over every place did */
(void)v4_fabric_remove(&f, 2);
CHECK(v4_fabric_next(&f, 2) == 3, "a removed place's next is the next that holds a node (%u)", v4_fabric_next(&f, 2));
(void)v4_fabric_remove(&f, 3);
CHECK(v4_fabric_next(&f, 2) == f.capacity && v4_fabric_next(&f, 1) == f.capacity, "and none after: the capacity");
(void)v4_fabric_remove(&f, 1);
CHECK(v4_fabric_first(&f) == f.capacity, "all removed: nothing to walk (%s)", walk());
/* the boot's case: Hera alone in sixteen places */
v4_fabric_init(&f, places, 16);
(void)v4_fabric_add(&f, &pool[0], PB);
CHECK(strcmp(walk(), "0 ") == 0, "one node in sixteen places: a walk of one (%s)", walk());
CHECK(v4_fabric_step(&f) == 0 && pool[0].n.reading, "and the step runs it: blocked reading its ports");
/* more room: the walk is kept, and a node added in it is walked */
(void)v4_fabric_add(&f, &pool[1], PB);
v4_fabric_grow(&f, more, 24);
CHECK(strcmp(walk(), "0 1 ") == 0, "grown: the walk kept (%s)", walk());
for (k = 2; k < 6; k++) (void)v4_fabric_add(&f, &pool[k], PB);
CHECK(strcmp(walk(), "0 1 2 3 4 5 ") == 0, "and the nodes added after are walked (%s)", walk());
printf(" %d checks, %d failures\n", checks, failures);
return failures != 0;
}