Skip to content

Commit 56113c8

Browse files
committed
topo: add plot optimized mode
1 parent c1dc7e0 commit 56113c8

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "flashroute_rs"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
authors = [
55
"Bugen Zhao <[email protected]>",
66
"Zhengdong Wang <[email protected]>",

src/dcb.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use std::{
33
sync::atomic::{AtomicBool, AtomicU8, Ordering::SeqCst},
44
};
55

6+
use crate::OPT;
7+
68
#[derive(Debug)]
79
pub struct DstCtrlBlock {
810
pub addr: Ipv4Addr,
@@ -95,7 +97,13 @@ impl DstCtrlBlock {
9597
}
9698

9799
pub fn stop_backward(&self) {
98-
self.next_backward_hop.fetch_min(0, SeqCst);
100+
if OPT.plot_optimized {
101+
if self.backward_count.load(SeqCst) >= 2 {
102+
self.next_backward_hop.fetch_min(0, SeqCst);
103+
}
104+
} else {
105+
self.next_backward_hop.fetch_min(0, SeqCst);
106+
}
99107
}
100108

101109
pub fn stop_forward(&self) {

src/opt.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ pub struct Opt {
4949
pub layout: String,
5050
#[structopt(long = "no-spline", parse(from_flag = std::ops::Not::not))]
5151
pub spline: bool,
52+
#[structopt(short = "p", long)]
53+
pub plot_optimized: bool,
5254

5355
// Misc
5456
#[structopt(long, default_value = "114514")]
@@ -100,6 +102,9 @@ pub fn get_opt() -> Opt {
100102
log::warn!("Probing rate is 0, rate limit will be turned off.");
101103
opt.probing_rate = u64::MAX;
102104
}
105+
if opt.plot_optimized {
106+
opt.redundancy_removal = false;
107+
}
103108
opt
104109
}
105110

src/topo.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ impl Topo {
5151
}
5252
}
5353
for (a, b) in results.iter().zip(results.iter().skip(1)) {
54-
let dist = b.distance - a.distance;
55-
graph.add_node(b.responder);
56-
graph.add_edge(a.responder, b.responder, dist);
54+
if a.responder != b.responder {
55+
let dist = b.distance - a.distance;
56+
graph.add_node(b.responder);
57+
graph.add_edge(a.responder, b.responder, dist);
58+
}
5759
}
5860
};
5961

0 commit comments

Comments
 (0)