diff --git a/src/cli.rs b/src/cli.rs index abb48e33528..2160b7503d5 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -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"); diff --git a/src/output/mod.rs b/src/output/mod.rs index 5b7a670b2d1..5b98bf2edac 100644 --- a/src/output/mod.rs +++ b/src/output/mod.rs @@ -18,6 +18,7 @@ use std::io::{self, Write}; use std::path::PathBuf; mod dump; +mod tracking; mod timely; @@ -31,6 +32,7 @@ crate struct Output { restricts: FxHashMap>>, region_live_at: FxHashMap>, subset: FxHashMap>>, + crate region_degrees: tracking::RegionDegrees, } impl Output { @@ -46,6 +48,7 @@ impl Output { restricts: FxHashMap::default(), region_live_at: FxHashMap::default(), subset: FxHashMap::default(), + region_degrees: tracking::RegionDegrees::new(), dump_enabled, } } diff --git a/src/output/timely.rs b/src/output/timely.rs index b7a2bdf794f..bbd873aaa38 100644 --- a/src/output/timely.rs +++ b/src/output/timely.rs @@ -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); } } }); diff --git a/src/output/tracking.rs b/src/output/tracking.rs new file mode 100644 index 00000000000..b4d65c9f1a8 --- /dev/null +++ b/src/output/tracking.rs @@ -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 or the MIT license +// , 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; + } +}