added kiss_fft_cleanup

updated Makefiles for long and simd targets
This commit is contained in:
Mark Borgerding 2005-07-09 03:42:07 +00:00
parent 553bd4f13a
commit 3b5dfee961
6 changed files with 38 additions and 7 deletions

View File

@ -6,7 +6,7 @@ ZIPFILE=kiss_fft_v$(KFVER).zip
testall: testall:
# The simd and long types may or may not work on your machine # The simd and long types may or may not work on your machine
export DATATYPE=simd && cd test && make test #export DATATYPE=simd && cd test && make test
export DATATYPE=long && cd test && make test export DATATYPE=long && cd test && make test
export DATATYPE=short && cd test && make test export DATATYPE=short && cd test && make test

4
TIPS
View File

@ -10,6 +10,10 @@ Speed:
* If the input data has no imaginary component, use the kiss_fftr code under tools/. * If the input data has no imaginary component, use the kiss_fftr code under tools/.
Real ffts are roughly twice as fast as complex. Real ffts are roughly twice as fast as complex.
* If you can rearrange your code to do 4 FFTs in parallel and you are on a recent Intel or AMD machine,
then you might want to experiment with the USE_SIMD code.
Reducing code size: Reducing code size:
* remove some of the butterflies. There are currently butterflies optimized for radices * remove some of the butterflies. There are currently butterflies optimized for radices
2,3,4,5. It is worth mentioning that you can still use FFT sizes that contain 2,3,4,5. It is worth mentioning that you can still use FFT sizes that contain

View File

@ -26,7 +26,8 @@ static size_t ntmpbuf=0;
#define CHECKBUF(buf,nbuf,n) \ #define CHECKBUF(buf,nbuf,n) \
do { \ do { \
if ( nbuf < (size_t)(n) ) {\ if ( nbuf < (size_t)(n) ) {\
buf = (kiss_fft_cpx*)realloc(buf,sizeof(kiss_fft_cpx)*(n)); \ free(buf); \
buf = (kiss_fft_cpx*)KISS_FFT_MALLOC(sizeof(kiss_fft_cpx)*(n)); \
nbuf = (size_t)(n); \ nbuf = (size_t)(n); \
} \ } \
}while(0) }while(0)
@ -369,3 +370,16 @@ void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout)
kiss_fft_stride(cfg,fin,fout,1); kiss_fft_stride(cfg,fin,fout,1);
} }
/* not really necessary to call, but if someone is doing in-place ffts, they may want to free the
buffers from CHECKBUF
*/
void kiss_fft_cleanup(void)
{
free(scratchbuf);
scratchbuf = NULL;
nscratchbuf=0;
free(tmpbuf);
tmpbuf=NULL;
ntmpbuf=0;
}

View File

@ -99,6 +99,13 @@ void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout
buffer and can be simply free()d when no longer needed*/ buffer and can be simply free()d when no longer needed*/
#define kiss_fft_free free #define kiss_fft_free free
/*
Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
your compiler output to call this before you exit.
*/
void kiss_fft_cleanup(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -54,9 +54,9 @@ tools:
cd ../tools && make all cd ../tools && make all
# for x86 pentium+ machines , these flags work well # for x86 pentium+ machines , these flags work well
CFLAGS=-Wall -O3 -pedantic -march=pentiumpro -ffast-math -fomit-frame-pointer -I.. -I../tools $(WARNINGS) CFLAGS=-O3 -march=pentiumpro -ffast-math -fomit-frame-pointer -I.. -I../tools $(WARNINGS)
# If the above flags do not work, try the following # If the above flags do not work, try the following
#CFLAGS=-Wall -O3 -I.. -I../tools $(WARNINGS) #CFLAGS=-O3 -I.. -I../tools $(WARNINGS)
$(SELFTEST): $(SELFTESTSRC) $(SRCFILES) $(SELFTEST): $(SELFTESTSRC) $(SRCFILES)
$(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) -lm $+ $(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) -lm $+

View File

@ -6,17 +6,23 @@ ifeq "$(DATATYPE)" ""
DATATYPE=float DATATYPE=float
endif endif
ifeq "$(DATATYPE)" "long"
TYPEFLAGS=-DFIXED_POINT=32
endif
ifeq "$(DATATYPE)" "short" ifeq "$(DATATYPE)" "short"
TYPEFLAGS=-DFIXED_POINT -Dkiss_fft_scalar=short TYPEFLAGS=-DFIXED_POINT=16
else
TYPEFLAGS=-Dkiss_fft_scalar=$(DATATYPE)
endif endif
ifeq "$(DATATYPE)" "simd" ifeq "$(DATATYPE)" "simd"
TYPEFLAGS=-DUSE_SIMD=1 -msse TYPEFLAGS=-DUSE_SIMD=1 -msse
endif endif
ifeq "$(TYPEFLAGS)" ""
TYPEFLAGS=-Dkiss_fft_scalar=$(DATATYPE)
endif
ifeq "$(DATATYPE)" "float" ifeq "$(DATATYPE)" "float"
FFTUTIL=fft FFTUTIL=fft
FASTFILT=fastconv FASTFILT=fastconv