#![allow(clippy::too_many_arguments)]
use crate::fixed_point_graph::FixedPointAnalysisPlan;
use crate::fixed_point_resident::FixedPointResidentGraph;
use crate::fixed_point_resident_frontier::FixedPointResidentFrontierScratch;
pub trait GraphRef {
fn graph_ref(&self) -> &FixedPointResidentGraph;
}
impl GraphRef for FixedPointResidentGraph {
fn graph_ref(&self) -> &FixedPointResidentGraph {
self
}
}
impl GraphRef for &FixedPointResidentGraph {
fn graph_ref(&self) -> &FixedPointResidentGraph {
self
}
}
#[derive(Clone)]
pub struct PlanBuilder<G: GraphRef> {
pub(crate) graph: G,
pub(crate) pipeline: std::sync::Arc<dyn vyre::CompiledPipeline>,
}
impl<G: GraphRef> std::fmt::Debug for PlanBuilder<G> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("PlanBuilder")
.field("graph", self.graph.graph_ref())
.finish_non_exhaustive()
}
}
impl<G: GraphRef> PartialEq for PlanBuilder<G> {
fn eq(&self, other: &Self) -> bool {
self.graph.graph_ref() == other.graph.graph_ref()
}
}
impl<G: GraphRef> PlanBuilder<G> {
fn compiled_pipeline(&self) -> &dyn vyre::CompiledPipeline {
&*self.pipeline
}
fn require_sequence_layout(
&self,
plan: &FixedPointAnalysisPlan,
caller: &'static str,
) -> Result<(), String> {
self.graph
.graph_ref()
.require_same_layout(plan.graph(), caller)
}
#[must_use]
pub fn node_count(&self) -> u32 {
self.graph.graph_ref().node_count()
}
#[must_use]
pub fn edge_count(&self) -> u32 {
self.graph.graph_ref().edge_count()
}
#[must_use]
pub fn resident_resource_count(&self) -> usize {
self.graph.graph_ref().resident_resource_count()
}
pub fn reaching_resident_frontier(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
) -> Result<Vec<u32>, String> {
self.graph.graph_ref().reaching_resident_frontier(
backend,
self.compiled_pipeline(),
seed_bits,
max_iterations,
config,
scratch,
)
}
pub fn reaching_resident_frontier_into(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
self.graph.graph_ref().reaching_resident_frontier_into(
backend,
self.compiled_pipeline(),
seed_bits,
max_iterations,
config,
scratch,
result,
)
}
pub fn reaching_reusing_frontier(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
) -> Result<Vec<u32>, String> {
crate::reaching::reaching_closure_resident_plan_with_reusable_frontier_scratch(
backend,
self.compiled_pipeline(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
config,
scratch,
resident_frontier,
)
}
pub fn reaching_reusing_frontier_into(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
crate::reaching::reaching_closure_resident_plan_with_reusable_frontier_scratch_into(
backend,
self.compiled_pipeline(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
config,
scratch,
resident_frontier,
result,
)
}
pub fn live_resident_frontier(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
) -> Result<Vec<u32>, String> {
self.graph.graph_ref().live_resident_frontier(
backend,
self.compiled_pipeline(),
seed_bits,
max_iterations,
config,
scratch,
)
}
pub fn live_resident_frontier_into(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
self.graph.graph_ref().live_resident_frontier_into(
backend,
self.compiled_pipeline(),
seed_bits,
max_iterations,
config,
scratch,
result,
)
}
pub fn live_reusing_frontier(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
) -> Result<Vec<u32>, String> {
crate::live::live_closure_resident_plan_with_reusable_frontier_scratch(
backend,
self.compiled_pipeline(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
config,
scratch,
resident_frontier,
)
}
pub fn live_reusing_frontier_into(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
crate::live::live_closure_resident_plan_with_reusable_frontier_scratch_into(
backend,
self.compiled_pipeline(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
config,
scratch,
resident_frontier,
result,
)
}
pub fn points_to_subset_resident_frontier(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
) -> Result<Vec<u32>, String> {
self.graph.graph_ref().points_to_subset_resident_frontier(
backend,
self.compiled_pipeline(),
seed_bits,
max_iterations,
config,
scratch,
)
}
pub fn points_to_subset_resident_frontier_into(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
self.graph
.graph_ref()
.points_to_subset_resident_frontier_into(
backend,
self.compiled_pipeline(),
seed_bits,
max_iterations,
config,
scratch,
result,
)
}
pub fn points_to_subset_reusing_frontier(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
) -> Result<Vec<u32>, String> {
crate::points_to::subset_closure_resident_plan_with_reusable_frontier_scratch(
backend,
self.compiled_pipeline(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
config,
scratch,
resident_frontier,
)
}
pub fn points_to_subset_reusing_frontier_into(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
crate::points_to::subset_closure_resident_plan_with_reusable_frontier_scratch_into(
backend,
self.compiled_pipeline(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
config,
scratch,
resident_frontier,
result,
)
}
pub fn slice_resident_frontier(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
) -> Result<Vec<u32>, String> {
self.graph.graph_ref().slice_resident_frontier(
backend,
self.compiled_pipeline(),
seed_bits,
max_iterations,
config,
scratch,
)
}
pub fn slice_resident_frontier_into(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
self.graph.graph_ref().slice_resident_frontier_into(
backend,
self.compiled_pipeline(),
seed_bits,
max_iterations,
config,
scratch,
result,
)
}
pub fn slice_reusing_frontier(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
) -> Result<Vec<u32>, String> {
crate::slice::slice_closure_resident_plan_with_reusable_frontier_scratch(
backend,
self.compiled_pipeline(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
config,
scratch,
resident_frontier,
)
}
pub fn slice_reusing_frontier_into(
&self,
backend: &dyn vyre::VyreBackend,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
crate::slice::slice_closure_resident_plan_with_reusable_frontier_scratch_into(
backend,
self.compiled_pipeline(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
config,
scratch,
resident_frontier,
result,
)
}
pub fn reaching_reusing_frontier_sequence_window(
&self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
) -> Result<Vec<u32>, String> {
self.require_sequence_layout(
plan,
"PlanBuilder::reaching_reusing_frontier_sequence_window",
)?;
crate::reaching::reaching_closure_resident_plan_with_reusable_frontier_scratch_sequence_window(
backend,
plan.program(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
scratch,
resident_frontier,
)
}
pub fn reaching_reusing_frontier_sequence_window_into(
&self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
self.require_sequence_layout(
plan,
"PlanBuilder::reaching_reusing_frontier_sequence_window_into",
)?;
crate::reaching::reaching_closure_resident_plan_with_reusable_frontier_scratch_sequence_window_into(
backend,
plan.program(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
scratch,
resident_frontier,
result,
)
}
pub fn live_reusing_frontier_sequence_window(
&self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
) -> Result<Vec<u32>, String> {
self.require_sequence_layout(plan, "PlanBuilder::live_reusing_frontier_sequence_window")?;
crate::live::live_closure_resident_plan_with_reusable_frontier_scratch_sequence_window(
backend,
plan.program(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
scratch,
resident_frontier,
)
}
pub fn live_reusing_frontier_sequence_window_into(
&self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
self.require_sequence_layout(
plan,
"PlanBuilder::live_reusing_frontier_sequence_window_into",
)?;
crate::live::live_closure_resident_plan_with_reusable_frontier_scratch_sequence_window_into(
backend,
plan.program(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
scratch,
resident_frontier,
result,
)
}
pub fn points_to_subset_reusing_frontier_sequence_window(
&self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
) -> Result<Vec<u32>, String> {
self.require_sequence_layout(
plan,
"PlanBuilder::points_to_subset_reusing_frontier_sequence_window",
)?;
crate::points_to::subset_closure_resident_plan_with_reusable_frontier_scratch_sequence_window(
backend,
plan.program(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
scratch,
resident_frontier,
)
}
pub fn points_to_subset_reusing_frontier_sequence_window_into(
&self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
self.require_sequence_layout(
plan,
"PlanBuilder::points_to_subset_reusing_frontier_sequence_window_into",
)?;
crate::points_to::subset_closure_resident_plan_with_reusable_frontier_scratch_sequence_window_into(
backend,
plan.program(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
scratch,
resident_frontier,
result,
)
}
pub fn slice_reusing_frontier_sequence_window(
&self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
) -> Result<Vec<u32>, String> {
self.require_sequence_layout(plan, "PlanBuilder::slice_reusing_frontier_sequence_window")?;
crate::slice::slice_closure_resident_plan_with_reusable_frontier_scratch_sequence_window(
backend,
plan.program(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
scratch,
resident_frontier,
)
}
pub fn slice_reusing_frontier_sequence_window_into(
&self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
scratch: &mut crate::fixed_point_scratch::FixedPointScratch,
resident_frontier: &mut FixedPointResidentFrontierScratch,
result: &mut Vec<u32>,
) -> Result<(), String> {
self.require_sequence_layout(
plan,
"PlanBuilder::slice_reusing_frontier_sequence_window_into",
)?;
crate::slice::slice_closure_resident_plan_with_reusable_frontier_scratch_sequence_window_into(
backend,
plan.program(),
self.graph.graph_ref(),
seed_bits,
max_iterations,
scratch,
resident_frontier,
result,
)
}
}