Skip to content
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

Automated Filament Scheduling #466

Draft
wants to merge 68 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
09067cf
add scheduling test
UnsignedByte Sep 29, 2024
bc50607
get started on passes
UnsignedByte Sep 30, 2024
159115d
Merge branch 'main' into scheduling
UnsignedByte Oct 1, 2024
9be992c
add working scheduling
UnsignedByte Oct 8, 2024
74dfab6
add scheduling insertions
UnsignedByte Oct 17, 2024
d9e5fb4
Merge branch 'main' into scheduling
UnsignedByte Oct 17, 2024
f240c56
update pipeline
UnsignedByte Oct 17, 2024
3fc941e
fix bugs and get working scheduling
UnsignedByte Oct 17, 2024
13eec5c
cleanup
UnsignedByte Oct 17, 2024
c57b7d9
cleanup tests
UnsignedByte Oct 17, 2024
3fd3bab
more cleanup
UnsignedByte Oct 17, 2024
d402d01
re-enable discharge
UnsignedByte Oct 18, 2024
33f1d1d
mild cleanup
UnsignedByte Oct 18, 2024
639b81f
Merge branch 'main' into scheduling
UnsignedByte Oct 29, 2024
278de4e
Merge branch 'main' into scheduling
UnsignedByte Oct 31, 2024
41f99b3
Merge branch 'main' into scheduling
UnsignedByte Jan 8, 2025
8dcffdd
start adding scheudling model
UnsignedByte Jan 10, 2025
a163f22
merge main
UnsignedByte Jan 18, 2025
3a065cb
Merge branch 'main' into scheduling
UnsignedByte Jan 19, 2025
85a263e
start adding conversion
UnsignedByte Jan 19, 2025
487712a
Merge branch 'main' into scheduling
UnsignedByte Jan 24, 2025
86815a0
merge
UnsignedByte Jan 24, 2025
b1cdfd5
Merge branch 'main' into scheduling
UnsignedByte Jan 25, 2025
fe84d1a
Merge branch 'main' into scheduling
UnsignedByte Feb 2, 2025
31e3f37
add scheduling model in attributes
UnsignedByte Feb 2, 2025
a9775c8
Merge branch 'main' into scheduling
UnsignedByte Feb 25, 2025
cc47a3e
add combinational scheduling
UnsignedByte Feb 27, 2025
af2d6c3
Merge branch 'main' into scheduling
UnsignedByte Feb 27, 2025
8ff66ff
working combinational delay
UnsignedByte Feb 28, 2025
106b38b
start work on multi-event scheduling
UnsignedByte Feb 28, 2025
0d42c1f
Merge branch 'main' into scheduling
UnsignedByte Feb 28, 2025
3ea8a3c
multi-event scheduling
UnsignedByte Feb 28, 2025
f27d970
add multi-event support
UnsignedByte Mar 10, 2025
e1ffd2d
bugfix minimize expression
UnsignedByte Mar 10, 2025
1ea63e1
cleanup
UnsignedByte Mar 10, 2025
dc75b3a
Merge branch 'main' into scheduling
UnsignedByte Mar 17, 2025
f9e81cf
format
UnsignedByte Mar 17, 2025
c2e50c8
start restructuring monomorphization for scheduling
UnsignedByte Mar 18, 2025
bcea9da
update error message
UnsignedByte Mar 18, 2025
7deef69
better error message
UnsignedByte Mar 18, 2025
2c9d413
start working on rewriting schedule
UnsignedByte Mar 18, 2025
63ea35a
more restructuring
UnsignedByte Mar 18, 2025
22f197b
tmp
UnsignedByte Mar 18, 2025
0e7acfe
add most of the assertions
UnsignedByte Mar 19, 2025
b4d0b9a
remove unused imp
UnsignedByte Mar 19, 2025
c0b8e60
move assumption generation to its own pass
UnsignedByte Mar 19, 2025
e7a5dee
ga
UnsignedByte Mar 19, 2025
fc5f787
cleanup
UnsignedByte Mar 19, 2025
825b908
add test case and bugfix
UnsignedByte Mar 19, 2025
4d1c5a5
add some comments
UnsignedByte Mar 19, 2025
8d04c64
merge
UnsignedByte Mar 19, 2025
d8a23ac
discard invalid facts
UnsignedByte Mar 19, 2025
e294ce9
merge
UnsignedByte Mar 19, 2025
8972b78
auto-enable validation
UnsignedByte Mar 19, 2025
dc7d7bc
more checks
UnsignedByte Mar 19, 2025
7cbc627
Merge branch 'validation' into scheduling
UnsignedByte Mar 19, 2025
43cde4d
add assertions
UnsignedByte Mar 19, 2025
4118edd
Merge branch 'validation' into scheduling
UnsignedByte Mar 19, 2025
deae1b9
use validation check
UnsignedByte Mar 19, 2025
1cd93f6
remove mutable references
UnsignedByte Mar 19, 2025
487bbae
Merge branch 'rangecheck' into scheduling
UnsignedByte Mar 19, 2025
3dd467d
tmp
UnsignedByte Mar 19, 2025
ffe4f45
bugfix
UnsignedByte Mar 19, 2025
3990206
update error orders
UnsignedByte Mar 19, 2025
438e6c3
rename files
UnsignedByte Mar 20, 2025
e21af5a
change type to struct
UnsignedByte Mar 20, 2025
ad3ef7f
cleanup
UnsignedByte Mar 20, 2025
4e1c024
merge
UnsignedByte Mar 20, 2025
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
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ smallvec = "1"
topological-sort = "0.2"
atty = "0.2"
lazy_static = "1.4"
easy-smt = { version = "0.2.1" }
easy-smt = "0.2.3"
struct-variant = "1.0"
tempfile = "3.13.0"
strum = "0.26.3"
strum_macros = "0.26.3"
ordered-float = "5.0.0"
boxcar = "0.2.10"

