-
Notifications
You must be signed in to change notification settings - Fork 12
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
Print the egglog program before the last schedule for multi-pass schedule in --run-mode egglog
#675
Changes from 6 commits
a547af9
26c3a98
6ecb973
06723fe
86464d9
ce33d00
0616dd5
4d547d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,8 +173,6 @@ pub fn parallel_schedule() -> Vec<CompilerPass> { | |
)), | ||
CompilerPass::InlineWithSchedule(format!( | ||
" | ||
;; HACK: when INLINE appears in this string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch |
||
;; we perform inlining in this pass | ||
(run-schedule | ||
(saturate | ||
{helpers} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ use crate::{EggCCError, Optimizer}; | |
use bril_rs::Program; | ||
use clap::ValueEnum; | ||
use dag_in_context::dag2svg::tree_to_svg; | ||
use dag_in_context::schedule::parallel_schedule; | ||
use dag_in_context::schedule::{self, parallel_schedule}; | ||
use dag_in_context::{build_program, check_roundtrip_egraph, EggccConfig, Schedule}; | ||
|
||
use dag_in_context::schema::TreeProgram; | ||
|
@@ -802,27 +802,36 @@ impl Run { | |
) | ||
} | ||
RunMode::Egglog => { | ||
assert_eq!(self.eggcc_config.schedule, Schedule::Parallel, "Output egglog only works in parallel mode. Sequential mode does not use a single egraph"); | ||
|
||
let rvsdg = Optimizer::program_to_rvsdg(&self.prog_with_args.program)?; | ||
let (dag, mut cache) = rvsdg.to_dag_encoding(true); | ||
|
||
let schedule_steps = parallel_schedule(); | ||
if schedule_steps.len() != 1 { | ||
log::warn!("Parallel schedule had multiple steps! You may need to adjust the schedule to make eggcc tractable."); | ||
} | ||
// to deal with i64::MAX | ||
let stop_after_n_passes = i64::min( | ||
self.eggcc_config.stop_after_n_passes, | ||
parallel_schedule().len() as i64, | ||
); | ||
let eggcc_config = EggccConfig { | ||
yihozhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// stop before the last pass that user specified. | ||
stop_after_n_passes: stop_after_n_passes - 1, | ||
..self.eggcc_config.clone() | ||
}; | ||
let optimized = dag_in_context::optimize(&dag, &mut cache, &eggcc_config) | ||
yihozhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.map_err(EggCCError::EggLog)?; | ||
|
||
let schedules = parallel_schedule(); | ||
let last_schedule_step = schedules.last().unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're still using the wrong pass here- didn't you want the stop_after_n_passes pass? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch, fixed! |
||
|
||
let inline_program = match last_schedule_step { | ||
schedule::CompilerPass::Schedule(_) => None, | ||
schedule::CompilerPass::InlineWithSchedule(_) => Some(&optimized), | ||
}; | ||
|
||
// TODO make the egglog run mode use intermediate egglog files instead of sticking passes together | ||
let egglog = build_program( | ||
&dag, | ||
Some(&dag), | ||
&optimized, | ||
inline_program, | ||
&dag.fns(), | ||
&mut cache, | ||
&schedule_steps | ||
.iter() | ||
.map(|pass| pass.egglog_schedule().to_string()) | ||
.collect::<Vec<String>>() | ||
.join("\n"), | ||
last_schedule_step.egglog_schedule(), | ||
); | ||
( | ||
vec![Visualization { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems weird... I would expect
-1
to run all but the last pass, but it looks like it runs all of them.Perhaps you should make it i64::MAX by default and use
[0 .. scheduler.len() + stop_after_n_passes ]
in the neg case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the code to reflect this, although it is a little less elegant now to handle the pass before
i64::MAX