Skip to content
Merged
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
18 changes: 15 additions & 3 deletions interactive/examples/ddir_col.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ mod render {
Node::Input(i) => {
nodes.insert(id, Rendered::Collection(inputs[*i].clone()));
},
Node::Import { name } => panic!("ddir_col: Import {:?} not supported in this harness (no trace registry).", name),
Node::Linear { input, ops } => {
let c = nodes[input].collection();
let ops = ops.clone();
Expand Down Expand Up @@ -305,10 +306,18 @@ fn run(name: &str, stmts: Vec<parse::Stmt>, n_inputs: usize, nodes: u64, edges:
let mut compiled: Program = lower::lower(stmts);
println!("{}: {} IR nodes (before optimize)", name, compiled.nodes.len());
compiled.optimize();
println!("{}: {} IR nodes (after optimize), result = {}", name, compiled.nodes.len(), compiled.result);
println!("{}: {} IR nodes (after optimize), exports = {:?}",
name, compiled.nodes.len(),
compiled.export.iter().map(|(n, id)| (n.as_str(), *id)).collect::<Vec<_>>());
compiled.dump();
let name = name.to_string();
let result_id = compiled.result;
let (driven_name, result_id) = {
let pick = compiled.export.iter().find(|(n, _)| n == "result")
.or_else(|| compiled.export.first())
.expect("ddir_col: program declares no exports");
(pick.0.clone(), pick.1)
};
println!("{}: driving export {:?} (id {})", name, driven_name, result_id);

timely::execute_from_args(std::env::args().skip(4), move |worker| {
use timely::dataflow::InputHandle;
Expand Down Expand Up @@ -412,7 +421,10 @@ fn main() {
} else {
parse::applicative::parse(&source)
};
let n_inputs = interactive::count_inputs(&stmts);
let (n_inputs, imports) = interactive::survey_sources(&stmts);
if !imports.is_empty() {
panic!("ddir_col: program references imports {:?} but this harness has no trace registry.", imports);
}
let name = std::path::Path::new(&program).file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or(program.clone());
run(&name, stmts, n_inputs, nodes, edges, arity, batch, rounds);
}
22 changes: 18 additions & 4 deletions interactive/examples/ddir_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ fn render_program<'scope>(program: &Program, scope: Scope<'scope, DdirTime>, inp
for (&id, node) in program.nodes.iter() {
match node {
Node::Input(i) => { nodes.insert(id, Rendered::Collection(inputs[*i].clone())); },
Node::Import { name } => panic!("ddir_vec: Import {:?} not supported in this harness (no trace registry).", name),
Node::Linear { input, ops } => {
use differential_dataflow::AsCollection;
use differential_dataflow::lattice::Lattice;
Expand Down Expand Up @@ -172,14 +173,24 @@ fn run(
// seeded from `QUERY=`.
if explain {
let input_arities = vec![(arity, 0usize); n_inputs];
compiled = interactive::explain::explain(&compiled, &input_arities);
let import_arities = std::collections::BTreeMap::new();
compiled = interactive::explain::explain(&compiled, &input_arities, &import_arities);
}
println!("{}: {} IR nodes (before optimize)", name, compiled.nodes.len());
compiled.optimize();
println!("{}: {} IR nodes (after optimize), result = {}", name, compiled.nodes.len(), compiled.result);
println!("{}: {} IR nodes (after optimize), exports = {:?}",
name, compiled.nodes.len(),
compiled.export.iter().map(|(n, id)| (n.as_str(), *id)).collect::<Vec<_>>());
compiled.dump();
let name = name.to_string();
let result_id = compiled.result;
// Drive one export: prefer `$result`, else the first declared.
let (driven_name, result_id) = {
let pick = compiled.export.iter().find(|(n, _)| n == "result")
.or_else(|| compiled.export.first())
.expect("ddir_vec: program declares no exports");
(pick.0.clone(), pick.1)
};
println!("{}: driving export {:?} (id {})", name, driven_name, result_id);
let total_inputs = if explain { n_inputs + 1 } else { n_inputs };
let query_input_idx = if explain { Some(n_inputs) } else { None };

Expand Down Expand Up @@ -297,7 +308,10 @@ fn main() {
} else {
parse::applicative::parse(&source)
};
let n_inputs = interactive::count_inputs(&stmts);
let (n_inputs, imports) = interactive::survey_sources(&stmts);
if !imports.is_empty() {
panic!("ddir_vec: program references imports {:?} but this harness has no trace registry.", imports);
}
let name = std::path::Path::new(&program).file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or(program.clone());
run(&name, stmts, n_inputs, nodes, edges, arity, batch, rounds, explain);
}
20 changes: 17 additions & 3 deletions interactive/examples/dump_explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() {
} else {
parse::applicative::parse(&source)
};
let n_inputs = interactive::count_inputs(&stmts);
let (n_inputs, imports) = interactive::survey_sources(&stmts);
let original = lower::lower(stmts);

println!("-- ====================================================");
Expand All @@ -32,7 +32,11 @@ fn main() {
print_ddp(&original);

let input_arities = vec![(arity, 0usize); n_inputs];
let rewritten = explain::explain(&original, &input_arities);
let import_arities: BTreeMap<String, (usize, usize)> = imports
.iter()
.map(|n| (n.clone(), (arity, 0usize)))
.collect();
let rewritten = explain::explain(&original, &input_arities, &import_arities);

println!();
println!("-- ====================================================");
Expand Down Expand Up @@ -85,6 +89,9 @@ fn print_ddp(p: &Program) {
Node::Input(i) => {
println!("{}let n{} = input {};", pad, id, i);
}
Node::Import { name } => {
println!("{}let n{} = import {:?};", pad, id, name);
}
Node::Linear { input, ops } => {
println!("{}let n{} = n{} | {};", pad, id, input, fmt_linear_ops(ops));
}
Expand Down Expand Up @@ -138,7 +145,14 @@ fn print_ddp(p: &Program) {
}
}
}
println!("{}result n{};", " ".repeat(indent), p.result);
let pad = " ".repeat(indent);
for (name, id) in &p.export {
if name == "result" {
println!("{}result n{};", pad, id);
} else {
println!("{}export {:?} = n{};", pad, name, id);
}
}
}

fn fmt_linear_ops(ops: &[LinearOp]) -> String {
Expand Down
2 changes: 1 addition & 1 deletion interactive/examples/programs/kcore.ddir
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ peel: {
}

let core_edges = CONCAT(symm, peel::removals);
result INSPECT(REDUCE(MAP(core_edges, ($0[0] ;)), COUNT), kcore_degrees);
export "result" = INSPECT(REDUCE(MAP(core_edges, ($0[0] ;)), COUNT), kcore_degrees);
2 changes: 1 addition & 1 deletion interactive/examples/programs/reach.ddir
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ reach: {
var reach = REDUCE(CONCAT(roots, proposals), DISTINCT);
}

result INSPECT(ARRANGE(MAP(reach::reach, (;))), total);
export "result" = INSPECT(ARRANGE(MAP(reach::reach, (;))), total);
2 changes: 1 addition & 1 deletion interactive/examples/programs/reach.ddp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ reach: {
var reach = roots + proposals | distinct;
}

result reach::reach | key(;) | arrange | inspect(total);
export "result" = reach::reach | key(;) | arrange | inspect(total);
2 changes: 1 addition & 1 deletion interactive/examples/programs/scc.ddir
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ outer: {
var scc_raw = CONCAT(trim_bwd, NEGATE(edges));
}

result INSPECT(ARRANGE(MAP(outer::scc, (;))), total);
export "result" = INSPECT(ARRANGE(MAP(outer::scc, (;))), total);
2 changes: 1 addition & 1 deletion interactive/examples/programs/scc.ddp
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ outer: {
var trim = trim_bwd - edges;
}

result outer::scc | map(;) | arrange | inspect(total);
export "result" = outer::scc | map(;) | arrange | inspect(total);
2 changes: 1 addition & 1 deletion interactive/examples/programs/stable.ddir
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ matching: {
var removals = ARRANGE(CONCAT(removals, by_a, NEGATE(props)));
}

result INSPECT(ARRANGE(MAP(matching::props, (;))), total);
export "result" = INSPECT(ARRANGE(MAP(matching::props, (;))), total);
2 changes: 1 addition & 1 deletion interactive/examples/programs/stable.ddp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ matching: {
var removals = removals + by_a - props | arrange;
}

result matching::props | key(;) | arrange | inspect(total);
export "result" = matching::props | key(;) | arrange | inspect(total);
Loading
Loading