diff --git a/common/route/awooter/rust/src/lib.rs b/common/route/awooter/rust/src/lib.rs index a7d32c29..3ac282ac 100644 --- a/common/route/awooter/rust/src/lib.rs +++ b/common/route/awooter/rust/src/lib.rs @@ -3,6 +3,8 @@ use std::{ptr::NonNull, time::Instant}; use colored::Colorize; +use indicatif::MultiProgress; +use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; use crate::partition::Coord; @@ -173,20 +175,29 @@ fn route(ctx: &mut npnr::Context) -> bool { let start = Instant::now(); - let mut router = route::Router::new(Coord::new(0, 0), Coord::new(x_part, y_part)); - log_info!("Routing northeast arcs\n"); - router.route(ctx, &nets, &ne); - log_info!("Routing southeast arcs\n"); - router.route(ctx, &nets, &se); - log_info!("Routing southwest arcs\n"); - router.route(ctx, &nets, &sw); - log_info!("Routing northwest arcs\n"); - router.route(ctx, &nets, &nw); + log_info!("Routing partitioned arcs\n"); + + let progress = MultiProgress::new(); + + let partitions = [ + (Coord::new(0, 0), Coord::new(x_part+1, y_part+1), &ne), + (Coord::new(x_part-1, 0), Coord::new(ctx.grid_dim_x(), y_part+1), &se), + (Coord::new(x_part-1, y_part-1), Coord::new(ctx.grid_dim_x(), ctx.grid_dim_y()), &sw), + (Coord::new(0, y_part-1), Coord::new(x_part+1, ctx.grid_dim_y()), &nw) + ]; + + partitions.par_iter().for_each(|(box_ne, box_sw, arcs)| { + let mut router = route::Router::new(*box_ne, *box_sw); + router.route(ctx, &nets, arcs, &progress); + }); + log_info!("Routing miscellaneous arcs\n"); - router.route(ctx, &nets, &misc); + let mut router = route::Router::new(Coord::new(0, 0), Coord::new(ctx.grid_dim_x(), ctx.grid_dim_y())); + router.route(ctx, &nets, &misc, &progress); let time = Instant::now() - start; - log_info!("Routing took {:.2}s\n", time.as_secs_f32()); + + log_info!("Routing took {:.2}s\n", time.as_secs_f32().to_string().bold()); //let mut router = route::Router::new(Coord::new(0, 0), Coord::new(x_part, y_part)); diff --git a/common/route/awooter/rust/src/partition.rs b/common/route/awooter/rust/src/partition.rs index 077803a9..3fa4ecd8 100644 --- a/common/route/awooter/rust/src/partition.rs +++ b/common/route/awooter/rust/src/partition.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, ops::RangeBounds, sync::atomic::AtomicUsize}; +use std::{collections::{HashMap, HashSet}, ops::RangeBounds, sync::atomic::AtomicUsize}; use colored::Colorize; use indicatif::{ParallelProgressIterator, ProgressBar, ProgressStyle}; @@ -24,6 +24,7 @@ pub enum Segment { // v // S // (x > P.x) +#[derive(Clone, Copy)] pub struct Coord { x: i32, y: i32, @@ -359,12 +360,10 @@ fn partition>( ); let is_special_case = |arc: &Arc| { - let src_wire = arc.get_source_wire(); - //let dst_wire = arc.get_sink_wire(); let src_name = ctx.name_of_wire(arc.get_source_wire()).to_str().unwrap(); - //let dst_name = ctx.name_of_wire(arc.get_sink_wire()).to_str().unwrap(); + let dst_name = ctx.name_of_wire(arc.get_sink_wire()).to_str().unwrap(); - if src_name.contains("FCO_SLICE") { + if src_name.contains("FCO_SLICE") || src_name.contains('J') || src_name.contains("DDR") || dst_name.contains("DDR") { return true; } @@ -407,8 +406,9 @@ fn partition>( let sink_coords: Coord = sink_loc.into(); let sink_is_north = sink_coords.is_north_of(&partition_coords); let sink_is_east = sink_coords.is_east_of(&partition_coords); - //let name = ctx.name_of(nets.name_from_index(arc.net())).to_str().unwrap().to_string(); - let verbose = false; // name == "decode_to_execute_IS_RS2_SIGNED_LUT4_D_1_Z_CCU2C_B1_S0_CCU2C_S0_3_B1"; + // let name = ctx.name_of(nets.name_from_index(arc.net())).to_str().unwrap().to_string(); + let verbose = false; // name == "IBusCachedPlugin_fetchPc_pc_LUT4_Z_15_B_CCU2C_S0$CCU2_FCI_INT"; + //"soc0.processor.with_fpu.fpu_0.fpu_multiply_0.rin_CCU2C_S0_24_B1_LUT4_Z_B_CCU2C_S0_CIN_CCU2C_COUT_S1_LUT4_D_Z_LUT4_Z_D_CCU2C_S0_CIN_CCU2C_COUT_CIN_CCU2C_COUT$CCU2_FCI_INT"; if source_is_north == sink_is_north && source_is_east == sink_is_east { let seg = source_coords.segment_from(&Coord::new(x, y)); vec![(seg, arc.clone())] diff --git a/common/route/awooter/rust/src/route.rs b/common/route/awooter/rust/src/route.rs index 31b50747..b7065425 100644 --- a/common/route/awooter/rust/src/route.rs +++ b/common/route/awooter/rust/src/route.rs @@ -3,7 +3,7 @@ use std::{ time::Duration, }; -use indicatif::{ProgressBar, ProgressStyle}; +use indicatif::{ProgressBar, ProgressStyle, MultiProgress}; use crate::{ npnr::{self, NetIndex, PipId}, @@ -126,15 +126,14 @@ impl Router { } } - pub fn route(&mut self, ctx: &npnr::Context, nets: &npnr::Nets, arcs: &[Arc]) { - let progress = ProgressBar::new(arcs.len() as u64); + pub fn route(&mut self, ctx: &npnr::Context, nets: &npnr::Nets, arcs: &[Arc], progress: &MultiProgress) { + let progress = progress.add(ProgressBar::new(arcs.len() as u64)); progress.set_style( ProgressStyle::with_template("[{elapsed}] [{bar:40.magenta/red}] {msg:30!}") .unwrap() .progress_chars("━╸ "), ); - progress.enable_steady_tick(Duration::from_secs_f32(0.2)); for arc in arcs { let net = unsafe { nets.net_from_index(arc.net).as_ref().unwrap() }; let name = ctx @@ -183,14 +182,14 @@ impl Router { } for pip in ctx.get_downhill_pips(source.wire) { - /*let pip_loc = ctx.pip_location(pip); + let pip_loc = ctx.pip_location(pip); let pip_coord = partition::Coord::from(pip_loc); if pip_coord.is_north_of(&self.box_ne) || pip_coord.is_east_of(&self.box_ne) { continue; } if pip_coord.is_south_of(&self.box_sw) || pip_coord.is_west_of(&self.box_sw) { continue; - }*/ + } /* if (!ctx->checkPipAvailForNet(dh, net))