Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transitive reduction to dump_schedule #422

Merged
merged 1 commit into from
Jul 24, 2023
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
2 changes: 1 addition & 1 deletion tools/dump_schedule/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

A simple debugging utility for visualizing Valence's schedule graph. Generates a SVG file.

1. Ensure that [Graphviz](https://graphviz.org/) is installed and the `dot` command is available.
1. Ensure that [Graphviz](https://graphviz.org/) is installed and the `dot` and `tred` commands are available.
2. Run the program with `cargo r -p dump_schedule -- PostUpdate`
3. Open the generated `graph.svg` in your browser or other program, e.g. `chromium graph.svg`.
36 changes: 26 additions & 10 deletions tools/dump_schedule/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct Cli {
/// Output SVG file path.
#[clap(short, long, default_value = "graph.svg")]
output: PathBuf,
/// Disables transitive reduction of the output schedule graph.
#[clap(short = 't', long)]
no_tred: bool,
}

fn main() -> io::Result<()> {
Expand Down Expand Up @@ -70,18 +73,31 @@ fn main() -> io::Result<()> {
},
);

let mut child = Command::new("dot")
.stdin(Stdio::piped())
.arg("-Tsvg")
.arg("-o")
.arg(cli.output)
.spawn()?;
let mut dot_command = Command::new("dot");
dot_command.arg("-Tsvg").arg("-o").arg(cli.output);

if let Some(stdin) = child.stdin.as_mut() {
stdin.write_all(dot_graph.as_bytes())?;
}
if cli.no_tred {
let mut dot_child = dot_command.stdin(Stdio::piped()).spawn()?;

dot_child
.stdin
.as_mut()
.unwrap()
.write_all(dot_graph.as_bytes())?;

dot_child.wait_with_output()?;
} else {
let tred_child = Command::new("tred")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()?;

child.wait_with_output()?;
let dot_child = dot_command.stdin(tred_child.stdout.unwrap()).spawn()?;

tred_child.stdin.unwrap().write_all(dot_graph.as_bytes())?;

dot_child.wait_with_output()?;
};

Ok(())
}
Expand Down
Loading