Skip to content

Commit

Permalink
Ch. 17: create a diagram showing blocked parallelism
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskrycho committed Oct 7, 2024
1 parent 8f63245 commit 3111eda
Show file tree
Hide file tree
Showing 11 changed files with 348 additions and 220 deletions.
35 changes: 24 additions & 11 deletions dot/trpl17-03.dot
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
digraph {
rankdir = RL;
overlap = false;
dpi = 300.0;

rankdir = "LR";
splines = false;
cluster = true;

node [shape = "plaintext";];
node [shape = diamond;];

// The graphs end up with the correct order, i.e. Task 1 *above* Task 2, when
// this is first.
subgraph cluster_ColleagueB {
label = "Task A";
A1;
A2;
A0_1 [style = invis;];
A3;

A1 -> A2;
A2 -> A0_1 [arrowhead = "tee"; headport = "A0_1:c"; headclip = false;];
A0_1;
A0_1 -> A3 [dir = both; arrowtail = "tee"; tailclip = false;];
}

fut1 [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td sides="B">fut1</td></tr>
<tr><td>0</td></tr>
<tr><td port="target">1</td></tr>
<tr><td port="source"> </td></tr>
</table>>;];
subgraph cluster_ColleagueA {
newrank = true;
label = "Task B";
B1 -> B2 -> B3 -> B4;
}

edge [tailclip = "false";];
fut1:source:c -> fut1:target [dir = forward;];
B3 -> A3;
}
31 changes: 9 additions & 22 deletions dot/trpl17-04.dot
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,13 @@ digraph {

node [shape = "plaintext";];

// Group the two together, which results in the desired alignment.
subgraph {
// But don't show the frame!
style = "invis";

fut1 [label = <<table border="0" cellborder="1" cellspacing="0" bgcolor="gray">
<tr><td sides="B">fut1</td></tr>
<tr><td>?</td></tr>
<tr><td port="target">?</td></tr>
<tr><td>?</td></tr>
</table>>;];

fut2 [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td sides="B">fut2</td></tr>
<tr><td>0</td></tr>
<tr><td>1</td></tr>
<tr><td port="source"> </td></tr>
</table>>;];

edge [tailclip = "false"; dir = forward];
fut2:source:c -> fut1:target:e;
}
fut1 [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td sides="B">fut1</td></tr>
<tr><td>0</td></tr>
<tr><td port="target">1</td></tr>
<tr><td port="source"> </td></tr>
</table>>;];

edge [tailclip = "false";];
fut1:source:c -> fut1:target [dir = forward;];
}
52 changes: 21 additions & 31 deletions dot/trpl17-05.dot
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
digraph {
rankdir = LR;
rankdir = RL;
overlap = false;
dpi = 300.0;
splines = false;
cluster = true;

node [shape = "plaintext";];

pinned_box [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td sides="B">Pin</td></tr>
<tr><td port="source"> </td></tr>
</table>>;];

subgraph cluster_box {
label = "";
peripheries = 0;
// Group the two together, which results in the desired alignment.
subgraph {
// But don't show the frame!
style = "invis";

subgraph cluster_box_internal {
peripheries = 1;
label = "b1";
shape = box;
style = solid;
pin [shape = "point";];
}
}

subgraph cluster_deref {
style = bold;
label = "pinned";
fut1 [label = <<table border="0" cellborder="1" cellspacing="0" bgcolor="gray">
<tr><td sides="B">fut1</td></tr>
<tr><td>?</td></tr>
<tr><td port="target">?</td></tr>
<tr><td>?</td></tr>
</table>>;];

box [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td sides="B">fut</td></tr>
<tr><td port="target">0</td></tr>
fut2 [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td sides="B">fut2</td></tr>
<tr><td>0</td></tr>
<tr><td>1</td></tr>
<tr><td port="source"> </td></tr>
<tr><td style="dashed">...</td></tr>
<tr><td port="internal">1</td></tr>
</table>>;];

edge [tailclip = "false"; dir = forward];
fut2:source:c -> fut1:target:e;
}

edge [tailclip = false;];
pinned_box -> pin [tailport = "source:c"; arrowhead = "none";];
pin -> box [headport = "target";];
box -> box [tailport = "source:c"; headport = "internal";];
}
58 changes: 18 additions & 40 deletions dot/trpl17-06.dot
Original file line number Diff line number Diff line change
@@ -1,50 +1,32 @@
digraph {
rankdir = LR;
newrank = true;
dpi = 300.0;

node [shape = "plaintext";];

pinned_box [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td sides="B">Pin</td></tr>
<tr><td port="source"> </td></tr>
</table>>;];

subgraph cluster_not_fut {
subgraph cluster_box {
label = "";
peripheries = 0;

pin [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td sides="B">Pin</td></tr>
<tr><td port="source"> </td></tr>
</table>>;];

subgraph cluster_boxes {
peripheries = 0;
rank = same;

subgraph cluster_box_1 {
subgraph cluster_box_2_internal {
label = "b1";
shape = box;
style = solid;
style = filled;
peripheries = 1;
box1 [shape = "point";style = "invis";];
}
}

subgraph cluster_box_2 {
subgraph cluster_box_2_internal {
label = "b2";
shape = box;
style = solid;
peripheries = 1;
box2 [shape = "point";];
}
}
subgraph cluster_box_internal {
peripheries = 1;
label = "b1";
shape = box;
style = solid;
pin [shape = "point";];
}
}
subgraph cluster_target {

subgraph cluster_deref {
style = bold;
label = "pinned";

fut [label = <<table border="0" cellborder="1" cellspacing="0">
box [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td sides="B">fut</td></tr>
<tr><td port="target">0</td></tr>
<tr><td port="source"> </td></tr>
Expand All @@ -53,12 +35,8 @@ digraph {
</table>>;];
}


box1 -> box2 [rankdir = TB; style = invis;];

edge [tailclip = false;];
pin -> box1 [style = "invis";];
pin -> box2 [tailport = "source:c"; arrowhead = "none";];
box2 -> fut [headport = "target";];
fut -> fut [tailport = "source:c"; headport = "internal";];
pinned_box -> pin [tailport = "source:c"; arrowhead = "none";];
pin -> box [headport = "target";];
box -> box [tailport = "source:c"; headport = "internal";];
}
73 changes: 49 additions & 24 deletions dot/trpl17-07.dot
Original file line number Diff line number Diff line change
@@ -1,39 +1,64 @@
digraph {
rankdir = LR;
overlap = false;
dpi = 300.0;
splines = false;
cluster = true;
newrank = true;
outputorder = in;
compound = true;
labelloc = "c";
dpi = 300.0;

node [shape = "plaintext";];

pinned_box [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td sides="B">Pin</td></tr>
<tr><td port="source"> </td></tr>
</table>>;];


subgraph cluster_deref {
style = dashed;
label = "String";
subgraph cluster_not_fut {
peripheries = 0;

pin [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td sides="B">Pin</td></tr>
<tr><td port="source"> </td></tr>
</table>>;];

pin [shape = "point";];
subgraph cluster_boxes {
peripheries = 0;
rank = same;

subgraph cluster_box_1 {
subgraph cluster_box_2_internal {
label = "b1";
shape = box;
style = solid;
style = filled;
peripheries = 1;
box1 [shape = "point";style = "invis";];
}
}

subgraph cluster_box_2 {
subgraph cluster_box_2_internal {
label = "b2";
shape = box;
style = solid;
peripheries = 1;
box2 [shape = "point";];
}
}
}
}
subgraph cluster_target {
style = bold;
label = "pinned";

fut [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td port="target">5usize</td>
<td>h</td>
<td>e</td>
<td>l</td>
<td>l</td>
<td>o</td></tr>
<tr><td sides="B">fut</td></tr>
<tr><td port="target">0</td></tr>
<tr><td port="source"> </td></tr>
<tr><td style="dashed">...</td></tr>
<tr><td port="internal">1</td></tr>
</table>>;];
}


box1 -> box2 [rankdir = TB; style = invis;];

edge [tailclip = false;];
pinned_box -> pin [tailport = "source:c"; arrowhead = "none";];
pin -> fut [headport = "target";];
pin -> box1 [style = "invis";];
pin -> box2 [tailport = "source:c"; arrowhead = "none";];
box2 -> fut [headport = "target";];
fut -> fut [tailport = "source:c"; headport = "internal";];
}
41 changes: 9 additions & 32 deletions dot/trpl17-08.dot
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,24 @@ digraph {
<tr><td port="source"> </td></tr>
</table>>;];

subgraph cluster_both {
peripheries = 0;


subgraph cluster_deref {
style = dashed;
label = "String";

pin [shape = "point";];

string1 [label = <<table border="0" cellborder="1" cellspacing="0" bgcolor="lightgray">
<tr><td colspan="8" sides="B">s1</td></tr>
<tr>
<td port="target">5usize</td>
fut [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td port="target">5usize</td>
<td>h</td>
<td>e</td>
<td>l</td>
<td>l</td>
<td>o</td>
</tr>
<td>o</td></tr>
</table>>;];

subgraph cluster_deref {
style = dashed;
label = "String";
peripheries = 1;

pin [shape = "point";];

string2 [label = <<table border="0" cellborder="1" cellspacing="0">
<tr><td colspan="8" sides="B">s2</td></tr>
<tr>
<td port="target">7usize</td>
<td>g</td>
<td>o</td>
<td>o</td>
<td>d</td>
<td>b</td>
<td>y</td>
<td>e</td>
</tr>
</table>>;];
}
}

edge [tailclip = false;];
pinned_box -> pin [tailport = "source:c"; arrowhead = "none";];
pin -> string2 [headport = "target";];
pin -> fut [headport = "target";];
}
Loading

0 comments on commit 3111eda

Please sign in to comment.