Skip to main content

weir/fixed_point_batch/ifds/
prepared.rs

1use crate::fixed_point_batch::FixedPointBatch;
2
3impl<'a, F> FixedPointBatch<'a, F>
4where
5    F: Fn(&vyre::ir::Program, &[&[u8]], Option<[u32; 3]>, &mut Vec<Vec<u8>>) -> Result<(), String>,
6{
7    /// Run IFDS reachability against prepared CSR buffers with retained batch scratch.
8    pub fn ifds_prepared(
9        &mut self,
10        prepared: &crate::ifds_gpu::PreparedIfdsCsr,
11        seed_facts: &[(u32, u32, u32)],
12        max_iterations: u32,
13    ) -> Result<Vec<u32>, String> {
14        crate::ifds_gpu::solve_prepared_borrowed_with_scratch_via(
15            self.dispatch,
16            prepared,
17            seed_facts,
18            max_iterations,
19            &mut self.ifds_scratch,
20        )
21    }
22
23    /// Run IFDS reachability against prepared CSR buffers into caller-owned
24    /// result storage with retained batch scratch.
25    pub fn ifds_prepared_into(
26        &mut self,
27        prepared: &crate::ifds_gpu::PreparedIfdsCsr,
28        seed_facts: &[(u32, u32, u32)],
29        max_iterations: u32,
30        result: &mut Vec<u32>,
31    ) -> Result<(), String> {
32        crate::ifds_gpu::solve_prepared_borrowed_with_scratch_into_via(
33            self.dispatch,
34            prepared,
35            seed_facts,
36            max_iterations,
37            &mut self.ifds_scratch,
38            result,
39        )
40    }
41
42    /// Run several IFDS reachability queries against prepared CSR buffers
43    /// while reusing retained batch scratch across every seed set.
44    pub fn ifds_prepared_many(
45        &mut self,
46        prepared: &crate::ifds_gpu::PreparedIfdsCsr,
47        seed_sets: &[&[(u32, u32, u32)]],
48        max_iterations: u32,
49    ) -> Result<Vec<Vec<u32>>, String> {
50        crate::ifds_gpu::solve_prepared_borrowed_many_with_scratch_via(
51            self.dispatch,
52            prepared,
53            seed_sets,
54            max_iterations,
55            &mut self.ifds_scratch,
56        )
57    }
58
59    /// Run several IFDS reachability queries against prepared CSR buffers into
60    /// caller-owned result rows with retained batch scratch.
61    pub fn ifds_prepared_many_into(
62        &mut self,
63        prepared: &crate::ifds_gpu::PreparedIfdsCsr,
64        seed_sets: &[&[(u32, u32, u32)]],
65        max_iterations: u32,
66        results: &mut Vec<Vec<u32>>,
67    ) -> Result<(), String> {
68        crate::ifds_gpu::solve_prepared_borrowed_many_with_scratch_into_via(
69            self.dispatch,
70            prepared,
71            seed_sets,
72            max_iterations,
73            &mut self.ifds_scratch,
74            results,
75        )
76    }
77}