From 0958995eb70b45d0b7d71994b5f2de47fb8828e3 Mon Sep 17 00:00:00 2001
From: Russel Arbore <russel.jma@gmail.com>
Date: Fri, 14 Feb 2025 14:40:24 -0600
Subject: [PATCH] unroll channel loop in gamut with intention of fusion the
 ctrl pts loop across channels

---
 juno_samples/cava/src/cava.jn | 2 +-
 juno_samples/cava/src/cpu.sch | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/juno_samples/cava/src/cava.jn b/juno_samples/cava/src/cava.jn
index 839e80e2..e6961faf 100644
--- a/juno_samples/cava/src/cava.jn
+++ b/juno_samples/cava/src/cava.jn
@@ -153,7 +153,7 @@ fn gamut<row : usize, col : usize, num_ctrl_pts : usize>(
         l2_dist[cp] = sqrt!::<f32>(v);
       }
 
-      for chan = 0 to CHAN {
+      @channel_loop for chan = 0 to CHAN {
         let chan_val : f32 = 0.0;
         for cp = 0 to num_ctrl_pts {
           chan_val += l2_dist[cp] * weights[cp, chan];
diff --git a/juno_samples/cava/src/cpu.sch b/juno_samples/cava/src/cpu.sch
index e9e3e683..3021f6a0 100644
--- a/juno_samples/cava/src/cpu.sch
+++ b/juno_samples/cava/src/cpu.sch
@@ -99,6 +99,9 @@ fixpoint {
   fork-coalesce(fuse4);
 }
 simpl!(fuse4);
+fork-unroll(fuse4@channel_loop);
+simpl!(fuse4);
+//fork-fusion(fuse4@channel_loop);
 fork-split(fuse4);
 unforkify(fuse4);
 
-- 
GitLab