diff --git a/hercules_opt/src/unforkify.rs b/hercules_opt/src/unforkify.rs index 2d6cf7b36f44864d67ef4ee505203de12ee59bff..2deb716564829cfa6f7d34ad128dc353d164c794 100644 --- a/hercules_opt/src/unforkify.rs +++ b/hercules_opt/src/unforkify.rs @@ -313,6 +313,12 @@ pub fn unforkify( edit = edit.delete_node(*reduce)?; } + edit.sub_edit(fork, proj_exit_id); + edit.sub_edit(fork, proj_back_id); + edit.sub_edit(fork, neq_id); + edit.sub_edit(fork, add_id); + + edit = edit.delete_node(fork)?; edit = edit.delete_node(join)?; for tid in tids { diff --git a/juno_samples/cava/Cargo.toml b/juno_samples/cava/Cargo.toml index bdf144da56d0a99d46aad8beffdf4615b01790c9..279a81f0f2784bd251eaf04b36895e638d3e952b 100644 --- a/juno_samples/cava/Cargo.toml +++ b/juno_samples/cava/Cargo.toml @@ -14,6 +14,7 @@ path = "src/lib.rs" [features] cuda = ["juno_build/cuda", "hercules_rt/cuda"] seq = [] +dont_fuse_gamut = [] [build-dependencies] juno_build = { path = "../../juno_build" } diff --git a/juno_samples/cava/src/cpu.sch b/juno_samples/cava/src/cpu.sch index ada2f552fb1f31412d3f9a0bfe5c27884d4d86e6..7d788c2f099ca664d9e2ff751fde3394a1623cdd 100644 --- a/juno_samples/cava/src/cpu.sch +++ b/juno_samples/cava/src/cpu.sch @@ -111,11 +111,15 @@ fixpoint { fork-fusion(fuse4@channel_loop); } simpl!(fuse4); -array-slf(fuse4); -simpl!(fuse4); + +if !feature("dont_fuse_gamut") { + array-slf(fuse4); + simpl!(fuse4); +} if !feature("seq") { let par = fuse4@image_loop \ fuse4@channel_loop; + let par = par \ fuse4@cp_loop; fork-tile[4, 1, false, false](par); fork-tile[8, 0, false, false](par); fork-interchange[1, 2](par); diff --git a/juno_samples/cava/src/gpu.sch b/juno_samples/cava/src/gpu.sch index 0ef466c00d08f3edffe02bad9612ce23ebf14768..daf523391fac697c2c1edf8ee02f4f13141bfcd2 100644 --- a/juno_samples/cava/src/gpu.sch +++ b/juno_samples/cava/src/gpu.sch @@ -115,12 +115,25 @@ fixpoint { fork-fusion(fuse4@channel_loop); } simpl!(fuse4); -array-slf(fuse4); -simpl!(fuse4); -fork-tile[2, 0, false, true](fuse4@channel_loop); -let out = fork-split(fuse4@channel_loop); -fork-unroll(out.cava_3.fj1); -unforkify(fuse4@channel_loop); + +if !feature("dont_fuse_gamut") { + array-slf(fuse4); + simpl!(fuse4); + fork-tile[2, 0, false, true](fuse4@channel_loop); + let out = fork-split(fuse4@channel_loop); + fork-unroll(out.cava_3.fj1); + unforkify(fuse4@channel_loop); +} + +let par = fuse4@image_loop \ fuse4@channel_loop; +let par = par \ fuse4@cp_loop; + +fork-tile[4, 1, false, true](par); +fork-tile[8, 0, false, true](par); +fork-interchange[1, 2](par); +let split = fork-split(par); +fork-coalesce(split.cava_3.fj0 \ split.cava_3.fj2); +fork-coalesce(split.cava_3.fj2); no-memset(fuse5@res1); no-memset(fuse5@res2); @@ -133,12 +146,7 @@ simpl!(fuse5); array-slf(fuse5); simpl!(fuse5); -fork-tile[4, 1, false, true](fuse4); -fork-tile[8, 0, false, true](fuse4); -fork-interchange[1, 2](fuse4); -let split = fork-split(fuse4); -fork-coalesce(split.cava_3.fj0 \ split.cava_3.fj2); -fork-coalesce(split.cava_3.fj2); + delete-uncalled(*); simpl!(*); diff --git a/juno_samples/edge_detection/Cargo.toml b/juno_samples/edge_detection/Cargo.toml index 8def75003c3728a7da6d257131b628daa5849597..6e53500a0c315971c3049d2662369388532df2c3 100644 --- a/juno_samples/edge_detection/Cargo.toml +++ b/juno_samples/edge_detection/Cargo.toml @@ -8,6 +8,7 @@ edition = "2021" opencv = ["dep:opencv"] cuda = ["juno_build/cuda", "hercules_rt/cuda"] seq = [] +warp_tile = [] [[bin]] name = "juno_edge_detection" diff --git a/juno_samples/edge_detection/benches/edge_detection_bench.rs b/juno_samples/edge_detection/benches/edge_detection_bench.rs index 760352754ccd39df878fa45523c5b7e76dd84f98..1fa08506a5840b252e293ddee36b72b7f359d78a 100644 --- a/juno_samples/edge_detection/benches/edge_detection_bench.rs +++ b/juno_samples/edge_detection/benches/edge_detection_bench.rs @@ -17,6 +17,7 @@ juno_build::juno!("edge_detection"); fn edge_detection_bench(c: &mut Criterion) { let mut group = c.benchmark_group("edge detection bench"); group.sample_size(10); + group.measurement_time(std::time::Duration::from_secs(25)); let input = "examples/formula1_scaled.mp4"; diff --git a/juno_samples/edge_detection/src/gpu.sch b/juno_samples/edge_detection/src/gpu.sch index 666f6cef30f0c0ecedef57f02e50bc25d2b26b8f..3a541dab08e230336b654d47ca8aa21cc90c0b27 100644 --- a/juno_samples/edge_detection/src/gpu.sch +++ b/juno_samples/edge_detection/src/gpu.sch @@ -95,22 +95,54 @@ fixpoint { fork-guard-elim(max_gradient); fork-coalesce(max_gradient); } -simpl!(max_gradient); -fork-dim-merge(max_gradient); -simpl!(max_gradient); -fork-tile[32, 0, false, true](max_gradient); -let out = fork-split(max_gradient); -clean-monoid-reduces(max_gradient); -simpl!(max_gradient); -let fission = fork-fission[out._4_max_gradient.fj0](max_gradient); -simpl!(max_gradient); -fork-tile[32, 0, false, true](fission._4_max_gradient.fj_bottom); -let out = fork-split(fission._4_max_gradient.fj_bottom); -clean-monoid-reduces(max_gradient); -simpl!(max_gradient); -let top = outline(fission._4_max_gradient.fj_top); -let bottom = outline(out._4_max_gradient.fj0); -gpu(top, bottom); + +if !feature("seq") { + if !feature("warp_tile") { + simpl!(max_gradient); + fork-dim-merge(max_gradient); + simpl!(max_gradient); + fork-tile[32, 0, false, true](max_gradient); + let out1 = fork-split(max_gradient); + clean-monoid-reduces(max_gradient); + simpl!(max_gradient); + let fission = fork-fission[out1._4_max_gradient.fj0](max_gradient); + simpl!(max_gradient); + fork-tile[32, 0, false, true](fission._4_max_gradient.fj_bottom); + let out2 = fork-split(fission._4_max_gradient.fj_bottom); + clean-monoid-reduces(max_gradient); + simpl!(max_gradient); + unforkify(out1._4_max_gradient.fj1); + + unforkify(out2._4_max_gradient.fj1); + simpl!(max_gradient); + let top = outline(fission._4_max_gradient.fj_top); + let bottom = outline(out2._4_max_gradient.fj0); + gpu(top, bottom); + } else { + simpl!(max_gradient); + fork-dim-merge(max_gradient); + simpl!(max_gradient); + fork-tile[32, 0, false, true](max_gradient); + let out = fork-split(max_gradient); + clean-monoid-reduces(max_gradient); + simpl!(max_gradient); + let fission = fork-fission[out._4_max_gradient.fj0](max_gradient); + simpl!(max_gradient); + fork-tile[32, 0, false, true](fission._4_max_gradient.fj_bottom); + let out = fork-split(fission._4_max_gradient.fj_bottom); + clean-monoid-reduces(max_gradient); + simpl!(max_gradient); + let top = outline(fission._4_max_gradient.fj_top); + let bottom = outline(out._4_max_gradient.fj0); + gpu(top, bottom); + } +} else { + simpl!(max_gradient); + fork-split(max_gradient); + unforkify(max_gradient); + gpu(max_gradient); +} + ip-sroa(*); sroa(*); simpl!(*);