awooter: multithreaded routing

This commit is contained in:
Lofty 2022-11-30 01:20:14 +00:00
parent 290291cca6
commit ac3ef9b0bb
3 changed files with 34 additions and 24 deletions

View File

@ -3,6 +3,8 @@
use std::{ptr::NonNull, time::Instant}; use std::{ptr::NonNull, time::Instant};
use colored::Colorize; use colored::Colorize;
use indicatif::MultiProgress;
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
use crate::partition::Coord; use crate::partition::Coord;
@ -173,20 +175,29 @@ fn route(ctx: &mut npnr::Context) -> bool {
let start = Instant::now(); let start = Instant::now();
let mut router = route::Router::new(Coord::new(0, 0), Coord::new(x_part, y_part)); log_info!("Routing partitioned arcs\n");
log_info!("Routing northeast arcs\n");
router.route(ctx, &nets, &ne); let progress = MultiProgress::new();
log_info!("Routing southeast arcs\n");
router.route(ctx, &nets, &se); let partitions = [
log_info!("Routing southwest arcs\n"); (Coord::new(0, 0), Coord::new(x_part+1, y_part+1), &ne),
router.route(ctx, &nets, &sw); (Coord::new(x_part-1, 0), Coord::new(ctx.grid_dim_x(), y_part+1), &se),
log_info!("Routing northwest arcs\n"); (Coord::new(x_part-1, y_part-1), Coord::new(ctx.grid_dim_x(), ctx.grid_dim_y()), &sw),
router.route(ctx, &nets, &nw); (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"); 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; 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)); //let mut router = route::Router::new(Coord::new(0, 0), Coord::new(x_part, y_part));

View File

@ -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 colored::Colorize;
use indicatif::{ParallelProgressIterator, ProgressBar, ProgressStyle}; use indicatif::{ParallelProgressIterator, ProgressBar, ProgressStyle};
@ -24,6 +24,7 @@ pub enum Segment {
// v // v
// S // S
// (x > P.x) // (x > P.x)
#[derive(Clone, Copy)]
pub struct Coord { pub struct Coord {
x: i32, x: i32,
y: i32, y: i32,
@ -359,12 +360,10 @@ fn partition<R: RangeBounds<i32>>(
); );
let is_special_case = |arc: &Arc| { 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 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; return true;
} }
@ -407,8 +406,9 @@ fn partition<R: RangeBounds<i32>>(
let sink_coords: Coord = sink_loc.into(); let sink_coords: Coord = sink_loc.into();
let sink_is_north = sink_coords.is_north_of(&partition_coords); let sink_is_north = sink_coords.is_north_of(&partition_coords);
let sink_is_east = sink_coords.is_east_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 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 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 { if source_is_north == sink_is_north && source_is_east == sink_is_east {
let seg = source_coords.segment_from(&Coord::new(x, y)); let seg = source_coords.segment_from(&Coord::new(x, y));
vec![(seg, arc.clone())] vec![(seg, arc.clone())]

View File

@ -3,7 +3,7 @@ use std::{
time::Duration, time::Duration,
}; };
use indicatif::{ProgressBar, ProgressStyle}; use indicatif::{ProgressBar, ProgressStyle, MultiProgress};
use crate::{ use crate::{
npnr::{self, NetIndex, PipId}, npnr::{self, NetIndex, PipId},
@ -126,15 +126,14 @@ impl Router {
} }
} }
pub fn route(&mut self, ctx: &npnr::Context, nets: &npnr::Nets, arcs: &[Arc]) { pub fn route(&mut self, ctx: &npnr::Context, nets: &npnr::Nets, arcs: &[Arc], progress: &MultiProgress) {
let progress = ProgressBar::new(arcs.len() as u64); let progress = progress.add(ProgressBar::new(arcs.len() as u64));
progress.set_style( progress.set_style(
ProgressStyle::with_template("[{elapsed}] [{bar:40.magenta/red}] {msg:30!}") ProgressStyle::with_template("[{elapsed}] [{bar:40.magenta/red}] {msg:30!}")
.unwrap() .unwrap()
.progress_chars("━╸ "), .progress_chars("━╸ "),
); );
progress.enable_steady_tick(Duration::from_secs_f32(0.2));
for arc in arcs { for arc in arcs {
let net = unsafe { nets.net_from_index(arc.net).as_ref().unwrap() }; let net = unsafe { nets.net_from_index(arc.net).as_ref().unwrap() };
let name = ctx let name = ctx
@ -183,14 +182,14 @@ impl Router {
} }
for pip in ctx.get_downhill_pips(source.wire) { 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); 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) { if pip_coord.is_north_of(&self.box_ne) || pip_coord.is_east_of(&self.box_ne) {
continue; continue;
} }
if pip_coord.is_south_of(&self.box_sw) || pip_coord.is_west_of(&self.box_sw) { if pip_coord.is_south_of(&self.box_sw) || pip_coord.is_west_of(&self.box_sw) {
continue; continue;
}*/ }
/* /*
if (!ctx->checkPipAvailForNet(dh, net)) if (!ctx->checkPipAvailForNet(dh, net))