#![allow(clippy::too_many_arguments)]
use super::FixedPointResidentBatch;
use crate::fixed_point_graph::{
FixedPointAnalysisKind, FixedPointAnalysisPlan, FixedPointForwardGraph,
};
use crate::fixed_point_resident_plan::FixedPointBorrowedResidentPlan;
impl FixedPointResidentBatch {
pub fn reaching(
&mut self,
backend: &dyn vyre::VyreBackend,
pipeline: std::sync::Arc<dyn vyre::CompiledPipeline>,
graph: &FixedPointForwardGraph,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
) -> Result<Vec<u32>, String> {
graph.require_kind(
FixedPointAnalysisKind::Reaching,
"FixedPointResidentBatch::reaching",
)?;
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
let plan = FixedPointBorrowedResidentPlan::new(resident, pipeline);
plan.reaching_reusing_frontier(
backend,
seed_bits,
max_iterations,
config,
&mut self.host_scratch,
&mut self.resident_frontier,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Reaching, graph)?;
if let Ok(words) = &result {
self.record_resident_dispatch_io(seed_bits.len(), words.len())?;
}
result
}
pub fn reaching_into(
&mut self,
backend: &dyn vyre::VyreBackend,
pipeline: std::sync::Arc<dyn vyre::CompiledPipeline>,
graph: &FixedPointForwardGraph,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
result: &mut Vec<u32>,
) -> Result<(), String> {
graph.require_kind(
FixedPointAnalysisKind::Reaching,
"FixedPointResidentBatch::reaching_into",
)?;
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let run_result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
let plan = FixedPointBorrowedResidentPlan::new(resident, pipeline);
plan.reaching_reusing_frontier_into(
backend,
seed_bits,
max_iterations,
config,
&mut self.host_scratch,
&mut self.resident_frontier,
result,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Reaching, graph)?;
if run_result.is_ok() {
self.record_resident_dispatch_io(seed_bits.len(), result.len())?;
}
run_result
}
pub fn live(
&mut self,
backend: &dyn vyre::VyreBackend,
pipeline: std::sync::Arc<dyn vyre::CompiledPipeline>,
graph: &FixedPointForwardGraph,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
) -> Result<Vec<u32>, String> {
graph.require_kind(
FixedPointAnalysisKind::Live,
"FixedPointResidentBatch::live",
)?;
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
let plan = FixedPointBorrowedResidentPlan::new(resident, pipeline);
plan.live_reusing_frontier(
backend,
seed_bits,
max_iterations,
config,
&mut self.host_scratch,
&mut self.resident_frontier,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Live, graph)?;
if let Ok(words) = &result {
self.record_resident_dispatch_io(seed_bits.len(), words.len())?;
}
result
}
pub fn live_into(
&mut self,
backend: &dyn vyre::VyreBackend,
pipeline: std::sync::Arc<dyn vyre::CompiledPipeline>,
graph: &FixedPointForwardGraph,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
result: &mut Vec<u32>,
) -> Result<(), String> {
graph.require_kind(
FixedPointAnalysisKind::Live,
"FixedPointResidentBatch::live_into",
)?;
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let run_result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
let plan = FixedPointBorrowedResidentPlan::new(resident, pipeline);
plan.live_reusing_frontier_into(
backend,
seed_bits,
max_iterations,
config,
&mut self.host_scratch,
&mut self.resident_frontier,
result,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Live, graph)?;
if run_result.is_ok() {
self.record_resident_dispatch_io(seed_bits.len(), result.len())?;
}
run_result
}
pub fn points_to_subset(
&mut self,
backend: &dyn vyre::VyreBackend,
pipeline: std::sync::Arc<dyn vyre::CompiledPipeline>,
graph: &FixedPointForwardGraph,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
) -> Result<Vec<u32>, String> {
graph.require_kind(
FixedPointAnalysisKind::PointsToSubset,
"FixedPointResidentBatch::points_to_subset",
)?;
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
let plan = FixedPointBorrowedResidentPlan::new(resident, pipeline);
plan.points_to_subset_reusing_frontier(
backend,
seed_bits,
max_iterations,
config,
&mut self.host_scratch,
&mut self.resident_frontier,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::PointsToSubset, graph)?;
if let Ok(words) = &result {
self.record_resident_dispatch_io(seed_bits.len(), words.len())?;
}
result
}
pub fn points_to_subset_into(
&mut self,
backend: &dyn vyre::VyreBackend,
pipeline: std::sync::Arc<dyn vyre::CompiledPipeline>,
graph: &FixedPointForwardGraph,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
result: &mut Vec<u32>,
) -> Result<(), String> {
graph.require_kind(
FixedPointAnalysisKind::PointsToSubset,
"FixedPointResidentBatch::points_to_subset_into",
)?;
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let run_result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
let plan = FixedPointBorrowedResidentPlan::new(resident, pipeline);
plan.points_to_subset_reusing_frontier_into(
backend,
seed_bits,
max_iterations,
config,
&mut self.host_scratch,
&mut self.resident_frontier,
result,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::PointsToSubset, graph)?;
if run_result.is_ok() {
self.record_resident_dispatch_io(seed_bits.len(), result.len())?;
}
run_result
}
pub fn slice(
&mut self,
backend: &dyn vyre::VyreBackend,
pipeline: std::sync::Arc<dyn vyre::CompiledPipeline>,
graph: &FixedPointForwardGraph,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
) -> Result<Vec<u32>, String> {
graph.require_kind(
FixedPointAnalysisKind::Slice,
"FixedPointResidentBatch::slice",
)?;
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
let plan = FixedPointBorrowedResidentPlan::new(resident, pipeline);
plan.slice_reusing_frontier(
backend,
seed_bits,
max_iterations,
config,
&mut self.host_scratch,
&mut self.resident_frontier,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Slice, graph)?;
if let Ok(words) = &result {
self.record_resident_dispatch_io(seed_bits.len(), words.len())?;
}
result
}
pub fn slice_into(
&mut self,
backend: &dyn vyre::VyreBackend,
pipeline: std::sync::Arc<dyn vyre::CompiledPipeline>,
graph: &FixedPointForwardGraph,
seed_bits: &[u32],
max_iterations: u32,
config: &vyre::DispatchConfig,
result: &mut Vec<u32>,
) -> Result<(), String> {
graph.require_kind(
FixedPointAnalysisKind::Slice,
"FixedPointResidentBatch::slice_into",
)?;
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let run_result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
let plan = FixedPointBorrowedResidentPlan::new(resident, pipeline);
plan.slice_reusing_frontier_into(
backend,
seed_bits,
max_iterations,
config,
&mut self.host_scratch,
&mut self.resident_frontier,
result,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Slice, graph)?;
if run_result.is_ok() {
self.record_resident_dispatch_io(seed_bits.len(), result.len())?;
}
run_result
}
pub fn reaching_sequence_window(
&mut self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
) -> Result<Vec<u32>, String> {
plan.require_kind(
FixedPointAnalysisKind::Reaching,
"FixedPointResidentBatch::reaching_sequence_window",
)?;
let graph = plan.graph();
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
crate::reaching::reaching_closure_resident_plan_with_reusable_frontier_scratch_sequence_window(
backend,
plan.program(),
resident,
seed_bits,
max_iterations,
&mut self.host_scratch,
&mut self.resident_frontier,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Reaching, graph)?;
if let Ok(words) = &result {
self.record_resident_changed_flag_sequence_window_io(seed_bits.len(), words.len())?;
}
result
}
pub fn reaching_sequence_window_into(
&mut self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
result: &mut Vec<u32>,
) -> Result<(), String> {
plan.require_kind(
FixedPointAnalysisKind::Reaching,
"FixedPointResidentBatch::reaching_sequence_window_into",
)?;
let graph = plan.graph();
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let run_result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
crate::reaching::reaching_closure_resident_plan_with_reusable_frontier_scratch_sequence_window_into(
backend,
plan.program(),
resident,
seed_bits,
max_iterations,
&mut self.host_scratch,
&mut self.resident_frontier,
result,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Reaching, graph)?;
if run_result.is_ok() {
self.record_resident_changed_flag_sequence_window_io(seed_bits.len(), result.len())?;
}
run_result
}
pub fn live_sequence_window(
&mut self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
) -> Result<Vec<u32>, String> {
plan.require_kind(
FixedPointAnalysisKind::Live,
"FixedPointResidentBatch::live_sequence_window",
)?;
let graph = plan.graph();
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
crate::live::live_closure_resident_plan_with_reusable_frontier_scratch_sequence_window(
backend,
plan.program(),
resident,
seed_bits,
max_iterations,
&mut self.host_scratch,
&mut self.resident_frontier,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Live, graph)?;
if let Ok(words) = &result {
self.record_resident_changed_flag_sequence_window_io(seed_bits.len(), words.len())?;
}
result
}
pub fn live_sequence_window_into(
&mut self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
result: &mut Vec<u32>,
) -> Result<(), String> {
plan.require_kind(
FixedPointAnalysisKind::Live,
"FixedPointResidentBatch::live_sequence_window_into",
)?;
let graph = plan.graph();
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let run_result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
crate::live::live_closure_resident_plan_with_reusable_frontier_scratch_sequence_window_into(
backend,
plan.program(),
resident,
seed_bits,
max_iterations,
&mut self.host_scratch,
&mut self.resident_frontier,
result,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Live, graph)?;
if run_result.is_ok() {
self.record_resident_changed_flag_sequence_window_io(seed_bits.len(), result.len())?;
}
run_result
}
pub fn points_to_subset_sequence_window(
&mut self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
) -> Result<Vec<u32>, String> {
plan.require_kind(
FixedPointAnalysisKind::PointsToSubset,
"FixedPointResidentBatch::points_to_subset_sequence_window",
)?;
let graph = plan.graph();
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
crate::points_to::subset_closure_resident_plan_with_reusable_frontier_scratch_sequence_window(
backend,
plan.program(),
resident,
seed_bits,
max_iterations,
&mut self.host_scratch,
&mut self.resident_frontier,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::PointsToSubset, graph)?;
if let Ok(words) = &result {
self.record_resident_changed_flag_sequence_window_io(seed_bits.len(), words.len())?;
}
result
}
pub fn points_to_subset_sequence_window_into(
&mut self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
result: &mut Vec<u32>,
) -> Result<(), String> {
plan.require_kind(
FixedPointAnalysisKind::PointsToSubset,
"FixedPointResidentBatch::points_to_subset_sequence_window_into",
)?;
let graph = plan.graph();
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let run_result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
crate::points_to::subset_closure_resident_plan_with_reusable_frontier_scratch_sequence_window_into(
backend,
plan.program(),
resident,
seed_bits,
max_iterations,
&mut self.host_scratch,
&mut self.resident_frontier,
result,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::PointsToSubset, graph)?;
if run_result.is_ok() {
self.record_resident_changed_flag_sequence_window_io(seed_bits.len(), result.len())?;
}
run_result
}
pub fn slice_sequence_window(
&mut self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
) -> Result<Vec<u32>, String> {
plan.require_kind(
FixedPointAnalysisKind::Slice,
"FixedPointResidentBatch::slice_sequence_window",
)?;
let graph = plan.graph();
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
crate::slice::slice_closure_resident_plan_with_reusable_frontier_scratch_sequence_window(
backend,
plan.program(),
resident,
seed_bits,
max_iterations,
&mut self.host_scratch,
&mut self.resident_frontier,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Slice, graph)?;
if let Ok(words) = &result {
self.record_resident_changed_flag_sequence_window_io(seed_bits.len(), words.len())?;
}
result
}
pub fn slice_sequence_window_into(
&mut self,
backend: &dyn vyre::VyreBackend,
plan: &FixedPointAnalysisPlan,
seed_bits: &[u32],
max_iterations: u32,
result: &mut Vec<u32>,
) -> Result<(), String> {
plan.require_kind(
FixedPointAnalysisKind::Slice,
"FixedPointResidentBatch::slice_sequence_window_into",
)?;
let graph = plan.graph();
self.require_frontier_budget(graph)?;
let before = self.frontier_state();
let run_result = {
let resident = self
.graph_cache
.get_or_upload(backend, graph)
.map_err(|error| error.to_string())?;
crate::slice::slice_closure_resident_plan_with_reusable_frontier_scratch_sequence_window_into(
backend,
plan.program(),
resident,
seed_bits,
max_iterations,
&mut self.host_scratch,
&mut self.resident_frontier,
result,
)
};
self.record_frontier_reuse(before)?;
self.record_execution_plan(backend, FixedPointAnalysisKind::Slice, graph)?;
if run_result.is_ok() {
self.record_resident_changed_flag_sequence_window_io(seed_bits.len(), result.len())?;
}
run_result
}
}