awooter: properly parallelise
This commit is contained in:
parent
c00fba75e9
commit
1077cd3654
@ -8,6 +8,8 @@ use colored::Colorize;
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
use rayon::prelude::*;
|
||||
|
||||
use crate::npnr::PortRef;
|
||||
|
||||
#[macro_use]
|
||||
mod npnr;
|
||||
|
||||
@ -312,11 +314,10 @@ fn partition_nets(
|
||||
let arcs = nets
|
||||
.users_by_name(*name)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.par_iter()
|
||||
.flat_map(|sink| {
|
||||
let sink = unsafe { sink.as_ref().unwrap() };
|
||||
ctx.sink_wires(net, sink)
|
||||
.into_iter()
|
||||
ctx.sink_wires(net, (*sink) as *const PortRef)
|
||||
.into_par_iter()
|
||||
.map(move |sink_wire| (sink, sink_wire))
|
||||
})
|
||||
.flat_map(|(sink, sink_wire)| {
|
||||
@ -682,7 +683,6 @@ fn route(ctx: &mut npnr::Context) -> bool {
|
||||
let mut y1 = 0;
|
||||
|
||||
for sink in nets.users_by_name(*name).unwrap().iter() {
|
||||
let sink = unsafe { sink.as_ref().unwrap() };
|
||||
let cell = sink.cell().unwrap().location();
|
||||
x0 = x0.min(cell.x);
|
||||
y0 = y0.min(cell.y);
|
||||
|
@ -319,7 +319,7 @@ extern "C" {
|
||||
/// Store for the nets of a context.
|
||||
pub struct Nets<'a> {
|
||||
nets: HashMap<IdString, *mut NetInfo>,
|
||||
users: HashMap<IdString, &'a [*mut PortRef]>,
|
||||
users: HashMap<IdString, &'a [&'a mut PortRef]>,
|
||||
_data: PhantomData<&'a Context>,
|
||||
}
|
||||
|
||||
@ -347,7 +347,7 @@ impl<'a> Nets<'a> {
|
||||
// Leaking memory is the most convenient FFI I could think of.
|
||||
let len =
|
||||
unsafe { npnr_netinfo_users_leak(net, &mut users_ptr as *mut *mut *mut PortRef) };
|
||||
let users_slice = unsafe { slice::from_raw_parts(users_ptr, len as usize) };
|
||||
let users_slice = unsafe { slice::from_raw_parts(users_ptr as *mut &mut PortRef, len as usize) };
|
||||
nets.insert(name, net);
|
||||
users.insert(name, users_slice);
|
||||
}
|
||||
@ -360,7 +360,7 @@ impl<'a> Nets<'a> {
|
||||
}
|
||||
|
||||
/// Find net users given a net's name.
|
||||
pub fn users_by_name(&self, net: IdString) -> Option<&&[*mut PortRef]> {
|
||||
pub fn users_by_name(&self, net: IdString) -> Option<&&[&mut PortRef]> {
|
||||
self.users.get(&net)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user