mirror of
https://github.com/mborgerding/kissfft.git
synced 2026-11-18 20:09:30 -05:00
allocators: route all library allocations through KISS_FFT_MALLOC/FREE
Users can override KISS_FFT_MALLOC and KISS_FFT_FREE, but several places bypassed them: - kiss_fftnd_alloc and kiss_fftndr_alloc called malloc() directly, so their configs (released with kiss_fft_free / kiss_fftndr_free) went to a different allocator than the one that freed them. - kiss_fftndr_free was defined as plain free. - kfc_cleanup released KISS_FFT_MALLOC'd cache entries with free(). - Under USE_SIMD, KISS_FFT_ALIGN_CHECK and KISS_FFT_ALIGN_SIZE_UP were defined only inside "#ifndef KISS_FFT_MALLOC", so overriding the allocator broke the build. Define them unconditionally. Note that under USE_SIMD the nd/ndr configs now come from the SIMD default allocator (_mm_malloc / aligned_alloc) instead of malloc, so they must be released with kiss_fft_free / kiss_fftndr_free. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ME1hnNaoD3ZcMj9H8TSYkZ
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c2f367e286
commit
f519878387
+10
-2
@@ -46,6 +46,7 @@ ifneq ($(KISSFFT_OPENMP),1)
|
||||
TESTSIZEVAL = tsizeval-$(KISSFFT_DATATYPE)
|
||||
TESTNDRALLOC = tndralloc-$(KISSFFT_DATATYPE)
|
||||
TESTNDALIGN = tndalign-$(KISSFFT_DATATYPE)
|
||||
TESTCUSTOMALLOC = tcustalloc-$(KISSFFT_DATATYPE)
|
||||
TESTKFC = tkfc-$(KISSFFT_DATATYPE)
|
||||
TESTFASTFILT = fastfilt-$(KISSFFT_DATATYPE)
|
||||
TESTCPP = testcpp-$(KISSFFT_DATATYPE)
|
||||
@@ -58,6 +59,7 @@ else
|
||||
TESTSIZEVAL = tsizeval-$(KISSFFT_DATATYPE)-openmp
|
||||
TESTNDRALLOC = tndralloc-$(KISSFFT_DATATYPE)-openmp
|
||||
TESTNDALIGN = tndalign-$(KISSFFT_DATATYPE)-openmp
|
||||
TESTCUSTOMALLOC = tcustalloc-$(KISSFFT_DATATYPE)-openmp
|
||||
TESTKFC = tkfc-$(KISSFFT_DATATYPE)-openmp
|
||||
TESTFASTFILT = fastfilt-$(KISSFFT_DATATYPE)-openmp
|
||||
TESTCPP = testcpp-$(KISSFFT_DATATYPE)-openmp
|
||||
@@ -109,7 +111,7 @@ endif
|
||||
# Target: "make all"
|
||||
#
|
||||
|
||||
all: $(BENCHKISS) $(SELFTEST) $(BENCHFFTW) $(TESTREAL) $(TESTSIZEVAL) $(TESTNDRALLOC) $(TESTNDALIGN) $(TESTKFC) $(TESTFASTFILT)
|
||||
all: $(BENCHKISS) $(SELFTEST) $(BENCHFFTW) $(TESTREAL) $(TESTSIZEVAL) $(TESTNDRALLOC) $(TESTNDALIGN) $(TESTCUSTOMALLOC) $(TESTKFC) $(TESTFASTFILT)
|
||||
|
||||
#
|
||||
# Individual test make rules
|
||||
@@ -134,6 +136,10 @@ $(TESTNDRALLOC): test_fftndr_alloc.c
|
||||
$(TESTNDALIGN): test_nd_alignment.c ../kiss_fftr.c ../kiss_fftnd.c ../kiss_fftndr.c
|
||||
$(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $< -L.. -l$(KISSFFTLIB_SHORTNAME) -lm
|
||||
|
||||
# unity build: compiles the library sources itself with KISS_FFT_MALLOC/FREE overridden, so it must not link the library
|
||||
$(TESTCUSTOMALLOC): test_custom_alloc.c ../kiss_fft.c ../kiss_fftr.c ../kiss_fftnd.c ../kiss_fftndr.c ../kfc.c
|
||||
$(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $< -lm
|
||||
|
||||
$(BENCHKISS): benchkiss.c pstats.c
|
||||
$(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $^ -L.. -l$(KISSFFTLIB_SHORTNAME) -lm
|
||||
|
||||
@@ -197,6 +203,8 @@ endif
|
||||
@LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):.." ./$(TESTNDRALLOC)
|
||||
$(warning ======multi-dimensional FFT state alignment regression test (type= $(KISSFFT_DATATYPE) ))
|
||||
@LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):.." ./$(TESTNDALIGN)
|
||||
$(warning ======custom KISS_FFT_MALLOC/KISS_FFT_FREE regression test (type= $(KISSFFT_DATATYPE) ))
|
||||
@LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):.." ./$(TESTCUSTOMALLOC)
|
||||
$(warning ======timing test (type=$(KISSFFT_DATATYPE)))
|
||||
@LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):.." ./$(BENCHKISS) -x $(NUMFFTS) -n $(NFFT)
|
||||
@[ -x ./$(BENCHFFTW) ] && LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):.." ./$(BENCHFFTW) -x $(NUMFFTS) -n $(NFFT) || true
|
||||
@@ -208,4 +216,4 @@ endif
|
||||
#
|
||||
|
||||
clean:
|
||||
rm -f *~ bm-* st-* tr-* tsizeval-* tndralloc-* tndalign-* kf-* tkfc-* ff-* fastfilt-* *.pyc *.pyo *.dat testcpp-* testsimd testsimd-* _test_library_dummy _test_library_dummy.c
|
||||
rm -f *~ bm-* st-* tr-* tsizeval-* tndralloc-* tndalign-* tcustalloc-* kf-* tkfc-* ff-* fastfilt-* *.pyc *.pyo *.dat testcpp-* testsimd testsimd-* _test_library_dummy _test_library_dummy.c
|
||||
|
||||
Reference in New Issue
Block a user