lumbda/c
russell@unturf.com f398902cc4
c-tier: emit-circuit-to-ops-bin-stream — streaming-emit primitive
Ports lumbda.py _emit_circuit_to_ops_bin_stream to C tier. Walks a
Scheme registers + ops list, writes each 56-byte QECCOPS1 op record
straight to disk via fopen/fwrite, then seeks back to patch the n_ops
header at the tail. O(1) host memory regardless of n_ops.

Cross-tier byte-identity verified:
  * 500-op mixed-tag synthetic circuit on host: Python ↔ C identical
  * real-point-add n+1=5 (p=11, 94,214 ops, 5.0 MB) inside VM
  * real-point-add n+1=9 (p=251, 674,872 ops, 36 MB) inside VM
  sha256 matches every width.

Speedup on equal Scheme source (build + emit combined):
  * n+1=5:  Python 56.8 s → C 1.1 s  (52×)
  * n+1=9:  Python 365 s  → C 8.4 s  (43×)
Combined ratio exceeds the prior 11-16× C-tier envelope because the
build phase (Phase B mod-arith construction) also accelerates on C;
emit-only ratio is ~3-9× and grows with op count.

C test suite: 85 → 88 passing (emit-stream-basic, alloc-free, empty).
Shared functional suite: 205/205 still passing on both tiers.

Implementation notes:
  * pack_op_record packs u32 kind + u32 pad + 6× u64 LE, matching
    op-specs->bytes byte layout exactly.
  * Layout hashtable Symbol → fixnum base, mirroring walk-circuit-ops.
  * NO_SLOT sentinel: 0xFFFFFFFFFFFFFFFF written directly to u64 slots
    that the Scheme side did not populate.
  * libc's default fwrite buffer (~4 KB) handles batching at ~73 ops
    per write — same throughput class as Python tier's 8 KiB list batch.
2026-06-07 11:36:46 -04:00
..
.gitignore rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
bench.c rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
bignum.c c-tier bignum — arbitrary-precision integers unblock secp256k1 widths 2026-06-06 20:23:37 -04:00
builtins.c c-tier: emit-circuit-to-ops-bin-stream — streaming-emit primitive 2026-06-07 11:36:46 -04:00
eval.c c-tier bignum — arbitrary-precision integers unblock secp256k1 widths 2026-06-06 20:23:37 -04:00
jit.c rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
jit.h rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
lumbda.h c-tier bignum — arbitrary-precision integers unblock secp256k1 widths 2026-06-06 20:23:37 -04:00
main.c c: enable Boehm GC by default, GC_INIT, file ops, regression test 2026-06-04 00:55:31 -04:00
Makefile c-tier bignum — arbitrary-precision integers unblock secp256k1 widths 2026-06-06 20:23:37 -04:00
portal.c portal-rng: add (random-seed-from-os!) across all three tiers 2026-04-20 15:50:26 -04:00
printer.c c-tier bignum — arbitrary-precision integers unblock secp256k1 widths 2026-06-06 20:23:37 -04:00
reader.c c-tier bignum — arbitrary-precision integers unblock secp256k1 widths 2026-06-06 20:23:37 -04:00
test.c c-tier: emit-circuit-to-ops-bin-stream — streaming-emit primitive 2026-06-07 11:36:46 -04:00
types.c c-tier bignum — arbitrary-precision integers unblock secp256k1 widths 2026-06-06 20:23:37 -04:00
vm.c c-tier bignum — arbitrary-precision integers unblock secp256k1 widths 2026-06-06 20:23:37 -04:00