From 3b5dfee9614b6a5ed90ef8c2a3b695f0dade7ef8 Mon Sep 17 00:00:00 2001 From: Mark Borgerding Date: Sat, 9 Jul 2005 03:42:07 +0000 Subject: [PATCH] added kiss_fft_cleanup updated Makefiles for long and simd targets --- Makefile | 2 +- TIPS | 4 ++++ kiss_fft.c | 16 +++++++++++++++- kiss_fft.h | 7 +++++++ test/Makefile | 4 ++-- tools/Makefile | 12 +++++++++--- 6 files changed, 38 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index ef68d11..b20a743 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ ZIPFILE=kiss_fft_v$(KFVER).zip testall: # 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=short && cd test && make test diff --git a/TIPS b/TIPS index 5007c40..c02f0c4 100644 --- a/TIPS +++ b/TIPS @@ -10,6 +10,10 @@ Speed: * If the input data has no imaginary component, use the kiss_fftr code under tools/. 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: * 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 diff --git a/kiss_fft.c b/kiss_fft.c index 0c26f66..e4c4044 100644 --- a/kiss_fft.c +++ b/kiss_fft.c @@ -26,7 +26,8 @@ static size_t ntmpbuf=0; #define CHECKBUF(buf,nbuf,n) \ do { \ 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); \ } \ }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); } + +/* 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; +} diff --git a/kiss_fft.h b/kiss_fft.h index a0e232f..4919c5c 100644 --- a/kiss_fft.h +++ b/kiss_fft.h @@ -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*/ #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 } #endif diff --git a/test/Makefile b/test/Makefile index 9fe7c3b..30f5e55 100644 --- a/test/Makefile +++ b/test/Makefile @@ -54,9 +54,9 @@ tools: cd ../tools && make all # 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 -#CFLAGS=-Wall -O3 -I.. -I../tools $(WARNINGS) +#CFLAGS=-O3 -I.. -I../tools $(WARNINGS) $(SELFTEST): $(SELFTESTSRC) $(SRCFILES) $(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) -lm $+ diff --git a/tools/Makefile b/tools/Makefile index fa3fe46..0110ee4 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -6,17 +6,23 @@ ifeq "$(DATATYPE)" "" DATATYPE=float endif +ifeq "$(DATATYPE)" "long" + TYPEFLAGS=-DFIXED_POINT=32 +endif ifeq "$(DATATYPE)" "short" - TYPEFLAGS=-DFIXED_POINT -Dkiss_fft_scalar=short -else - TYPEFLAGS=-Dkiss_fft_scalar=$(DATATYPE) + TYPEFLAGS=-DFIXED_POINT=16 endif ifeq "$(DATATYPE)" "simd" TYPEFLAGS=-DUSE_SIMD=1 -msse endif +ifeq "$(TYPEFLAGS)" "" + TYPEFLAGS=-Dkiss_fft_scalar=$(DATATYPE) +endif + + ifeq "$(DATATYPE)" "float" FFTUTIL=fft FASTFILT=fastconv