weirflow 0.1.0

GPU-first dataflow analysis primitives for Vyre and Santh compiler pipelines.
Documentation
use super::{generic::PlanBuilder, FixedPointResidentPlan};
use crate::fixed_point_graph::FixedPointForwardGraph;
use crate::fixed_point_resident::FixedPointResidentGraph;
use crate::fixed_point_resident_frontier::FixedPointResidentFrontierScratch;

impl FixedPointResidentPlan {
    /// Upload graph buffers and bind them to a compiled pipeline.
    pub fn new(
        backend: &dyn vyre::VyreBackend,
        graph: &FixedPointForwardGraph,
        pipeline: std::sync::Arc<dyn vyre::CompiledPipeline>,
    ) -> Result<Self, vyre::BackendError> {
        Ok(Self {
            inner: PlanBuilder {
                graph: FixedPointResidentGraph::upload(backend, graph)?,
                pipeline,
            },
        })
    }

    /// Free resident graph and reusable frontier resources owned around this plan.
    pub fn free_with_frontier(
        self,
        backend: &dyn vyre::VyreBackend,
        resident_frontier: &mut FixedPointResidentFrontierScratch,
    ) -> Result<(), vyre::BackendError> {
        let frontier_result = resident_frontier.clear(backend);
        let graph_result = self.inner.graph.free(backend);
        match (frontier_result, graph_result) {
            (Err(error), _) | (_, Err(error)) => Err(error),
            (Ok(()), Ok(())) => Ok(()),
        }
    }

    /// Free resident graph resources owned by this plan.
    pub fn free(self, backend: &dyn vyre::VyreBackend) -> Result<(), vyre::BackendError> {
        self.inner.graph.free(backend)
    }
}