Skip to content

Commit

Permalink
fix(hydroflow_lang)!: fix #1401 lattice_bimorphism() double-emit, a…
Browse files Browse the repository at this point in the history
…dd docs (#1522)

Fixes the issue by combining the all values generated per subgraph
execution into one, which effectively de-duplicates the values.

Adds basic docs.

BREAKING CHANGE: changes exact behavior of `lattice_bimorphism()`,
instead of emitting multiple items, will emit a single item which is the
merge of what would've been all the old outputs. `Output: Merge<Output>`
is a new required bound.
  • Loading branch information
MingweiSamuel authored Nov 6, 2024
1 parent 2faffdb commit e796200
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@ digraph {
n5v1 [label="(n5v1) map(SetUnionSingletonSet::new_from)", shape=invhouse, fillcolor="#88aaff"]
n6v1 [label="(n6v1) state::<'static, SetUnionHashSet<u32>>()", shape=invhouse, fillcolor="#88aaff"]
n7v1 [label="(n7v1) lattice_bimorphism(CartesianProductBimorphism::<HashSet<_>>::default(), lhs, rhs)", shape=invhouse, fillcolor="#88aaff"]
n8v1 [label="(n8v1) lattice_reduce()", shape=invhouse, fillcolor="#88aaff"]
n9v1 [label="(n9v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"]
n8v1 [label="(n8v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"]
n9v1 [label="(n9v1) handoff", shape=parallelogram, fillcolor="#ddddff"]
n10v1 [label="(n10v1) handoff", shape=parallelogram, fillcolor="#ddddff"]
n11v1 [label="(n11v1) handoff", shape=parallelogram, fillcolor="#ddddff"]
n12v1 [label="(n12v1) handoff", shape=parallelogram, fillcolor="#ddddff"]
n2v1 -> n3v1
n1v1 -> n2v1
n5v1 -> n6v1
n4v1 -> n5v1
n3v1 -> n10v1
n6v1 -> n11v1
n8v1 -> n9v1
n7v1 -> n12v1
n10v1 -> n7v1 [label="0"]
n11v1 -> n7v1 [label="1"]
n12v1 -> n8v1 [color=red]
n3v1 -> n9v1
n6v1 -> n10v1
n7v1 -> n8v1
n9v1 -> n7v1 [label="0"]
n10v1 -> n7v1 [label="1"]
n3v1 -> n7v1 [color=red]
n6v1 -> n7v1 [color=red]
subgraph "cluster n1v1" {
Expand Down Expand Up @@ -63,21 +59,11 @@ digraph {
style=filled
label = "sg_3v1\nstratum 1"
n7v1
n8v1
subgraph "cluster_sg_3v1_var_my_join" {
label="var my_join"
n7v1
}
}
subgraph "cluster n4v1" {
fillcolor="#dddddd"
style=filled
label = "sg_4v1\nstratum 1"
n8v1
n9v1
subgraph "cluster_sg_4v1_var_my_join" {
label="var my_join"
n8v1
n9v1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,20 @@ linkStyle default stroke:#aaa
5v1[\"(5v1) <code>map(SetUnionSingletonSet::new_from)</code>"/]:::pullClass
6v1[\"(6v1) <code>state::&lt;'static, SetUnionHashSet&lt;u32&gt;&gt;()</code>"/]:::pullClass
7v1[\"(7v1) <code>lattice_bimorphism(CartesianProductBimorphism::&lt;HashSet&lt;_&gt;&gt;::default(), lhs, rhs)</code>"/]:::pullClass
8v1[\"(8v1) <code>lattice_reduce()</code>"/]:::pullClass
9v1[/"(9v1) <code>for_each(|x| out_send.send(x).unwrap())</code>"\]:::pushClass
8v1[/"(8v1) <code>for_each(|x| out_send.send(x).unwrap())</code>"\]:::pushClass
9v1["(9v1) <code>handoff</code>"]:::otherClass
10v1["(10v1) <code>handoff</code>"]:::otherClass
11v1["(11v1) <code>handoff</code>"]:::otherClass
12v1["(12v1) <code>handoff</code>"]:::otherClass
2v1-->3v1
1v1-->2v1
5v1-->6v1
4v1-->5v1
3v1-->10v1
6v1-->11v1
8v1-->9v1
7v1-->12v1
10v1-->|0|7v1
11v1-->|1|7v1
12v1-->8v1; linkStyle 10 stroke:#060
3v1--x7v1; linkStyle 11 stroke:red
6v1--x7v1; linkStyle 12 stroke:red
3v1-->9v1
6v1-->10v1
7v1-->8v1
9v1-->|0|7v1
10v1-->|1|7v1
3v1--x7v1; linkStyle 9 stroke:red
6v1--x7v1; linkStyle 10 stroke:red
subgraph sg_1v1 ["sg_1v1 stratum 0"]
1v1
2v1
Expand All @@ -55,15 +51,9 @@ subgraph sg_2v1 ["sg_2v1 stratum 0"]
end
subgraph sg_3v1 ["sg_3v1 stratum 1"]
7v1
8v1
subgraph sg_3v1_var_my_join ["var <tt>my_join</tt>"]
7v1
end
end
subgraph sg_4v1 ["sg_4v1 stratum 1"]
8v1
9v1
subgraph sg_4v1_var_my_join ["var <tt>my_join</tt>"]
8v1
9v1
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
source: hydroflow/tests/surface_lattice_bimorphism.rs
expression: "df.meta_graph().unwrap().to_dot(& Default :: default())"
---
digraph {
node [fontname="Monaco,Menlo,Consolas,&quot;Droid Sans Mono&quot;,Inconsolata,&quot;Courier New&quot;,monospace", style=filled];
edge [fontname="Monaco,Menlo,Consolas,&quot;Droid Sans Mono&quot;,Inconsolata,&quot;Courier New&quot;,monospace"];
n1v1 [label="(n1v1) source_iter(0..1)", shape=invhouse, fillcolor="#88aaff"]
n2v1 [label="(n2v1) map(SetUnionSingletonSet::new_from)", shape=invhouse, fillcolor="#88aaff"]
n3v1 [label="(n3v1) state::<'static, SetUnionHashSet<u32>>()", shape=invhouse, fillcolor="#88aaff"]
n4v1 [label="(n4v1) source_iter(1..2)", shape=invhouse, fillcolor="#88aaff"]
n5v1 [label="(n5v1) map(SetUnionSingletonSet::new_from)", shape=invhouse, fillcolor="#88aaff"]
n6v1 [label="(n6v1) state::<'static, SetUnionHashSet<u32>>()", shape=invhouse, fillcolor="#88aaff"]
n7v1 [label="(n7v1) lattice_bimorphism(CartesianProductBimorphism::<HashSet<_>>::default(), lhs, rhs)", shape=invhouse, fillcolor="#88aaff"]
n8v1 [label="(n8v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"]
n9v1 [label="(n9v1) handoff", shape=parallelogram, fillcolor="#ddddff"]
n10v1 [label="(n10v1) handoff", shape=parallelogram, fillcolor="#ddddff"]
n2v1 -> n3v1
n1v1 -> n2v1
n5v1 -> n6v1
n4v1 -> n5v1
n3v1 -> n9v1
n6v1 -> n10v1
n7v1 -> n8v1
n9v1 -> n7v1 [label="0"]
n10v1 -> n7v1 [label="1"]
n3v1 -> n7v1 [color=red]
n6v1 -> n7v1 [color=red]
subgraph "cluster n1v1" {
fillcolor="#dddddd"
style=filled
label = "sg_1v1\nstratum 0"
n1v1
n2v1
n3v1
subgraph "cluster_sg_1v1_var_lhs" {
label="var lhs"
n1v1
n2v1
n3v1
}
}
subgraph "cluster n2v1" {
fillcolor="#dddddd"
style=filled
label = "sg_2v1\nstratum 0"
n4v1
n5v1
n6v1
subgraph "cluster_sg_2v1_var_rhs" {
label="var rhs"
n4v1
n5v1
n6v1
}
}
subgraph "cluster n3v1" {
fillcolor="#dddddd"
style=filled
label = "sg_3v1\nstratum 1"
n7v1
n8v1
subgraph "cluster_sg_3v1_var_my_join" {
label="var my_join"
n7v1
n8v1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
source: hydroflow/tests/surface_lattice_bimorphism.rs
expression: "df.meta_graph().unwrap().to_mermaid(& Default :: default())"
---
%%{init:{'theme':'base','themeVariables':{'clusterBkg':'#ddd','clusterBorder':'#888'}}}%%
flowchart TD
classDef pullClass fill:#8af,stroke:#000,text-align:left,white-space:pre
classDef pushClass fill:#ff8,stroke:#000,text-align:left,white-space:pre
classDef otherClass fill:#fdc,stroke:#000,text-align:left,white-space:pre
linkStyle default stroke:#aaa
1v1[\"(1v1) <code>source_iter(0..1)</code>"/]:::pullClass
2v1[\"(2v1) <code>map(SetUnionSingletonSet::new_from)</code>"/]:::pullClass
3v1[\"(3v1) <code>state::&lt;'static, SetUnionHashSet&lt;u32&gt;&gt;()</code>"/]:::pullClass
4v1[\"(4v1) <code>source_iter(1..2)</code>"/]:::pullClass
5v1[\"(5v1) <code>map(SetUnionSingletonSet::new_from)</code>"/]:::pullClass
6v1[\"(6v1) <code>state::&lt;'static, SetUnionHashSet&lt;u32&gt;&gt;()</code>"/]:::pullClass
7v1[\"(7v1) <code>lattice_bimorphism(CartesianProductBimorphism::&lt;HashSet&lt;_&gt;&gt;::default(), lhs, rhs)</code>"/]:::pullClass
8v1[/"(8v1) <code>for_each(|x| out_send.send(x).unwrap())</code>"\]:::pushClass
9v1["(9v1) <code>handoff</code>"]:::otherClass
10v1["(10v1) <code>handoff</code>"]:::otherClass
2v1-->3v1
1v1-->2v1
5v1-->6v1
4v1-->5v1
3v1-->9v1
6v1-->10v1
7v1-->8v1
9v1-->|0|7v1
10v1-->|1|7v1
3v1--x7v1; linkStyle 9 stroke:red
6v1--x7v1; linkStyle 10 stroke:red
subgraph sg_1v1 ["sg_1v1 stratum 0"]
1v1
2v1
3v1
subgraph sg_1v1_var_lhs ["var <tt>lhs</tt>"]
1v1
2v1
3v1
end
end
subgraph sg_2v1 ["sg_2v1 stratum 0"]
4v1
5v1
6v1
subgraph sg_2v1_var_rhs ["var <tt>rhs</tt>"]
4v1
5v1
6v1
end
end
subgraph sg_3v1 ["sg_3v1 stratum 1"]
7v1
8v1
subgraph sg_3v1_var_my_join ["var <tt>my_join</tt>"]
7v1
8v1
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,20 @@ digraph {
n5v1 [label="(n5v1) map(SetUnionSingletonSet::new_from)", shape=invhouse, fillcolor="#88aaff"]
n6v1 [label="(n6v1) state::<'tick, SetUnionHashSet<u32>>()", shape=invhouse, fillcolor="#88aaff"]
n7v1 [label="(n7v1) lattice_bimorphism(CartesianProductBimorphism::<HashSet<_>>::default(), lhs, rhs)", shape=invhouse, fillcolor="#88aaff"]
n8v1 [label="(n8v1) lattice_reduce()", shape=invhouse, fillcolor="#88aaff"]
n9v1 [label="(n9v1) inspect(|x| println!(\"{:?}: {:?}\", context.current_tick(), x))", shape=invhouse, fillcolor="#88aaff"]
n10v1 [label="(n10v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"]
n8v1 [label="(n8v1) inspect(|x| println!(\"{:?}: {:?}\", context.current_tick(), x))", shape=invhouse, fillcolor="#88aaff"]
n9v1 [label="(n9v1) for_each(|x| out_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"]
n10v1 [label="(n10v1) handoff", shape=parallelogram, fillcolor="#ddddff"]
n11v1 [label="(n11v1) handoff", shape=parallelogram, fillcolor="#ddddff"]
n12v1 [label="(n12v1) handoff", shape=parallelogram, fillcolor="#ddddff"]
n13v1 [label="(n13v1) handoff", shape=parallelogram, fillcolor="#ddddff"]
n2v1 -> n3v1
n1v1 -> n2v1
n5v1 -> n6v1
n4v1 -> n5v1
n3v1 -> n11v1 [label="items"]
n6v1 -> n12v1 [label="items"]
n9v1 -> n10v1
n3v1 -> n10v1 [label="items"]
n6v1 -> n11v1 [label="items"]
n8v1 -> n9v1
n7v1 -> n13v1
n11v1 -> n7v1 [label="0"]
n12v1 -> n7v1 [label="1"]
n13v1 -> n8v1 [color=red]
n7v1 -> n8v1
n10v1 -> n7v1 [label="0"]
n11v1 -> n7v1 [label="1"]
n3v1 -> n7v1 [color=red]
n6v1 -> n7v1 [color=red]
subgraph "cluster n1v1" {
Expand Down Expand Up @@ -65,24 +61,13 @@ digraph {
style=filled
label = "sg_3v1\nstratum 1"
n7v1
subgraph "cluster_sg_3v1_var_my_join" {
label="var my_join"
n7v1
}
}
subgraph "cluster n4v1" {
fillcolor="#dddddd"
style=filled
label = "sg_4v1\nstratum 1"
n8v1
n9v1
n10v1
subgraph "cluster_sg_4v1_var_my_join" {
subgraph "cluster_sg_3v1_var_my_join" {
label="var my_join"
n7v1
n8v1
n9v1
n10v1
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,22 @@ linkStyle default stroke:#aaa
5v1[\"(5v1) <code>map(SetUnionSingletonSet::new_from)</code>"/]:::pullClass
6v1[\"(6v1) <code>state::&lt;'tick, SetUnionHashSet&lt;u32&gt;&gt;()</code>"/]:::pullClass
7v1[\"(7v1) <code>lattice_bimorphism(CartesianProductBimorphism::&lt;HashSet&lt;_&gt;&gt;::default(), lhs, rhs)</code>"/]:::pullClass
8v1[\"(8v1) <code>lattice_reduce()</code>"/]:::pullClass
9v1[\"(9v1) <code>inspect(|x| println!(&quot;{:?}: {:?}&quot;, context.current_tick(), x))</code>"/]:::pullClass
10v1[/"(10v1) <code>for_each(|x| out_send.send(x).unwrap())</code>"\]:::pushClass
8v1[\"(8v1) <code>inspect(|x| println!(&quot;{:?}: {:?}&quot;, context.current_tick(), x))</code>"/]:::pullClass
9v1[/"(9v1) <code>for_each(|x| out_send.send(x).unwrap())</code>"\]:::pushClass
10v1["(10v1) <code>handoff</code>"]:::otherClass
11v1["(11v1) <code>handoff</code>"]:::otherClass
12v1["(12v1) <code>handoff</code>"]:::otherClass
13v1["(13v1) <code>handoff</code>"]:::otherClass
2v1-->3v1
1v1-->2v1
5v1-->6v1
4v1-->5v1
3v1-->|items|11v1
6v1-->|items|12v1
9v1-->10v1
3v1-->|items|10v1
6v1-->|items|11v1
8v1-->9v1
7v1-->13v1
11v1-->|0|7v1
12v1-->|1|7v1
13v1-->8v1; linkStyle 11 stroke:#060
3v1--x7v1; linkStyle 12 stroke:red
6v1--x7v1; linkStyle 13 stroke:red
7v1-->8v1
10v1-->|0|7v1
11v1-->|1|7v1
3v1--x7v1; linkStyle 10 stroke:red
6v1--x7v1; linkStyle 11 stroke:red
subgraph sg_1v1 ["sg_1v1 stratum 0"]
1v1
2v1
Expand All @@ -57,18 +53,11 @@ subgraph sg_2v1 ["sg_2v1 stratum 0"]
end
subgraph sg_3v1 ["sg_3v1 stratum 1"]
7v1
subgraph sg_3v1_var_my_join ["var <tt>my_join</tt>"]
7v1
end
end
subgraph sg_4v1 ["sg_4v1 stratum 1"]
8v1
9v1
10v1
subgraph sg_4v1_var_my_join ["var <tt>my_join</tt>"]
subgraph sg_3v1_var_my_join ["var <tt>my_join</tt>"]
7v1
8v1
9v1
10v1
end
end

Loading

0 comments on commit e796200

Please sign in to comment.