Skip to content

Commit

Permalink
add inlining after optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
oflatt committed Nov 12, 2024
1 parent aec37ce commit 0b328b8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
7 changes: 5 additions & 2 deletions dag_in_context/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,11 @@ pub fn optimize(

// if we are inlining, save the program
// TODO we inline on the first pass, but this should be configurable from the schedule
// TODO inline
let inline_program = if i == 1000 { Some(res.clone()) } else { None };
let inline_program = if schedule.contains("INLINE") {
Some(res.clone())
} else {
None
};

for func in fns {
log::info!("Running pass {} on {}", i, func);
Expand Down
3 changes: 1 addition & 2 deletions dag_in_context/src/optimizations/rec_to_loop.egg
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@
(= always-runs-len (tuple-length always-runs))
(= start-ty (TupleT start-ty-list))
(HasType body func-ty))
((panic "good")
(let loop-ty
((let loop-ty
(TupleT (TLConcat start-ty-list (TCons (IntT) (TNil)))))
;; recursive case in the loop
(let new-rec-case
Expand Down
22 changes: 16 additions & 6 deletions dag_in_context/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ fn optimizations() -> Vec<String> {
"loop-inv-motion",
"loop-strength-reduction",
"loop-peel",
"rec-to-loop",
]
.iter()
.map(|opt| opt.to_string())
Expand Down Expand Up @@ -118,12 +117,22 @@ pub fn mk_sequential_schedule() -> Vec<String> {
pub fn parallel_schedule() -> Vec<String> {
let helpers = helpers();

vec![format!(
"
vec![
format!(
"
(run-schedule
(repeat 2
{helpers}
swap-if)
{helpers}
(repeat 2 swap-if)
rec-to-loop
{helpers})"
),
format!(
"
;; HACK: when INLINE appears in this string
;; we perform inlining in this pass
(run-schedule
(repeat 2
{helpers}
all-optimizations
Expand All @@ -137,5 +146,6 @@ pub fn parallel_schedule() -> Vec<String> {
{helpers}
)
"
)]
),
]
}

0 comments on commit 0b328b8

Please sign in to comment.