weirflow 0.1.0

GPU-first dataflow analysis primitives for Vyre and Santh compiler pipelines.
Documentation
//! `weir::live::live_step`  -  Program construction invariants.
//!
//! Op id: `weir::tests::df::live::construction`. Soundness: `Exact`  -
//! mirrors the reaching test contract for the live-variables
//! backward-step primitive. The primitive is a thin wrapper over
//! `csr_forward_traverse` operating on a reversed graph; the test
//! gates the buffer set + access modes + determinism so the wrapper
//! contract doesn't drift.

use vyre::ir::BufferAccess;
use vyre_primitives::graph::program_graph::ProgramGraphShape;
use weir::live::live_step;

#[test]
fn live_step_emits_required_buffers_and_writable_output() {
    let shape = ProgramGraphShape::new(64, 64);
    let prog = live_step(shape, "frontier_in", "frontier_out");

    let names: Vec<&str> = prog.buffers().iter().map(|b| b.name()).collect();
    assert!(
        names.contains(&"frontier_in"),
        "missing frontier_in; {names:?}"
    );
    assert!(
        names.contains(&"frontier_out"),
        "missing frontier_out; {names:?}"
    );

    let f_in = prog
        .buffers()
        .iter()
        .find(|b| b.name() == "frontier_in")
        .expect("frontier_in declared");
    assert_eq!(f_in.access, BufferAccess::ReadOnly);

    let f_out = prog
        .buffers()
        .iter()
        .find(|b| b.name() == "frontier_out")
        .expect("frontier_out declared");
    assert!(matches!(
        f_out.access,
        BufferAccess::ReadWrite | BufferAccess::WriteOnly
    ));
    assert_ne!(prog.entry().len(), 0);
}

#[test]
fn live_step_is_deterministic() {
    let shape = ProgramGraphShape::new(64, 64);
    let a = live_step(shape, "fin", "fout");
    let b = live_step(shape, "fin", "fout");
    let names_a: Vec<String> = a.buffers().iter().map(|b| b.name().to_string()).collect();
    let names_b: Vec<String> = b.buffers().iter().map(|b| b.name().to_string()).collect();
    assert_eq!(names_a, names_b);
    assert_eq!(a.entry().len(), b.entry().len());
}