add c version for FilterBank version and fix original Bamboo version to reduce some...
authorjzhou <jzhou>
Wed, 4 Feb 2009 20:01:18 +0000 (20:01 +0000)
committerjzhou <jzhou>
Wed, 4 Feb 2009 20:01:18 +0000 (20:01 +0000)
Robust/src/Benchmarks/Scheduling/FilterBank/FilterBank.java
Robust/src/Benchmarks/Scheduling/FilterBank/c/Makefile [new file with mode: 0644]
Robust/src/Benchmarks/Scheduling/FilterBank/c/filterbank.c [new file with mode: 0644]

index 47de0210adef9eef4b465892f466deb5d999281e..a1dc9e49650fafa115e6919545e2f663ac192b0a 100644 (file)
@@ -7,15 +7,20 @@ task t1(StartupObject s{initialstate}) {
        int N_col=128;
        int i,j;
 
-       float r[] = new float[N_sim];
+       /*float r[] = new float[N_sim];
        for (i=0;i<N_sim;i++) {
                r[i]=i+1;
-       }
+       }*/
        
        for(j = 0; j < N_ch; j++) {
-               FilterBankAtom fba = new FilterBankAtom(j, N_ch, N_col, N_sim, N_samp, r/*, H, F*/){tosamp};
+               FilterBankAtom fba = new FilterBankAtom(j, 
+                                                       N_ch, 
+                                                       N_col, 
+                                                       N_sim, 
+                                                       N_samp/*, 
+                                                       r*/){tosamp};
        }
-       FilterBank fb = new FilterBank(N_sim, N_ch){!finish};
+       FilterBank fb = new FilterBank(N_sim, N_ch){!finish, !print};
 
        taskexit(s{!initialstate});
 }
