Skip to content

Commit

Permalink
Finished merge
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchuyaya committed Mar 14, 2024
1 parent 88dd9b7 commit 00d28a0
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 4 deletions.
4 changes: 2 additions & 2 deletions hydroflow_plus/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub enum HfPlusLeaf {
impl HfPlusLeaf {
pub fn transform_children(
self,
transform: impl Fn(HfPlusNode, &mut SeenTees) -> HfPlusNode,
mut transform: impl FnMut(HfPlusNode, &mut SeenTees) -> HfPlusNode,
seen_tees: &mut SeenTees,
) -> HfPlusLeaf {
match self {
Expand Down Expand Up @@ -246,7 +246,7 @@ pub type SeenTees = HashMap<*const RefCell<HfPlusNode>, Rc<RefCell<HfPlusNode>>>
impl HfPlusNode {
pub fn transform_children(
self,
transform: impl Fn(HfPlusNode, &mut SeenTees) -> HfPlusNode,
mut transform: impl FnMut(HfPlusNode, &mut SeenTees) -> HfPlusNode,
seen_tees: &mut SeenTees,
) -> HfPlusNode {
match self {
Expand Down
1 change: 1 addition & 0 deletions hydroflow_plus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub use builder::FlowBuilder;
pub mod ir;

pub mod persist_pullup;
pub mod profiler;

#[derive(Clone)]
pub struct RuntimeContext<'a> {
Expand Down
5 changes: 3 additions & 2 deletions hydroflow_plus/src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ mod tests {
.map(q!(|v| v + 1))
.for_each(q!(|n| println!("{}", n)));

let built = flow.build();
let built = flow.extract();

insta::assert_debug_snapshot!(&built.ir);

let pushed_down = built.optimize_with(|ir| super::profiling(ir, flow.runtime_context()));
let counters = RuntimeData::new("Fake");
let pushed_down = built.optimize_with(|ir| super::profiling(ir, flow.runtime_context(), counters));

insta::assert_debug_snapshot!(&pushed_down.ir);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
source: hydroflow_plus/src/profiler.rs
assertion_line: 62
expression: "&pushed_down.ir"
---
[
ForEach {
f: { use crate :: __staged :: profiler :: tests :: * ; | n | println ! ("{}" , n) },
input: Map {
f: { use crate :: __staged :: profiler :: * ; let counters_copy = Fake ; let my_id = 0u32 ; let context = & context ; let my_id = 32668u32 ; let counters = Fake ; let my_id = 32668u32 ; { counters_copy . borrow_mut () [my_id as usize] = 0 ; move | v | { hydroflow_plus :: profiler :: increment_counter (context . current_tick () , my_id , & mut counters . borrow_mut () [my_id as usize]) ; v } } },
input: Map {
f: { use crate :: __staged :: profiler :: tests :: * ; | v | v + 1 },
input: Map {
f: { use crate :: __staged :: profiler :: * ; let counters_copy = Fake ; let my_id = 1u32 ; let context = & context ; let my_id = 32668u32 ; let counters = Fake ; let my_id = 32668u32 ; { counters_copy . borrow_mut () [my_id as usize] = 0 ; move | v | { hydroflow_plus :: profiler :: increment_counter (context . current_tick () , my_id , & mut counters . borrow_mut () [my_id as usize]) ; v } } },
input: Persist(
Map {
f: { use crate :: __staged :: profiler :: * ; let counters_copy = Fake ; let my_id = 2u32 ; let context = & context ; let my_id = 32668u32 ; let counters = Fake ; let my_id = 32668u32 ; { counters_copy . borrow_mut () [my_id as usize] = 0 ; move | v | { hydroflow_plus :: profiler :: increment_counter (context . current_tick () , my_id , & mut counters . borrow_mut () [my_id as usize]) ; v } } },
input: Source {
source: Iter(
{ use crate :: __staged :: profiler :: tests :: * ; 0 .. 10 },
),
location_id: 0,
},
},
),
},
},
},
},
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
source: hydroflow_plus/src/profiler.rs
assertion_line: 57
expression: "&built.ir"
---
[
ForEach {
f: { use crate :: __staged :: profiler :: tests :: * ; | n | println ! ("{}" , n) },
input: Map {
f: { use crate :: __staged :: profiler :: tests :: * ; | v | v + 1 },
input: Persist(
Source {
source: Iter(
{ use crate :: __staged :: profiler :: tests :: * ; 0 .. 10 },
),
location_id: 0,
},
),
},
},
]

0 comments on commit 00d28a0

Please sign in to comment.