Skip to content

Commit

Permalink
refactor(hydroflow_lang)!: change lattice_bimorphism to take state …
Browse files Browse the repository at this point in the history
…via singleton arguments hydro-project#969 hydro-project#1058 (hydro-project#1159)

BREAKING CHANGE: `lattice_bimorphism` ports renamed `items_0`->`0`, `items_1`->`1`
BREAKING CHANGE: `lattice_bimorphism` ports `state_0`, `state_1` removed, changed to use singleton references in the second and third argument positions
  • Loading branch information
MingweiSamuel committed Apr 15, 2024
1 parent 0429dca commit 9800955
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,70 @@ digraph {
n4v1 [label="(n4v1) source_iter_delta(3..5)", shape=invhouse, fillcolor="#88aaff"]
n5v1 [label="(n5v1) map(SetUnionSingletonSet::new_from)", shape=invhouse, fillcolor="#88aaff"]
n6v1 [label="(n6v1) state::<SetUnionHashSet<usize>>()", shape=invhouse, fillcolor="#88aaff"]
n7v1 [label="(n7v1) lattice_bimorphism(CartesianProductBimorphism::<HashSet<_>>::default())", 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"]
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 [color=darkgreen, style=dashed]
n1v1 -> n2v1 [color=darkgreen, style=dashed]
n5v1 -> n6v1 [color=darkgreen, style=dashed]
n4v1 -> n5v1 [color=darkgreen, style=dashed]
n3v1 -> n7v1 [label="items\nitems_0", color=darkgreen, style=bold]
n6v1 -> n7v1 [label="items\nitems_1", color=darkgreen, style=bold]
n3v1 -> n7v1 [label="state\nstate_0", color=darkgreen, style=bold]
n6v1 -> n7v1 [label="state\nstate_1", color=darkgreen, style=bold]
n3v1 -> n10v1 [label="items", color=darkgreen, style=bold]
n6v1 -> n11v1 [label="items", color=darkgreen, style=bold]
n8v1 -> n9v1 [color=darkgreen, style=bold]
n7v1 -> n10v1 [color=darkgreen, style=bold]
n10v1 -> n8v1 [color=red, style=bold]
n7v1 -> n12v1 [color=darkgreen, style=bold]
n10v1 -> n7v1 [label="0", color=darkgreen, style=bold]
n11v1 -> n7v1 [label="1", color=darkgreen, style=bold]
n12v1 -> n8v1 [color=red, style=bold]
n3v1 -> n7v1 [color=red]
n6v1 -> n7v1 [color=red]
subgraph "cluster n1v1" {
fillcolor="#dddddd"
style=filled
label = "sg_1v1\nstratum 0"
n1v1
n2v1
n3v1
n4v1
n5v1
n6v1
n7v1
subgraph "cluster_sg_1v1_var_lhs" {
label="var lhs"
n1v1
n2v1
n3v1
}
subgraph "cluster_sg_1v1_var_my_join" {
label="var my_join"
n7v1
}
subgraph "cluster_sg_1v1_var_rhs" {
}
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 n2v1" {
subgraph "cluster n3v1" {
fillcolor="#dddddd"
style=filled
label = "sg_2v1\nstratum 0"
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
subgraph "cluster_sg_2v1_var_my_join" {
subgraph "cluster_sg_4v1_var_my_join" {
label="var my_join"
n8v1
n9v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,55 @@ linkStyle default stroke:#aaa
4v1[\"(4v1) <code>source_iter_delta(3..5)</code>"/]:::pullClass
5v1[\"(5v1) <code>map(SetUnionSingletonSet::new_from)</code>"/]:::pullClass
6v1[\"(6v1) <code>state::&lt;SetUnionHashSet&lt;usize&gt;&gt;()</code>"/]:::pullClass
7v1[\"(7v1) <code>lattice_bimorphism(CartesianProductBimorphism::&lt;HashSet&lt;_&gt;&gt;::default())</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
10v1["(10v1) <code>handoff</code>"]:::otherClass
11v1["(11v1) <code>handoff</code>"]:::otherClass
12v1["(12v1) <code>handoff</code>"]:::otherClass
2v1-.->3v1; linkStyle 0 stroke:#060
1v1-.->2v1; linkStyle 1 stroke:#060
5v1-.->6v1; linkStyle 2 stroke:#060
4v1-.->5v1; linkStyle 3 stroke:#060
3v1==>|items<br>items_0|7v1; linkStyle 4 stroke:#060
6v1==>|items<br>items_1|7v1; linkStyle 5 stroke:#060
3v1==>|state<br>state_0|7v1; linkStyle 6 stroke:#060
6v1==>|state<br>state_1|7v1; linkStyle 7 stroke:#060
8v1==>9v1; linkStyle 8 stroke:#060
7v1==>10v1; linkStyle 9 stroke:#060
10v1==>8v1; linkStyle 10 stroke:#060
3v1==>|items|10v1; linkStyle 4 stroke:#060
6v1==>|items|11v1; linkStyle 5 stroke:#060
8v1==>9v1; linkStyle 6 stroke:#060
7v1==>12v1; linkStyle 7 stroke:#060
10v1==>|0|7v1; linkStyle 8 stroke:#060
11v1==>|1|7v1; linkStyle 9 stroke:#060
12v1==>8v1; linkStyle 10 stroke:#060
3v1--x7v1; linkStyle 11 stroke:red
6v1--x7v1; linkStyle 12 stroke:red
subgraph sg_1v1 ["sg_1v1 stratum 0"]
1v1
2v1
3v1
4v1
5v1
6v1
7v1
subgraph sg_1v1_var_lhs ["var <tt>lhs</tt>"]
1v1
2v1
3v1
end
subgraph sg_1v1_var_my_join ["var <tt>my_join</tt>"]
7v1
end
subgraph sg_1v1_var_rhs ["var <tt>rhs</tt>"]
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_2v1 ["sg_2v1 stratum 0"]
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
subgraph sg_2v1_var_my_join ["var <tt>my_join</tt>"]
subgraph sg_4v1_var_my_join ["var <tt>my_join</tt>"]
8v1
9v1
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,70 @@ digraph {
n4v1 [label="(n4v1) source_iter_delta([(7, 0), (7, 1), (7, 2)])", shape=invhouse, fillcolor="#88aaff"]
n5v1 [label="(n5v1) map(|(k, v)| MapUnionSingletonMap::new_from((k, SetUnionSingletonSet::new_from(v))))", shape=invhouse, fillcolor="#88aaff"]
n6v1 [label="(n6v1) state::<MapUnionHashMap<usize, SetUnionHashSet<usize>>>()", shape=invhouse, fillcolor="#88aaff"]
n7v1 [label="(n7v1) lattice_bimorphism(\l KeyedBimorphism::<\l HashMap<_, _>,\l _,\l >::from(CartesianProductBimorphism::<HashSet<_>>::default()),\l)\l", shape=invhouse, fillcolor="#88aaff"]
n7v1 [label="(n7v1) lattice_bimorphism(\l KeyedBimorphism::<\l HashMap<_, _>,\l _,\l >::from(CartesianProductBimorphism::<HashSet<_>>::default()),\l lhs,\l rhs,\l)\l", 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"]
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 [color=darkgreen, style=dashed]
n1v1 -> n2v1 [color=darkgreen, style=dashed]
n5v1 -> n6v1 [color=darkgreen, style=dashed]
n4v1 -> n5v1 [color=darkgreen, style=dashed]
n3v1 -> n7v1 [label="items\nitems_0", color=darkgreen, style=bold]
n6v1 -> n7v1 [label="items\nitems_1", color=darkgreen, style=bold]
n3v1 -> n7v1 [label="state\nstate_0", color=darkgreen, style=bold]
n6v1 -> n7v1 [label="state\nstate_1", color=darkgreen, style=bold]
n3v1 -> n10v1 [label="items", color=darkgreen, style=bold]
n6v1 -> n11v1 [label="items", color=darkgreen, style=bold]
n8v1 -> n9v1 [color=darkgreen, style=bold]
n7v1 -> n10v1 [color=darkgreen, style=bold]
n10v1 -> n8v1 [color=red, style=bold]
n7v1 -> n12v1 [color=darkgreen, style=bold]
n10v1 -> n7v1 [label="0", color=darkgreen, style=bold]
n11v1 -> n7v1 [label="1", color=darkgreen, style=bold]
n12v1 -> n8v1 [color=red, style=bold]
n3v1 -> n7v1 [color=red]
n6v1 -> n7v1 [color=red]
subgraph "cluster n1v1" {
fillcolor="#dddddd"
style=filled
label = "sg_1v1\nstratum 0"
n1v1
n2v1
n3v1
n4v1
n5v1
n6v1
n7v1
subgraph "cluster_sg_1v1_var_lhs" {
label="var lhs"
n1v1
n2v1
n3v1
}
subgraph "cluster_sg_1v1_var_my_join" {
label="var my_join"
n7v1
}
subgraph "cluster_sg_1v1_var_rhs" {
}
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 n2v1" {
subgraph "cluster n3v1" {
fillcolor="#dddddd"
style=filled
label = "sg_2v1\nstratum 0"
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
subgraph "cluster_sg_2v1_var_my_join" {
subgraph "cluster_sg_4v1_var_my_join" {
label="var my_join"
n8v1
n9v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,55 @@ linkStyle default stroke:#aaa
4v1[\"(4v1) <code>source_iter_delta([(7, 0), (7, 1), (7, 2)])</code>"/]:::pullClass
5v1[\"(5v1) <code>map(|(k, v)| MapUnionSingletonMap::new_from((k, SetUnionSingletonSet::new_from(v))))</code>"/]:::pullClass
6v1[\"(6v1) <code>state::&lt;MapUnionHashMap&lt;usize, SetUnionHashSet&lt;usize&gt;&gt;&gt;()</code>"/]:::pullClass
7v1[\"<div style=text-align:center>(7v1)</div> <code>lattice_bimorphism(<br> KeyedBimorphism::&lt;<br> HashMap&lt;_, _&gt;,<br> _,<br> &gt;::from(CartesianProductBimorphism::&lt;HashSet&lt;_&gt;&gt;::default()),<br>)</code>"/]:::pullClass
7v1[\"<div style=text-align:center>(7v1)</div> <code>lattice_bimorphism(<br> KeyedBimorphism::&lt;<br> HashMap&lt;_, _&gt;,<br> _,<br> &gt;::from(CartesianProductBimorphism::&lt;HashSet&lt;_&gt;&gt;::default()),<br> lhs,<br> rhs,<br>)</code>"/]:::pullClass
8v1[\"(8v1) <code>lattice_reduce()</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
2v1-.->3v1; linkStyle 0 stroke:#060
1v1-.->2v1; linkStyle 1 stroke:#060
5v1-.->6v1; linkStyle 2 stroke:#060
4v1-.->5v1; linkStyle 3 stroke:#060
3v1==>|items<br>items_0|7v1; linkStyle 4 stroke:#060
6v1==>|items<br>items_1|7v1; linkStyle 5 stroke:#060
3v1==>|state<br>state_0|7v1; linkStyle 6 stroke:#060
6v1==>|state<br>state_1|7v1; linkStyle 7 stroke:#060
8v1==>9v1; linkStyle 8 stroke:#060
7v1==>10v1; linkStyle 9 stroke:#060
10v1==>8v1; linkStyle 10 stroke:#060
3v1==>|items|10v1; linkStyle 4 stroke:#060
6v1==>|items|11v1; linkStyle 5 stroke:#060
8v1==>9v1; linkStyle 6 stroke:#060
7v1==>12v1; linkStyle 7 stroke:#060
10v1==>|0|7v1; linkStyle 8 stroke:#060
11v1==>|1|7v1; linkStyle 9 stroke:#060
12v1==>8v1; linkStyle 10 stroke:#060
3v1--x7v1; linkStyle 11 stroke:red
6v1--x7v1; linkStyle 12 stroke:red
subgraph sg_1v1 ["sg_1v1 stratum 0"]
1v1
2v1
3v1
4v1
5v1
6v1
7v1
subgraph sg_1v1_var_lhs ["var <tt>lhs</tt>"]
1v1
2v1
3v1
end
subgraph sg_1v1_var_my_join ["var <tt>my_join</tt>"]
7v1
end
subgraph sg_1v1_var_rhs ["var <tt>rhs</tt>"]
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_2v1 ["sg_2v1 stratum 0"]
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
subgraph sg_2v1_var_my_join ["var <tt>my_join</tt>"]
subgraph sg_4v1_var_my_join ["var <tt>my_join</tt>"]
8v1
9v1
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ digraph {
n1v1 [label="(n1v1) source_iter(1..=10)", shape=invhouse, fillcolor="#88aaff"]
n2v1 [label="(n2v1) source_iter_delta(3..=5)", shape=invhouse, fillcolor="#88aaff"]
n3v1 [label="(n3v1) map(Max::new)", shape=invhouse, fillcolor="#88aaff"]
n4v1 [label="(n4v1) state_ref::<Max<_>>()", shape=invhouse, fillcolor="#88aaff"]
n4v1 [label="(n4v1) state::<Max<_>>()", shape=invhouse, fillcolor="#88aaff"]
n5v1 [label="(n5v1) filter(|value| { value <= max_of_stream2.as_reveal_ref() })", shape=invhouse, fillcolor="#88aaff"]
n6v1 [label="(n6v1) map(|x| (context.current_tick(), x))", shape=invhouse, fillcolor="#88aaff"]
n7v1 [label="(n7v1) for_each(|x| filter_send.send(x).unwrap())", shape=house, fillcolor="#ffff88"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ linkStyle default stroke:#aaa
1v1[\"(1v1) <code>source_iter(1..=10)</code>"/]:::pullClass
2v1[\"(2v1) <code>source_iter_delta(3..=5)</code>"/]:::pullClass
3v1[\"(3v1) <code>map(Max::new)</code>"/]:::pullClass
4v1[\"(4v1) <code>state_ref::&lt;Max&lt;_&gt;&gt;()</code>"/]:::pullClass
4v1[\"(4v1) <code>state::&lt;Max&lt;_&gt;&gt;()</code>"/]:::pullClass
5v1[\"(5v1) <code>filter(|value| { value &lt;= max_of_stream2.as_reveal_ref() })</code>"/]:::pullClass
6v1[\"(6v1) <code>map(|x| (context.current_tick(), x))</code>"/]:::pullClass
7v1[/"(7v1) <code>for_each(|x| filter_send.send(x).unwrap())</code>"\]:::pushClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ digraph {
edge [fontname="Monaco,Menlo,Consolas,&quot;Droid Sans Mono&quot;,Inconsolata,&quot;Courier New&quot;,monospace"];
n1v1 [label="(n1v1) source_iter_delta(15..=25)", shape=invhouse, fillcolor="#88aaff"]
n2v1 [label="(n2v1) map(Max::new)", shape=invhouse, fillcolor="#88aaff"]
n3v1 [label="(n3v1) state_ref::<Max<_>>()", shape=house, fillcolor="#ffff88"]
n3v1 [label="(n3v1) state::<Max<_>>()", shape=house, fillcolor="#ffff88"]
n1v1 -> n2v1 [color=darkgreen, style=dashed]
n2v1 -> n3v1 [color=darkgreen, style=dashed]
subgraph "cluster n1v1" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ classDef otherClass fill:#fdc,stroke:#000,text-align:left,white-space:pre
linkStyle default stroke:#aaa
1v1[\"(1v1) <code>source_iter_delta(15..=25)</code>"/]:::pullClass
2v1[\"(2v1) <code>map(Max::new)</code>"/]:::pullClass
3v1[/"(3v1) <code>state_ref::&lt;Max&lt;_&gt;&gt;()</code>"\]:::pushClass
3v1[/"(3v1) <code>state::&lt;Max&lt;_&gt;&gt;()</code>"\]:::pushClass
1v1-.->2v1; linkStyle 0 stroke:#060
2v1-.->3v1; linkStyle 1 stroke:#060
subgraph sg_1v1 ["sg_1v1 stratum 0"]
Expand Down
16 changes: 6 additions & 10 deletions hydroflow/tests/surface_lattice_bimorphism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ pub fn test_cartesian_product() {
-> map(SetUnionSingletonSet::new_from)
-> state::<SetUnionHashSet<usize>>();

lhs[items] -> [items_0]my_join;
rhs[items] -> [items_1]my_join;
lhs[state] -> [state_0]my_join;
rhs[state] -> [state_1]my_join;
lhs[items] -> [0]my_join;
rhs[items] -> [1]my_join;

my_join = lattice_bimorphism(CartesianProductBimorphism::<HashSet<_>>::default())
my_join = lattice_bimorphism(CartesianProductBimorphism::<HashSet<_>>::default(), #lhs, #rhs)
-> lattice_reduce()
-> for_each(|x| out_send.send(x).unwrap());
};
Expand Down Expand Up @@ -56,12 +54,10 @@ pub fn test_join() {
-> map(|(k, v)| MapUnionSingletonMap::new_from((k, SetUnionSingletonSet::new_from(v))))
-> state::<MapUnionHashMap<usize, SetUnionHashSet<usize>>>();

lhs[items] -> [items_0]my_join;
rhs[items] -> [items_1]my_join;
lhs[state] -> [state_0]my_join;
rhs[state] -> [state_1]my_join;
lhs[items] -> [0]my_join;
rhs[items] -> [1]my_join;

my_join = lattice_bimorphism(KeyedBimorphism::<HashMap<_, _>, _>::from(CartesianProductBimorphism::<HashSet<_>>::default()))
my_join = lattice_bimorphism(KeyedBimorphism::<HashMap<_, _>, _>::from(CartesianProductBimorphism::<HashSet<_>>::default()), #lhs, #rhs)
-> lattice_reduce()
-> for_each(|x| out_send.send(x).unwrap());
};
Expand Down
Loading

0 comments on commit 9800955

Please sign in to comment.