Skip to content

Add tracking for in/out degree #16

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

Merged
merged 1 commit into from
May 4, 2018
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
11 changes: 11 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ pub fn main(opt: Opt) -> Result<(), Error> {
let seconds: f64 = duration.as_secs() as f64;
let millis: f64 = duration.subsec_nanos() as f64 * 0.000_000_001_f64;
println!("Time: {:0.3}s", seconds + millis);

if opt.verbose {
println!("Max region graph in/out-degree: {} {}",
output.region_degrees.max_in_degree(),
output.region_degrees.max_out_degree());
if output.region_degrees.has_multidegree() {
println!("Found multidegree");
} else {
println!("No multidegree");
}
}
}
if !opt.skip_tuples {
output.dump(&opt.output_directory, tables).expect("Failed to write output");
Expand Down
3 changes: 3 additions & 0 deletions src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::io::{self, Write};
use std::path::PathBuf;

mod dump;
mod tracking;
mod timely;


Expand All @@ -31,6 +32,7 @@ crate struct Output {
restricts: FxHashMap<Point, BTreeMap<Region, BTreeSet<Loan>>>,
region_live_at: FxHashMap<Point, Vec<Region>>,
subset: FxHashMap<Point, BTreeMap<Region, BTreeSet<Region>>>,
crate region_degrees: tracking::RegionDegrees,
}

impl Output {
Expand All @@ -46,6 +48,7 @@ impl Output {
restricts: FxHashMap::default(),
region_live_at: FxHashMap::default(),
subset: FxHashMap::default(),
region_degrees: tracking::RegionDegrees::new(),
dump_enabled,
}
}
Expand Down
1 change: 1 addition & 0 deletions src/output/timely.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ pub(super) fn timely_dataflow(dump_enabled: bool, all_facts: AllFacts) -> Output
.entry(*r1)
.or_insert(BTreeSet::new())
.insert(*r2);
result.region_degrees.update_degrees(*r1, *r2, *location);
}
}
});
Expand Down
52 changes: 52 additions & 0 deletions src/output/tracking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use crate::facts::{Point, Region};
use fxhash::FxHashMap;

#[derive(Clone, Debug)]
crate struct RegionDegrees {
in_degree: FxHashMap<(Region, Point), usize>,
out_degree: FxHashMap<(Region, Point), usize>,
}

impl RegionDegrees {
crate fn new() -> Self {
Self {
in_degree: Default::default(),
out_degree: Default::default(),
}
}

crate fn update_degrees(&mut self, r1: Region, r2: Region, p: Point) {
*self.in_degree.entry((r2, p)).or_insert(0) += 1;
*self.out_degree.entry((r1, p)).or_insert(0) += 1;
}

crate fn max_out_degree(&self) -> usize {
*self.out_degree.values().max().unwrap_or(&0)
}

crate fn max_in_degree(&self) -> usize {
*self.in_degree.values().max().unwrap_or(&0)
}

crate fn has_multidegree(&self) -> bool {
for (region_point, in_count) in &self.in_degree {
match self.out_degree.get(region_point) {
Some(out_count) => if *out_count > 1 && *in_count > 1 {
return true;
}
None => {}
}
}
return false;
}
}