@@ -23,7 +28,7 @@ task t1(StartupObject s{initialstate}) {
 task t2(FilterBankAtom fba{tosamp}) {
        //System.printString("task t2\n");
        
-       fba.init();
+       //fba.init();
        fba.FBCore();
 
        taskexit(fba{!tosamp, tomerge});
@@ -67,18 +72,20 @@ public class FilterBank {
        }
 
        public boolean merge(float[] result) {
-               for(int i = 0; i < this.N_sim; i++) {
-                       this.y[i] += result[i];
-               }
-               this.counter--;
+           float[] ty = this.y;
+           int Nsim = this.N_sim;
+           for(int i = 0; i < Nsim; i++) {
+               ty[i] += result[i];
+           }
+           this.counter--;
 
-               return this.counter == 0;
+           return this.counter == 0;
        }
 
        public void print() {
-               /*for(int i = 0; i < this.N_sim; i++) {
-                       //System.printI((int)this.y[i]);
-               }*/
+               for(int i = 0; i < this.N_sim; i++) {
+                       System.printI((int)(this.y[i] * 10000));
+               }
        }
 }
 
@@ -92,26 +99,31 @@ public class FilterBankAtom {
        int N_col;
        int N_sim;
        int N_samp;
-       float[] r;
-       float[] H;
+       //float[] r;
+       /*float[] H;
        float[] F;
        float[] vH;
        float[] vDn;
-       float[] vUp;
+       float[] vUp;*/
        public float[] vF;
 
-       public FilterBankAtom(int cindex, int N_ch, int N_col, int N_sim, int N_samp, float[] r/*, float[] H, float[] F*/) {
+       public FilterBankAtom(int cindex, 
+                             int N_ch, 
+                             int N_col, 
+                             int N_sim, 
+                             int N_samp/*, 
+                             float[] r*/) {
            this.ch_index = cindex;
            this.N_ch = N_ch;
            this.N_col = N_col;
            this.N_sim = N_sim;
            this.N_samp = N_samp;
-           this.r = r;
+           /*this.r = r;
            //this.H = null;
            //this.F = null;
            this.vH = new float[this.N_sim];
            this.vDn = new float[(int) this.N_sim/this.N_samp];
-           this.vUp = new float[this.N_sim];
+           this.vUp = new float[this.N_sim];*/
            this.vF = new float[this.N_sim];
            /*this.H[] = new float[N_col];
            this.F[] = new float[N_col];
@@ -121,7 +133,7 @@ public class FilterBankAtom {
            }*/
        }
        
-       public void init() {
+       /*public void init() {
            int j = this.ch_index;
            this.H = new float[this.N_col];
            this.F = new float[this.N_col];
@@ -129,37 +141,53 @@ public class FilterBankAtom {
                this.H[i]=i*this.N_col+j*this.N_ch+j+i+j+1;
                this.F[i]=i*j+j*j+j+i;
            }
-       }
+       }*/
 
        public void FBCore() {
-               int j,k;
+               int i,j,k;
+               int chindex = this.ch_index;
+               int Ncol = this.N_col;
+               int Nsim = this.N_sim;
+               int Nch = this.N_ch;
+               int Nsamp = this.N_samp;
+               float[] tvF = this.vF;
+               
+               float r[] = new float[Nsim];
+               for (i=0;i<Nsim;i++) {
+                       r[i]=i+1;
+               }
+
+               float[] H = new float[Ncol];
+               float[] F = new float[Ncol];
+               for(i = 0; i < Ncol; i++) {
+                   H[i]=i*Ncol+chindex*Nch+chindex+i+chindex+1;
+                   F[i]=i*chindex+chindex*chindex+chindex+i;
+               }
+               float[] vH = new float[Nsim];
+               float[] vDn = new float[(int)(Nsim/Nsamp)];
+               float[] vUp = new float[Nsim];
 
                //convolving H
-               for (j=0; j< N_sim; j++) {
-                       this.vH[j]=0;
-                       for (k=0; ((k<this.N_col) && ((j-k)>=0)); k++) {
-                               this.vH[j]+=this.H[k]*this.r[j-k];
+               for (j=0; j< Nsim; j++) {
+                       for (k=0; ((k<Ncol) && ((j-k)>=0)); k++) {
+                               vH[j]+=H[k]*r[j-k];
                        }
                }
 
                //Down Samplin
-               for (j=0; j < this.N_sim/this.N_samp; j++) {
-                       this.vDn[j]=this.vH[j*this.N_samp];
+               for (j=0; j < Nsim/Nsamp; j++) {
+                       vDn[j]=vH[j*Nsamp];
                }
 
                //Up Sampling
-               for (j=0; j < this.N_sim; j++) {
-                       this.vUp[j]=0;
-               }
-               for (j=0; j < this.N_sim/this.N_samp; j++) {
-                       this.vUp[j*this.N_samp]=this.vDn[j];
+               for (j=0; j < Nsim/Nsamp; j++) {
+                       vUp[j*Nsamp]=vDn[j];
                }
 
                //convolving F
-               for (j=0; j< this.N_sim; j++) {
-                       this.vF[j]=0;
-                       for (k=0; ((k<this.N_col) && ((j-k)>=0)); k++) {
-                               this.vF[j]+=this.F[k]*this.vUp[j-k];
+               for (j=0; j< Nsim; j++) {
+                       for (k=0; ((k<Ncol) && ((j-k)>=0)); k++) {
+                               tvF[j]+=F[k]*vUp[j-k];
                        }
                }
        }
diff --git a/Robust/src/Benchmarks/Scheduling/FilterBank/c/Makefile b/Robust/src/Benchmarks/Scheduling/FilterBank/c/Makefile
new file mode 100644 (file)
index 0000000..6d2e882
--- /dev/null
@@ -0,0 +1,20 @@
+TOPDIR=/home/jzhou/starsearch
+include $(TOPDIR)/Makefile.include
+
+RGCCFLAGS += -O2 
+RGCCFLAGS += -DRAW 
+
+USE_SLGCC=1
+
+SIM-CYCLES = 10000
+
+ATTRIBUTES += HWIC
+
+TILES = 00
+
+OBJECT_FILES_00 = filterbank.o
+#OBJECT_FILES = JGFSeriesBench.o
+
+# this is for a multi-tile test
+include $(COMMONDIR)/Makefile.all
+#include $(COMMONDIR)/Makefile.single
diff --git a/Robust/src/Benchmarks/Scheduling/FilterBank/c/filterbank.c b/Robust/src/Benchmarks/Scheduling/FilterBank/c/filterbank.c
new file mode 100644 (file)
index 0000000..7bce76f
--- /dev/null
@@ -0,0 +1,134 @@
+#include <math.h>
+#ifdef RAW
+#include <raw.h>
+#else
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#endif
+
+//const int N_sim=2*1024;
+const int N_sim=1200;//2048;
+const int N_samp=8;
+//const int N_ch=N_samp;
+const int N_ch=16;//8;
+const int N_col=128;//32;
+
+void begin(void);
+void FBCore(int N_samp,int N_ch, int N_col,float r[N_sim],float y[N_sim], float H[N_ch][N_col],float F[N_ch][N_col]);
+
+static int numiters = 1;
+
+#ifndef RAW
+int main(int argc, char **argv)
+{
+  int option;
+
+  while ((option = getopt(argc, argv, "i:")) != -1)
+  {
+    switch(option)
+    {
+    case 'i':
+      numiters = atoi(optarg);
+    }
+  }
+
+  begin();
+  return 0;
+}
+#endif
+
+void begin(void){
+
+  float r[N_sim];
+  float y[N_sim];
+  float H[N_ch][N_col];
+  float F[N_ch][N_col];
+
+               
+  int i,j;
+
+  for (i=0;i<N_sim;i++)
+      r[i]=i+1;
+
+
+  for (i=0;i<N_col;i++) {
+
+      for (j=0;j<N_ch;j++){
+         H[j][i]=i*N_col+j*N_ch+j+i+j+1;
+
+         F[j][i]=i*j+j*j+j+i;
+       
+      }
+  }
+
+  while (numiters == -1 || numiters-- > 0) {
+    FBCore(N_samp,N_ch,N_col,r,y,H,F);
+    for (i=0;i<N_sim;i++) {
+#ifdef RAW
+      //print_float(y[i]);
+#else
+      //printf("%f\n", y[i]);
+#endif
+    }
+  }
+
+#ifdef RAW
+    raw_test_pass(raw_get_cycle());
+       raw_test_done(1);
+#endif
+}
+
+
+// the FB core gets the input vector (r) , the filter responses H and F and generates the output vector(y)
+void FBCore(int N_samp,int N_ch, int N_col,float r[N_sim],float y[N_sim], float H[N_ch][N_col],float F[N_ch][N_col])
+{
+  int i,j,k;
+  for (i=0; i < N_sim;i++)
+    y[i]=0;
+
+  for (i=0; i< N_ch; i++)
+    {
+      float Vect_H[N_sim]; //(output of the H)
+      float Vect_Dn[(int) N_sim/N_samp]; //output of the down sampler;
+      float Vect_Up[N_sim]; // output of the up sampler;
+      float Vect_F[N_sim];// this is the output of the
+#ifdef RAW
+               raw_test_pass(raw_get_cycle());
+#endif 
+
+      //convolving H
+      for (j=0; j< N_sim; j++)
+       {
+         Vect_H[j]=0;
+         for (k=0; ((k<N_col) & ((j-k)>=0)); k++)
+           Vect_H[j]+=H[i][k]*r[j-k];
+       }
+
+      //Down Sampling
+      for (j=0; j < N_sim/N_samp; j++)
+       Vect_Dn[j]=Vect_H[j*N_samp];
+
+      //Up Sampling
+      /*for (j=0; j < N_sim;j++)
+       Vect_Up[j]=0;
+      for (j=0; j < N_sim/N_samp;j++)
+       Vect_Up[j*N_samp]=Vect_Dn[j];*/
+
+      //convolving F
+      for (j=0; j< N_sim; j++)
+       {
+         Vect_F[j]=0;
+         /*for (k=0; ((k<N_col) & ((j-k)>=0)); k++)
+           Vect_F[j]+=F[i][k]*Vect_Up[j-k];*/
+       }
+
+      //adding the results to the y matrix
+
+      for (j=0; j < N_sim; j++)
+       y[j]+=Vect_F[j];
+#ifdef RAW
+               raw_test_pass(raw_get_cycle());
+#endif
+    }
+}