use vyre_foundation::ir::{Node, Program};
use vyre_primitives::graph::{
adaptive_traverse::{adaptive_dense_step, should_use_dense},
csr_forward_or_changed::{
csr_forward_or_changed_body, csr_forward_or_changed_body_prefixed,
csr_forward_or_changed_child, csr_forward_or_changed_child_prefixed,
csr_forward_or_changed_parallel, csr_forward_or_changed_parallel_batch,
csr_forward_or_changed_parallel_batch_global,
csr_forward_or_changed_parallel_batch_global_slot,
try_csr_forward_or_changed_parallel_batch,
try_csr_forward_or_changed_parallel_batch_global_slot,
},
csr_frontier_degree_sum::csr_frontier_degree_sum,
persistent_bfs_step::{
persistent_bfs_step, persistent_bfs_step_body, persistent_bfs_step_body_prefixed,
persistent_bfs_step_child, persistent_bfs_step_child_prefixed,
persistent_bfs_step_child_prefixed_with_active,
},
program_graph::ProgramGraphShape,
};
#[must_use]
pub fn select_dense_traversal(frontier_in: &[u32], node_count: u32) -> bool {
should_use_dense(frontier_in, node_count)
}
#[must_use]
pub fn dispatch_adaptive_dense_step(
frontier_in: &str,
frontier_out: &str,
adj_rows_dense: &str,
node_count: u32,
) -> Program {
adaptive_dense_step(frontier_in, frontier_out, adj_rows_dense, node_count)
}
#[must_use]
pub fn csr_forward_body(
shape: ProgramGraphShape,
frontier_out: &str,
changed_var: &str,
edge_kind_mask: u32,
) -> Vec<Node> {
csr_forward_or_changed_body(shape, frontier_out, changed_var, edge_kind_mask)
}
#[must_use]
pub fn prefixed_csr_forward_body(
shape: ProgramGraphShape,
frontier_out: &str,
changed_var: &str,
edge_kind_mask: u32,
prefix: &str,
) -> Vec<Node> {
csr_forward_or_changed_body_prefixed(shape, frontier_out, changed_var, edge_kind_mask, prefix)
}
#[must_use]
pub fn child_csr_forward_stage(
parent_op_id: &str,
shape: ProgramGraphShape,
frontier_out: &str,
changed_var: &str,
edge_kind_mask: u32,
) -> Node {
csr_forward_or_changed_child(
parent_op_id,
shape,
frontier_out,
changed_var,
edge_kind_mask,
)
}
#[must_use]
pub fn prefixed_child_csr_forward_stage(
parent_op_id: &str,
shape: ProgramGraphShape,
frontier_out: &str,
changed_var: &str,
edge_kind_mask: u32,
prefix: &str,
) -> Node {
csr_forward_or_changed_child_prefixed(
parent_op_id,
shape,
frontier_out,
changed_var,
edge_kind_mask,
prefix,
)
}
#[must_use]
pub fn dispatch_csr_forward_parallel(
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
edge_kind_mask: u32,
) -> Program {
csr_forward_or_changed_parallel(shape, frontier_out, changed, edge_kind_mask)
}
pub fn dispatch_csr_forward_batch_checked(
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
edge_kind_mask: u32,
query_count: u32,
) -> Result<Program, String> {
try_csr_forward_or_changed_parallel_batch(
shape,
frontier_out,
changed,
edge_kind_mask,
query_count,
)
}
#[must_use]
pub fn dispatch_csr_forward_batch(
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
edge_kind_mask: u32,
query_count: u32,
) -> Program {
csr_forward_or_changed_parallel_batch(shape, frontier_out, changed, edge_kind_mask, query_count)
}
#[must_use]
pub fn dispatch_csr_forward_batch_global(
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
edge_kind_mask: u32,
query_count: u32,
) -> Program {
csr_forward_or_changed_parallel_batch_global(
shape,
frontier_out,
changed,
edge_kind_mask,
query_count,
)
}
#[allow(clippy::too_many_arguments)]
pub fn dispatch_csr_forward_batch_global_slot_checked(
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
edge_kind_mask: u32,
query_count: u32,
changed_slot: u32,
changed_slots: u32,
) -> Result<Program, String> {
try_csr_forward_or_changed_parallel_batch_global_slot(
shape,
frontier_out,
changed,
edge_kind_mask,
query_count,
changed_slot,
changed_slots,
)
}
#[must_use]
#[allow(clippy::too_many_arguments)]
pub fn dispatch_csr_forward_batch_global_slot(
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
edge_kind_mask: u32,
query_count: u32,
changed_slot: u32,
changed_slots: u32,
) -> Program {
csr_forward_or_changed_parallel_batch_global_slot(
shape,
frontier_out,
changed,
edge_kind_mask,
query_count,
changed_slot,
changed_slots,
)
}
#[must_use]
pub fn dispatch_frontier_degree_sum(shape: ProgramGraphShape) -> Program {
csr_frontier_degree_sum(shape)
}
#[must_use]
pub fn persistent_step_body(
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
scratch: &str,
edge_kind_mask: u32,
) -> Vec<Node> {
persistent_bfs_step_body(shape, frontier_out, changed, scratch, edge_kind_mask)
}
#[must_use]
pub fn prefixed_persistent_step_body(
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
scratch: &str,
edge_kind_mask: u32,
prefix: &str,
) -> Vec<Node> {
persistent_bfs_step_body_prefixed(
shape,
frontier_out,
changed,
scratch,
edge_kind_mask,
prefix,
)
}
#[must_use]
pub fn child_persistent_step(
parent_op_id: &str,
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
scratch: &str,
edge_kind_mask: u32,
) -> Node {
persistent_bfs_step_child(
parent_op_id,
shape,
frontier_out,
changed,
scratch,
edge_kind_mask,
)
}
#[must_use]
pub fn prefixed_child_persistent_step(
parent_op_id: &str,
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
scratch: &str,
edge_kind_mask: u32,
prefix: &str,
) -> Node {
persistent_bfs_step_child_prefixed(
parent_op_id,
shape,
frontier_out,
changed,
scratch,
edge_kind_mask,
prefix,
)
}
#[must_use]
#[allow(clippy::too_many_arguments)]
pub fn active_child_persistent_step(
parent_op_id: &str,
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
scratch: &str,
active_scratch: &str,
edge_kind_mask: u32,
prefix: &str,
) -> Node {
persistent_bfs_step_child_prefixed_with_active(
parent_op_id,
shape,
frontier_out,
changed,
scratch,
active_scratch,
edge_kind_mask,
prefix,
)
}
#[must_use]
pub fn dispatch_persistent_bfs_step(
shape: ProgramGraphShape,
frontier_out: &str,
changed: &str,
edge_kind_mask: u32,
) -> Program {
persistent_bfs_step(shape, frontier_out, changed, edge_kind_mask)
}