Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion interactive/examples/ddir_col.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ type DdirOuterUpdate = (Row, Row, u64, Diff);
fn run(name: &str, stmts: Vec<parse::Stmt>, n_inputs: usize, nodes: u64, edges: u64, arity: usize, batch: u64, rounds: Option<u64>) {
let mut compiled: Program = lower::lower(stmts);
println!("{}: {} IR nodes (before optimize)", name, compiled.nodes.len());
compiled.optimize();
compiled = interactive::optimize(compiled);
println!("{}: {} IR nodes (after optimize), result = {}", name, compiled.nodes.len(), compiled.result);
compiled.dump();
let name = name.to_string();
Expand Down
2 changes: 1 addition & 1 deletion interactive/examples/ddir_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn render_program<'scope>(program: &Program, scope: Scope<'scope, DdirTime>, inp
fn run(name: &str, stmts: Vec<parse::Stmt>, n_inputs: usize, nodes: u64, edges: u64, arity: usize, batch: u64, rounds: Option<u64>) {
let mut compiled: Program = lower::lower(stmts);
println!("{}: {} IR nodes (before optimize)", name, compiled.nodes.len());
compiled.optimize();
compiled = interactive::optimize(compiled);
println!("{}: {} IR nodes (after optimize), result = {}", name, compiled.nodes.len(), compiled.result);
compiled.dump();
let name = name.to_string();
Expand Down
2 changes: 1 addition & 1 deletion interactive/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where
}

/// An individual step within a Linear node.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub enum LinearOp {
/// Rekey/reval: project to new (key, val).
Project(Projection),
Expand Down
12 changes: 12 additions & 0 deletions interactive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
pub mod parse;
pub mod ir;
pub mod lower;
pub mod opt;

/// Run the optimizer on a flat IR program. Honors the `OPTIMIZE` environment
/// variable: set `OPTIMIZE=0` to bypass and return the input unchanged.
/// Any other value (or unset) engages the optimizer.
pub fn optimize(program: ir::Program) -> ir::Program {
let on = std::env::var("OPTIMIZE").map(|v| v != "0").unwrap_or(true);
if !on { return program; }
let mut o = opt::lift(&program);
o.optimize();
opt::lower(&o)
}

use parse::{Stmt, Expr};

Expand Down
Loading
Loading