fil-utils = { version = "0.1.0", path = "crates/utils" }
Expand Down
8 changes: 8 additions & 0 deletions crates/ast/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ impl Signature {
pub fn outputs(&self) -> impl Iterator<Item = &Loc<PortDef>> {
self.ports[self.outputs_idx..].iter()
}
/// Inputs of this signature
pub fn inputs_mut(&mut self) -> impl Iterator<Item = &mut Loc<PortDef>> {
self.ports[..self.outputs_idx].iter_mut()
}
/// Outputs of this signature
pub fn outputs_mut(&mut self) -> impl Iterator<Item = &mut Loc<PortDef>> {
self.ports[self.outputs_idx..].iter_mut()
}
/// Iterator over all the ports of this signature
pub fn ports(&self) -> &Vec<Loc<PortDef>> {
&self.ports
Expand Down
1 change: 1 addition & 0 deletions crates/filament/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fil-ast.workspace = true
fil-ir.workspace = true
fil-utils.workspace = true
fil-gen.workspace = true
ordered-float.workspace = true

calyx-ir.workspace = true
calyx-frontend.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/filament/src/ast_passes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod scheduling_model;
mod toplevel;

pub use scheduling_model::SchedulingModel;
pub use toplevel::TopLevel;
74 changes: 74 additions & 0 deletions crates/filament/src/ast_passes/scheduling_model.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
use crate::ast_visitor::{Action, Construct, Visitor};
use fil_ast as ast;
use fil_utils::{self as utils, AttrCtx, GPosIdx};
use serde::Deserialize;
use std::{collections::HashMap, fs};

#[derive(Deserialize, Debug, Default)]
struct CompModel {
ports: HashMap<String, f64>,
combinational: bool,
}

type Model = HashMap<String, CompModel>;

/// Loads the scheduling model into attributes
pub struct SchedulingModel {
/// Scheduling model mapping
model: Model,
}

impl Construct for SchedulingModel {
fn from(opts: &crate::cmdline::Opts, _: &mut fil_ast::Namespace) -> Self {
let model = opts
.scheduling_model
.as_ref()
.map(|path| {
toml::from_str(&fs::read_to_string(path).unwrap()).unwrap()
})
.unwrap_or_default();

Self { model }
}

fn clear_data(&mut self) {}
}

impl Visitor for SchedulingModel {
fn name() -> &'static str {
"scheduling_model"
}
fn signature(&mut self, sig: &mut ast::Signature) -> Action {
let comp = sig.name.inner().to_string();

log::info!(
"Scheduling model for component {}: {:?}",
comp,
self.model.get(&comp)
);

if let Some(attr_map) = self.model.get(&comp) {
if attr_map.combinational {
sig.attributes.set(
utils::CompBool::Combinational,
true,
GPosIdx::UNKNOWN,
);
}

for port in sig.outputs_mut() {
let name = port.name.to_string();

let value = *attr_map.ports.get(&name).unwrap_or_else(|| panic!("Port {} not found in scheduling model for component {}",
name, comp));

port.attrs.set(
utils::PortFloat::CombDelay,
value,
GPosIdx::UNKNOWN,
);
}
}
Action::Continue
}
}
4 changes: 4 additions & 0 deletions crates/filament/src/cmdline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ pub struct Opts {
#[argh(switch, long = "preserve-names")]
pub preserve_names: bool,

/// scheduling model containing port delays relative to clock frequency
#[argh(option, long = "scheduling-model")]
pub scheduling_model: Option<String>,

// Solver specific configuration
/// solver to use (default: cvc5): cvc5, z3
#[argh(option, long = "solver", default = "Solver::Z3")]
Expand Down
Loading
Loading