IPP 的FFT测试

来源:互联网 发布:c c 高性能网络库 编辑:程序博客网 时间:2024/05/22 22:29

double双精度型复数fft测试

平台:Intel Core(TM)2 Duo CPU E8500 3.16GHz 3.16GHz

4.00GB内存  32位win7

ipp测试代码: 

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <ipps.h>

/* Maximum value that can be returned by the rand function. */
#ifndef RAND_MAX
#define RAND_MAX 0x7fff
#endif
int main()
{
    double t0;
    unsigned int myOrder,myLength,n;
    int myBufferSize;
    Ipp8u *myBuffer;
    Ipp64fc *myA,*myB;
    IppsFFTSpec_C_64fc *mySpec;
    for (myOrder = 10; myOrder < 22; myOrder++)
    {
        myLength = 1 << myOrder;
        ippsFFTInitAlloc_C_64fc(&mySpec, myOrder, IPP_FFT_NODIV_BY_ANY, ippAlgHintFast);

        myBufferSize = 0;
        ippsFFTGetBufSize_C_64fc(mySpec, &myBufferSize);
        myBuffer = ippsMalloc_8u(myBufferSize);

        myA = ippsMalloc_64fc(myLength);
        myB = ippsMalloc_64fc(myLength);
        for(n = 0; n < myLength; ++n)
        {
            myA[n].re = rand()/RAND_MAX;
            myA[n].im = rand()/RAND_MAX;
        }

        t0=clock();
            ippsFFTFwd_CToC_64fc(myA, myB, mySpec, myBuffer);
        printf("%8.d  %20.10f       /n",myLength,(clock()-t0)/CLOCKS_PER_SEC); 


        ippsFree(myA);
        ippsFree(myB);
        ippsFree(myBuffer);
        ippsFFTFree_C_64fc(mySpec);
    }
    system("pause");
}

 

make命令:


@echo off
rem call "D:/Microsoft Visual Studio 10.0/VC/bin/VCVARS32.BAT"
call "C:/Program Files/Intel/Parallel Studio 2011/ips-vars.cmd"
call "C:/Program Files/Intel/Parallel Studio 2011/Composer/ipp/bin/ippvars.bat"

icl /c /o3 ipptest.c

xilink /subsystem:console ipptest.obj ipps.lib


del *.obj

pause

 

结果:

     n                 time (s)

    1024          0.0000000000
    2048          0.0000000000
    4096          0.0030000000
    8192          0.0000000000
   16384          0.0010000000
   32768          0.0010000000
   65536          0.0030000000
  131072          0.0040000000
  262144          0.0090000000
  524288          0.0190000000
 1048576          0.0470000000
 2097152          0.0900000000
请按任意键继续. . .

//=============================================

ooura_fft  测试:使用fftsg_h.c

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
/* Maximum value that can be returned by the rand function. */
#ifndef RAND_MAX
#define RAND_MAX 0x7fff
#endif

#ifdef __cplusplus
extern "C" {
#endif
void cdft(int n, int isgn, double *a);
#ifdef __cplusplus
}
#endif


void  initTestData(double  *data,int len)
{
 int i;
 for (i=0;i<len;i++)
 {
  data[2*i]=(double)(rand() % RAND_MAX);
  data[2*i+1]=(double)(rand() % RAND_MAX);
 }

}

void testSpeed_oouraFFT(int maxLen)
{
 int  len,c;
 double k,t,tmp,t0;
 double *data=NULL;
 data =(double *)malloc( (maxLen*2+1)*sizeof(double) );
 if (data==NULL)
  return ;

 printf("    len  /tfft time /n");
 for (len=1024;len<=maxLen;len*=2)
 {
  
  initTestData(data,len);
  t0=clock();
        cdft(len*2,1,data);  
        printf("%8.d  %20.10f       /n",len,(clock()-t0)/CLOCKS_PER_SEC);
 }
    if (data!=NULL)
  free(data);

}
int main()
{
 testSpeed_oouraFFT(2*1048576);
 system("pause");
 return 0;
}

 

make命令:


@echo off
rem call "D:/Microsoft Visual Studio 10.0/VC/bin/VCVARS32.BAT"
call "C:/Program Files/Intel/Parallel Studio 2011/ips-vars.cmd"
icl /c /o3 fftsg_h.c test_speedFFT.c

xilink /subsystem:console test_speedFFT.obj fftsg_h.obj

rem icl /help

del *.obj

pause

 

结果:

    n                   time(s)
    1024          0.0010000000
    2048          0.0000000000
    4096          0.0000000000
    8192          0.0000000000
   16384          0.0000000000
   32768          0.0010000000
   65536          0.0010000000
  131072          0.0060000000
  262144          0.0110000000
  524288          0.0200000000
 1048576          0.0560000000
 2097152          0.1080000000
请按任意键继续. . .

 

 

 

 

 

 

 

原创粉丝点击