Skip to content

Make the dual-mode example a diamond split/recombine DAG - #593

Merged
0-jake-0 merged 1 commit into
nextfrom
claude/dual-mode-split-recombine-diamond-bzgvam
Jul 28, 2026
Merged

Make the dual-mode example a diamond split/recombine DAG#593
0-jake-0 merged 1 commit into
nextfrom
claude/dual-mode-split-recombine-diamond-bzgvam

Conversation

@0-jake-0

Copy link
Copy Markdown
Contributor

Summary

Reworks the dual_mode example so its graph! wiring is a diamond (split/recombine) DAG instead of a mostly-linear chain. This demonstrates that the macro's dual-mode expansion derives a non-linear graph — a shared apex node and a two-input recombine — into both the interpreted and the fully monomorphized compiled runner, and that the two agree.

           count            (apex — shared node, executed once/cycle)
          /     \
     doubled   squared      (two independent branches)
          \     /
         combined           (recombine — join reads both branches)
            |
           sum

count is referenced twice, so it is a shared apex node: the interpreted engine runs it once per cycle and fans the tick out to both branches, and the compiled engine emits it once and feeds both join inputs from the same slot.

Why

Answers the question "can the dual-mode graph! macro handle a split/recombine diamond?" — yes. The macro derives the full DAG from the wiring tokens (shared/fan-out nodes and multi-input recombine ops like join/merge), so nothing is limited to linear chains. Updating the canonical dual-mode example to a diamond makes that explicit in the one example most likely to be read first.

Testing

cargo run -p wingfoil-next --release --example dual_mode:

diamond sum of (2i + i^2) over 200000 cycles: 2666726666900000 (both engines agree)
interpreted: 29.6ms  (148.2 ns/cycle)
compiled:     9.7ms  ( 48.7 ns/cycle)
speedup:      3.0x

cargo fmt --all -- --check and cargo clippy -p wingfoil-next --example dual_mode -- -D warnings both pass.

🤖 Generated with Claude Code


Generated by Claude Code

Rework the dual_mode example so its graph! wiring is the canonical
split/recombine graph: a counter is split on parity into two labelled
branches ("{i} is odd" / "{i} is even") which are merged back into one
stream and printed. This shows the macro's dual-mode expansion deriving a
non-linear DAG — a shared apex node and a recombine — into both the
interpreted and the fully monomorphized compiled runner, with the example
asserting the two agree.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GNhpnzwTYzMe1DWiVn2h2E
@0-jake-0
0-jake-0 force-pushed the claude/dual-mode-split-recombine-diamond-bzgvam branch from ad140d3 to b3d2fa2 Compare July 28, 2026 07:51
@0-jake-0
0-jake-0 merged commit 4b8a8bf into next Jul 28, 2026
5 of 6 checks passed
@0-jake-0
0-jake-0 deleted the claude/dual-mode-split-recombine-diamond-bzgvam branch July 28, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants