close
 

參考資料: Using GPU_FFT with data 

             Using GPU_FFT with data – part2


#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include "mailbox.h"
#include "gpu_fft.h"
int main()
{
   int ret, m, l, d, j, k, i, ii, iii, w, freq;
   m = mbox_open();
   l = 8;               //length
   d = GPU_FFT_FWD;     //direction
   j = 255;             //jobs
   k = 1;               //loops
   float data[j];
   for (i=0; i<j; i++)  //loop to make false data set
   {
      data[i] = i*.00001;
      //printf("data[%d] = %f\n", i, data[i]);
   }
   struct GPU_FFT *fft;
   gpu_fft_prepare(m, l, d, j, &fft);
   for(i=0; i<k; i++)
   {
      for(iii=0; iii<j; iii++)  //input buffer loop
      {
         struct GPU_FFT_COMPLEX *in = fft->in + j*fft->step;
/*setting all mem to 0 in order to have guard space between buffers*/
         for (ii=0; ii<j+1; ii++)
         {
             in[ii].re=in[ii].im=0;
         }
/*sending data set to input buffer, excluding first and last address so they are still zero*/
         freq = iii+1;
         in[freq].re = data[iii];
         in[j-1].re = 0;
         //printf("in[%d].re = %f\n", iii, in[iii].re);
      }
      gpu_fft_execute(fft);
/*assigning buffer address to pointer out*/
      struct GPU_FFT_COMPLEX *out = fft->out+iii*fft->step;
/*attempting to print values of output buffer, should be values created by gpu_fft_execute*/
      for(w=0; w<j; w++) //output print loop
      {
      printf("real out[%d].re = %f\n", w, out[w].re);
      }
   }
   gpu_fft_release(fft);
   printf("END END END END END END END END END END END END END END END END END END\n");
   return 0;
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

    me1237guy 發表在 痞客邦 留言(0) 人氣()