weirflow 0.1.0

GPU-first dataflow analysis primitives for Vyre and Santh compiler pipelines.
Documentation
//! `weir::value_set` + `weir::post_dominates`  -  bitset_and wrappers.
//!
//! Op id: `weir::tests::df::value_set_post_dominates`. Soundness:
//! `Exact` for both  -  pure word-wise AND of two host-supplied
//! bitsets. The Programs are thin wrappers tagged with their
//! respective op ids, and the reference oracles match `bitset_and::cpu_ref`.

use weir::post_dominates;
use weir::value_set;

#[test]
fn value_set_cpu_ref_intersects_constants_with_query() {
    let consts = vec![0b0011u32];
    let query = vec![0b0101u32];
    assert_eq!(
        weir::oracle::bitset::value_set(&consts, &query),
        vec![0b0001u32]
    );
}

#[test]
fn value_set_program_three_buffers() {
    let prog = value_set::value_set(64, "consts", "query", "out");
    let mut names: Vec<&str> = prog.buffers().iter().map(|b| b.name()).collect();
    names.sort();
    assert_eq!(names, vec!["consts", "out", "query"]);
    assert!(!prog.entry().is_empty());
}

#[test]
fn post_dominates_cpu_ref_intersects_pdom_with_target() {
    // pdom set: nodes that post-dominate the query target.
    // target set: nodes the caller wants to filter by post-dominance.
    let pdom = vec![0b1100u32];
    let target = vec![0b0110u32];
    assert_eq!(
        weir::oracle::bitset::post_dominates(&pdom, &target),
        vec![0b0100u32]
    );
}

#[test]
fn post_dominates_cpu_ref_disjoint_returns_zero() {
    let pdom = vec![0b1010u32, 0u32];
    let target = vec![0b0101u32, 0xFFu32];
    assert_eq!(
        weir::oracle::bitset::post_dominates(&pdom, &target),
        vec![0u32, 0u32]
    );
}

#[test]
fn post_dominates_program_three_buffers() {
    let prog = post_dominates::post_dominates(64, "pdom", "target", "out");
    let mut names: Vec<&str> = prog.buffers().iter().map(|b| b.name()).collect();
    names.sort();
    assert_eq!(names, vec!["out", "pdom", "target"]);
    assert!(!prog.entry().is_empty());
}