Update of /cvsroot/audacity/lib-src/libnyquist/nyquist/ffts/Timing-code
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv8506/ffts/Timing-code
Added Files:
fftTiming.c rfftTiming.c
Log Message:
Updating to Nyquist v3.03.
--- NEW FILE: rfftTiming.c ---
/* A program to time real input fast fourier transform routine */
#include <stdio.h>
#include <stdlib.h>
#include <fp.h>
#include <math.h>
#include "fftlib.h"
#include "fftext.h"
#if macintosh
#include <timer.h>
#endif
#define NSIZES 3 /* the number of different fft sizes to time */
void main(){
float *a;
long fftSize[NSIZES] = {2048, 32768, 524288}; /* size of FFTs, must
be powers of 2 */
long fftRepeats[NSIZES] = {2000, 50, 1}; /* number of timing
loops */
long isize;
long i1;
long TheErr;
long N;
long M;
#if macintosh
UnsignedWide TheTime1;
UnsignedWide TheTime2;
double TheTime;
#endif
printf(" %6d Byte Floats \n", sizeof(a[0]));
for (isize = 0; isize < NSIZES; isize++){
N = fftSize[isize];
printf("rffts size = %9d ", N);
M = roundtol(LOG2(N));
TheErr = fftInit(M);
if(!TheErr){
a = (float *) malloc(N*sizeof(float));
if (a == 0) TheErr = 2;
}
if(!TheErr){
/* set up a simple test case */
for (i1=0; i1<N; i1++){
a[i1] = sqrt(i1+.77777);
}
#if macintosh
/* make sure routines
are in physical (not virtual) memory */
Microseconds(&TheTime1);
rffts(a, M, 1);
riffts(a, M, 1);
Microseconds(&TheTime1);
for (i1 = 0; i1 < fftRepeats[isize]; i1++){ /* do
many times for timing */
rffts(a, M, 1);
riffts(a, M, 1);
}
Microseconds(&TheTime2);
TheTime = (double)(TheTime2.hi - TheTime1.hi) * 65536.0 *
65536.0;
TheTime = (TheTime + (double)(TheTime2.lo - TheTime1.lo));
printf("Ave of rffts & riffts Times = %14.1f µs.\n",
TheTime/fftRepeats[isize]/2);
#else
printf("start timing %12d real fft's\n", fftRepeats[isize]*2);
for (i1=0;i1<fftRepeats[isize];i1++){ /* do many
times for timing */
rffts(a, M, 1);
riffts(a, M, 1);
}
printf("end timing \n");
#endif
free (a);
fftFree();
}
else{
if(TheErr==2) printf(" out of memory ");
else printf(" error ");
fftFree();
}
}
printf(" Done. \n");
return;
}
--- NEW FILE: fftTiming.c ---
/* A program to time complex forward and inverse fast fourier transform
routines */
void four1(float data[], unsigned long nn, int isign);
#include <stdio.h>
#include <stdlib.h>
#include <fp.h>
#include <math.h>
#include "fftlib.h"
#include "fftext.h"
#if macintosh
#include <timer.h>
#endif
#define NSIZES 3 /* the number of different ffts sizes to time */
typedef struct{
float Re;
float Im;
} Complex;
void main(){
long fftSize[NSIZES] = {1024, 16384, 262144}; /* size of FFTs, must
be powers of 2 */
long fftRepeats[NSIZES] = {2000, 50, 1}; /* number of timing
loops */
Complex *a;
long isize;
long i1;
long TheErr;
long N;
long M;
#if macintosh
UnsignedWide TheTime1;
UnsignedWide TheTime2;
double TheTime;
#endif
printf(" %6d Byte Floats \n", sizeof(a[0].Re));
for (isize = 0; isize < NSIZES; isize++){
N = fftSize[isize];
printf("ffts size = %7d, ", N);
M = roundtol(LOG2(N));
TheErr = fftInit(M);
if(!TheErr){
a = (Complex *) malloc(N*sizeof(Complex) );
if (a == 0) TheErr = 2;
}
if(!TheErr){
/* set up a simple test case */
for (i1=0; i1<N; i1++){
a[i1].Re = sqrt(i1+.77777);
a[i1].Im = sqrt(i1+.22222);
}
#if macintosh
/* make sure routines
are in physical (not virtual) memory */
Microseconds(&TheTime1);
ffts((float *)a, M, 1);
iffts((float *)a, M, 1);
Microseconds(&TheTime1);
for (i1=0;i1<fftRepeats[isize];i1++){ /* do many
times for timing */
ffts((float *)a, M, 1);
iffts((float *)a, M, 1);
}
Microseconds(&TheTime2);
TheTime = (double)(TheTime2.hi - TheTime1.hi) * 65536.0 *
65536.0;
TheTime = (TheTime + (double)(TheTime2.lo - TheTime1.lo));
printf("ffts time = %12.1f µs, a[0].Re=%6e\n",
TheTime/fftRepeats[isize]/2, a[0].Re);
#else
printf("start timing %12d real ffts's\n", fftRepeats[isize]*2);
for (i1=0;i1<fftRepeats[isize];i1++){ /* do many
times for timing */
ffts((float *)a, M, 1);
iffts((float *)a, M, 1);
}
printf("end timing \n");
#endif
free(a);
fftFree();
}
else{
if(TheErr==2) printf(" out of memory \n");
else printf(" error \n");
fftFree();
}
}
printf(" Done. \n");
return;
}
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs