Skip to content
Snippets Groups Projects
Commit 6279e4f0 authored by Russel Arbore's avatar Russel Arbore
Browse files

Display schedules in dot graph

parent e782b4c2
No related branches found
No related tags found
1 merge request!13Basic IR schedules framework
This commit is part of merge request !13. Comments created here will be created in the context of that merge request.
...@@ -20,9 +20,9 @@ pub enum Schedule { ...@@ -20,9 +20,9 @@ pub enum Schedule {
*/ */
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Plan { pub struct Plan {
schedules: Vec<Vec<Schedule>>, pub schedules: Vec<Vec<Schedule>>,
partitions: Vec<PartitionID>, pub partitions: Vec<PartitionID>,
num_partitions: usize, pub num_partitions: usize,
} }
define_id_type!(PartitionID); define_id_type!(PartitionID);
......
...@@ -15,6 +15,7 @@ pub fn write_dot<W: Write>( ...@@ -15,6 +15,7 @@ pub fn write_dot<W: Write>(
typing: &ModuleTyping, typing: &ModuleTyping,
doms: &Vec<DomTree>, doms: &Vec<DomTree>,
fork_join_maps: &Vec<HashMap<NodeID, NodeID>>, fork_join_maps: &Vec<HashMap<NodeID, NodeID>>,
plans: &Vec<Plan>,
w: &mut W, w: &mut W,
) -> std::fmt::Result { ) -> std::fmt::Result {
write_digraph_header(w)?; write_digraph_header(w)?;
...@@ -22,6 +23,7 @@ pub fn write_dot<W: Write>( ...@@ -22,6 +23,7 @@ pub fn write_dot<W: Write>(
for function_id in (0..module.functions.len()).map(FunctionID::new) { for function_id in (0..module.functions.len()).map(FunctionID::new) {
let function = &module.functions[function_id.idx()]; let function = &module.functions[function_id.idx()];
let reverse_postorder = &reverse_postorders[function_id.idx()]; let reverse_postorder = &reverse_postorders[function_id.idx()];
let plan = &plans[function_id.idx()];
let mut reverse_postorder_node_numbers = vec![0; function.nodes.len()]; let mut reverse_postorder_node_numbers = vec![0; function.nodes.len()];
for (idx, id) in reverse_postorder.iter().enumerate() { for (idx, id) in reverse_postorder.iter().enumerate() {
reverse_postorder_node_numbers[id.idx()] = idx; reverse_postorder_node_numbers[id.idx()] = idx;
...@@ -39,7 +41,14 @@ pub fn write_dot<W: Write>( ...@@ -39,7 +41,14 @@ pub fn write_dot<W: Write>(
// Control nodes are dark red, data nodes are dark blue. // Control nodes are dark red, data nodes are dark blue.
let color = if dst_control { "darkred" } else { "darkblue" }; let color = if dst_control { "darkred" } else { "darkblue" };
write_node(node_id, function_id, color, module, w)?; write_node(
node_id,
function_id,
color,
module,
&plan.schedules[node_id.idx()],
w,
)?;
for u in def_use::get_uses(&node).as_ref() { for u in def_use::get_uses(&node).as_ref() {
let src_ty = &module.types[typing[function_id.idx()][u.idx()].idx()]; let src_ty = &module.types[typing[function_id.idx()][u.idx()].idx()];
...@@ -164,6 +173,7 @@ fn write_node<W: Write>( ...@@ -164,6 +173,7 @@ fn write_node<W: Write>(
function_id: FunctionID, function_id: FunctionID,
color: &str, color: &str,
module: &Module, module: &Module,
schedules: &Vec<Schedule>,
w: &mut W, w: &mut W,
) -> std::fmt::Result { ) -> std::fmt::Result {
let node = &module.functions[function_id.idx()].nodes[node_id.idx()]; let node = &module.functions[function_id.idx()].nodes[node_id.idx()];
...@@ -222,16 +232,33 @@ fn write_node<W: Write>( ...@@ -222,16 +232,33 @@ fn write_node<W: Write>(
} else { } else {
format!("{} ({})", node.lower_case_name(), suffix) format!("{} ({})", node.lower_case_name(), suffix)
}; };
write!(
w, let mut iter = schedules.into_iter();
"{}_{}_{} [xlabel={}, label=\"{}\", color={}];\n", if let Some(first) = iter.next() {
node.lower_case_name(), let subtitle = iter.fold(format!("{:?}", first), |b, i| format!("{}, {:?}", b, i));
function_id.idx(), write!(
node_id.idx(), w,
node_id.idx(), "{}_{}_{} [xlabel={}, label=<{}<BR /><FONT POINT-SIZE=\"8\">{}</FONT>>, color={}];\n",
label, node.lower_case_name(),
color function_id.idx(),
)?; node_id.idx(),
node_id.idx(),
label,
subtitle,
color
)?;
} else {
write!(
w,
"{}_{}_{} [xlabel={}, label=\"{}\", color={}];\n",
node.lower_case_name(),
function_id.idx(),
node_id.idx(),
node_id.idx(),
label,
color
)?;
}
Ok(()) Ok(())
} }
......
...@@ -102,6 +102,7 @@ fn main() { ...@@ -102,6 +102,7 @@ fn main() {
&typing, &typing,
&doms, &doms,
&fork_join_maps, &fork_join_maps,
&plans,
&mut contents, &mut contents,
) )
.expect("PANIC: Unable to generate output file contents."); .expect("PANIC: Unable to generate output file contents.");
...@@ -120,6 +121,7 @@ fn main() { ...@@ -120,6 +121,7 @@ fn main() {
&typing, &typing,
&doms, &doms,
&fork_join_maps, &fork_join_maps,
&plans,
&mut contents, &mut contents,
) )
.expect("PANIC: Unable to generate output file contents."); .expect("PANIC: Unable to generate output file contents.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment