From b30b93cd971d2c073df6996dbacdc75a0f177159 Mon Sep 17 00:00:00 2001 From: Mark Borgerding Date: Sun, 19 Apr 2020 09:57:40 -0400 Subject: [PATCH] A test case for issue #40. Segfaults with: make -C test test_simd && ./test/test_simd --- .gitignore | 1 + test/Makefile | 2 ++ test/test_simd.c | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 test/test_simd.c diff --git a/.gitignore b/.gitignore index 94a9531..4b2dede 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ tools/fft_float tools/fft_int16_t tools/fft_int32_t tools/fft_simd +test/test_simd diff --git a/test/Makefile b/test/Makefile index 5de5e56..79bd440 100644 --- a/test/Makefile +++ b/test/Makefile @@ -64,6 +64,8 @@ all: tools $(BENCHKISS) $(SELFTEST) $(BENCHFFTW) $(TESTREAL) $(TESTKFC) tools: cd ../tools && make all +test_simd: test_simd.c $(SRCFILES) + $(CC) -o $@ -g $(CFLAGS) -DUSE_SIMD=1 -msse $+ -lm $(SELFTEST): $(SELFTESTSRC) $(SRCFILES) $(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $+ -lm diff --git a/test/test_simd.c b/test/test_simd.c new file mode 100644 index 0000000..d9c6790 --- /dev/null +++ b/test/test_simd.c @@ -0,0 +1,25 @@ +#include + +static void test1(void) +{ + int is_inverse = 1; + int n[2] = {256,256}; + size_t nbytes = sizeof(kiss_fft_cpx)*n[0]*n[1]; + + kiss_fft_cpx * inbuf = _mm_malloc(nbytes,16); + kiss_fft_cpx * outbuf = _mm_malloc(nbytes,16); + memset(inbuf,0,nbytes); + memset(outbuf,0,nbytes); + + kiss_fftnd_cfg cfg = kiss_fftnd_alloc(n,2,is_inverse,0,0); + kiss_fftnd(cfg,inbuf,outbuf); + kiss_fft_free(cfg); + _mm_free(inbuf); + _mm_free(outbuf); +} + +int main(void) +{ + test1(); + return 0; +}