changeset 1658:ed2fa50168ef draft

fix fft
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Tue, 09 Jul 2013 19:15:56 +0900
parents 6fe17b1c8cf3
children 0d25364759e0
files example/fft/main.cc example/fft/ppe/butterfly.cc example/fft/ppe/highPassFilter.cc example/fft/ppe/norm.cc
diffstat 4 files changed, 32 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/example/fft/main.cc	Thu Jul 04 18:02:48 2013 +0900
+++ b/example/fft/main.cc	Tue Jul 09 19:15:56 2013 +0900
@@ -127,27 +127,31 @@
     brev->wait_for(waitTask);
     brev->iterate(gws[0],gws[1]);
 
-    HTask* bfly = manager->create_task(BUTTERFLY);
+    waitTask = brev;
+    
     setWorkSize(gws,lws,n/2,n);
-    bfly->set_inData(0, dst, length_dst*sizeof(cl_float2));
-    bfly->set_inData(1, spin, sizeof(cl_float2)*(n/2));
-    bfly->set_outData(0,dst,length_dst*sizeof(cl_float2));
-    bfly->set_param(3,n);
-    bfly->set_param(4,direction_flag);
-    bfly->set_cpu(spe_cpu);
-    bfly->wait_for(brev);
-    bfly->iterate(gws[0],gws[1],m);
-
-    waitTask = bfly;
+    for(int iter=1;iter<=m;iter++) {
+        HTask* bfly = manager->create_task(BUTTERFLY);
+        bfly->set_inData(0, dst, length_dst*sizeof(cl_float2));
+        bfly->set_inData(1, spin, sizeof(cl_float2)*(n/2));
+        bfly->set_outData(0,dst,length_dst*sizeof(cl_float2));
+        bfly->set_param(3,n);
+        bfly->set_param(4,direction_flag);
+        bfly->set_param(5,iter);
+        bfly->set_cpu(spe_cpu);
+        bfly->wait_for(waitTask);
+        bfly->iterate(gws[0],gws[1]);
+        waitTask = bfly;
+    }
     
     if (direction == inverse) { 
+        setWorkSize(gws,lws,n,n);
         HTask *norm = manager->create_task(NORMALIZATION);
-        setWorkSize(gws,lws,n,n);
+        norm->set_inData(0,dst,length_dst*sizeof(cl_float2));
         norm->set_outData(0, dst, length_dst*sizeof(cl_float2));
         norm->set_param(3,n);
         norm->set_cpu(spe_cpu);
-        norm->flip();
-        norm->wait_for(bfly);
+        norm->wait_for(waitTask);
         norm->iterate(gws[0],gws[1]);
         
         waitTask = norm;
@@ -211,9 +215,9 @@
     }
         
     // Create spin factor
+    setWorkSize(gws,lws,n/2,1);
     int length_w = n / 2;
     HTask* sfac = manager->create_task(SPIN_FACT);
-    setWorkSize(gws,lws,n/2,1);
     sfac->set_outData(0, wm, length_w*sizeof(cl_float2));
     sfac->set_param(3,n);
     sfac->set_cpu(spe_cpu);
@@ -234,12 +238,13 @@
     first_trns->iterate(gws[0],gws[1]);
 
     // Butterfly Operation 
-    waitTask = fftCore(manager, rm, xm, wm, m, forward,first_trns);
+    waitTask = fftCore(manager, xm, rm, wm, m, forward,first_trns);
 
     // Apply high-pass filter
     HTask *hpfl = manager->create_task(HIGH_PASS_FILTER);
     cl_int radius = n/8;
     setWorkSize(gws,lws,n,n);
+    hpfl->set_inData(0,rm,length_r*sizeof(cl_float2));
     hpfl->set_outData(0, rm, length_r*sizeof(cl_float2));
     hpfl->set_param(3,n);
     hpfl->set_param(4,radius);
--- a/example/fft/ppe/butterfly.cc	Thu Jul 04 18:02:48 2013 +0900
+++ b/example/fft/ppe/butterfly.cc	Tue Jul 09 19:15:56 2013 +0900
@@ -17,10 +17,10 @@
 
     unsigned long gid = (unsigned long)s->get_param(0);
     unsigned long nid = (unsigned long)s->get_param(1);
-    long iter = (long)s->get_param(2) + 1;
-
+    
     long n = (long)s->get_param(3);
     long direction_flag = (long)s->get_param(4);
+    long iter = (long)s->get_param(5);
 
     int butterflySize = 1 << (iter-1);
     int butterflyGrpDist = 1 << iter;
--- a/example/fft/ppe/highPassFilter.cc	Thu Jul 04 18:02:48 2013 +0900
+++ b/example/fft/ppe/highPassFilter.cc	Tue Jul 09 19:15:56 2013 +0900
@@ -10,6 +10,8 @@
 static int
 highPassFilter(SchedTask* s,void* rbuf,void* wbuf)
 {
+    cl_float2* in = (cl_float2*)s->get_inputAddr(0);
+
     cl_float2* image = (cl_float2*)s->get_outputAddr(0);
 
     unsigned long xgid = (unsigned long)s->get_param(0);
@@ -46,8 +48,8 @@
         window.x = window.y = (int)-1L;
     }
 
-    image[ygid*n+xgid].x = (float)((int)image[ygid*n+xgid].x & window.x);
-    image[ygid*n+xgid].y = (float)((int)image[ygid*n+xgid].y & window.y);
+    image[ygid*n+xgid].x = (float)((int)in[ygid*n+xgid].x & window.x);
+    image[ygid*n+xgid].y = (float)((int)in[ygid*n+xgid].y & window.y);
 
     return 0;
 }
--- a/example/fft/ppe/norm.cc	Thu Jul 04 18:02:48 2013 +0900
+++ b/example/fft/ppe/norm.cc	Tue Jul 09 19:15:56 2013 +0900
@@ -10,15 +10,17 @@
 static int
 norm(SchedTask* s, void* rbuf,void* wbuf)
 {
-    cl_float2* x = (cl_float2*)s->get_outputAddr(0);
+    cl_float2* in_x = (cl_float2*)s->get_inputAddr(0);
+
+    cl_float2* out_x = (cl_float2*)s->get_outputAddr(0);
 
     unsigned long gid = (unsigned long)s->get_param(0);
     unsigned long nid = (unsigned long)s->get_param(1);
 
     long n = (long)s->get_param(3);
 
-    x[nid*n+gid].x = x[nid*n+gid].x / (float)n;
-    x[nid*n+gid].y = x[nid*n+gid].y / (float)n;
+    out_x[nid*n+gid].x = in_x[nid*n+gid].x / (float)n;
+    out_x[nid*n+gid].y = in_x[nid*n+gid].y / (float)n;
 
     return 0;
 }