40 #include "unit_test_common.h" 48 #define TEST_LENGTH_SAMPLES (32768) 49 #define MIN_LENGTH_SAMPLES_CPX (2) 50 #define MIN_LENGTH_SAMPLES_REAL (MIN_LENGTH_SAMPLES_CPX) 51 #define SNR_THRESHOLD_FLOAT32 90.0f 53 #define TEST_COUNT 10000000 55 #define NE10_FFT_PARA_LEVEL 4 91 void test_fft_c2c_1d_float32_conformance()
97 fprintf (stdout,
"----------%30s start\n", __FUNCTION__);
107 fprintf (stdout,
"FFT size %d\n", fftSize);
108 flag_result = test_c2c_alloc (fftSize);
115 memcpy (in_c, testInput_f32, 2 * fftSize *
sizeof (
ne10_float32_t));
116 memcpy (in_neon, testInput_f32, 2 * fftSize *
sizeof (
ne10_float32_t));
118 GUARD_ARRAY (out_c, fftSize * 2);
119 GUARD_ARRAY (out_neon, fftSize * 2);
124 assert_true (CHECK_ARRAY_GUARD (out_c, fftSize * 2));
125 assert_true (CHECK_ARRAY_GUARD (out_neon, fftSize * 2));
128 snr = CAL_SNR_FLOAT32 (out_c, out_neon, fftSize * 2);
129 assert_false ( (snr < SNR_THRESHOLD));
132 memcpy (in_c, testInput_f32, 2 * fftSize *
sizeof (
ne10_float32_t));
133 memcpy (in_neon, testInput_f32, 2 * fftSize *
sizeof (
ne10_float32_t));
135 GUARD_ARRAY (out_c, fftSize * 2);
136 GUARD_ARRAY (out_neon, fftSize * 2);
141 assert_true (CHECK_ARRAY_GUARD (out_c, fftSize * 2));
142 assert_true (CHECK_ARRAY_GUARD (out_neon, fftSize * 2));
144 CHECK_ARRAY_GUARD (out_c, fftSize * 2);
145 CHECK_ARRAY_GUARD (out_neon, fftSize * 2);
148 snr = CAL_SNR_FLOAT32 (out_c, out_neon, fftSize * 2);
149 assert_false ( (snr < SNR_THRESHOLD));
159 fftSize += (fftSize / 2);
163 fftSize += (fftSize / 3) * 2;
167 fftSize += (fftSize * 2);
178 void test_fft_c2c_1d_float32_performance()
185 fprintf (stdout,
"----------%30s start\n", __FUNCTION__);
186 fprintf (stdout,
"%25s%20s%20s%20s%20s\n",
"FFT Length",
"C Time (micro-s)",
"NEON Time (micro-s)",
"Time Savings",
"Performance Ratio");
190 fprintf (stdout,
"FFT size %d\n", fftSize);
193 memcpy (in_c, testInput_f32, 2 * fftSize *
sizeof (
ne10_float32_t));
194 memcpy (in_neon, testInput_f32, 2 * fftSize *
sizeof (
ne10_float32_t));
195 flag_result = test_c2c_alloc (fftSize);
207 for (i = 0; i < test_loop; i++)
215 for (i = 0; i < test_loop; i++)
221 time_savings = ( ( (
ne10_float32_t) (time_c - time_neon)) / time_c) * 100;
222 ne10_log (__FUNCTION__,
"Float FFT%21d%20lld%20lld%19.2f%%%18.2f:1\n", fftSize, time_c, time_neon, time_savings, time_speedup);
232 for (i = 0; i < test_loop; i++)
240 for (i = 0; i < test_loop; i++)
246 time_savings = ( ( (
ne10_float32_t) (time_c - time_neon)) / time_c) * 100;
247 ne10_log (__FUNCTION__,
"Float FFT%21d%20lld%20lld%19.2f%%%18.2f:1\n", fftSize, time_c, time_neon, time_savings, time_speedup);
254 void test_fft_r2c_1d_float32_conformance()
261 fprintf (stdout,
"----------%30s start\n", __FUNCTION__);
265 fprintf (stdout,
"FFT size %d\n", fftSize);
269 memcpy (in_neon, testInput_f32, fftSize *
sizeof (
ne10_float32_t));
273 fprintf (stdout,
"======ERROR, FFT alloc fails\n");
277 GUARD_ARRAY (out_c, (fftSize / 2 + 1) * 2);
278 GUARD_ARRAY (out_neon, (fftSize / 2 + 1) * 2);
283 assert_true (CHECK_ARRAY_GUARD (out_c, (fftSize / 2 + 1) * 2));
284 assert_true (CHECK_ARRAY_GUARD (out_neon, (fftSize / 2 + 1) * 2));
287 snr = CAL_SNR_FLOAT32 (out_c, out_neon, (fftSize / 2 + 1) * 2);
291 for (i = 1; i < (fftSize / 2); i++)
293 in_c[2 * i] = testInput_f32[2 * i];
294 in_c[2 * i + 1] = testInput_f32[2 * i + 1];
295 in_c[2 * (fftSize - i)] = in_c[2 * i];
296 in_c[2 * (fftSize - i) + 1] = -in_c[2 * i + 1];
298 in_c[0] = testInput_f32[0];
300 in_c[fftSize] = testInput_f32[1];
301 in_c[fftSize + 1] = 0;
304 GUARD_ARRAY (out_c, fftSize);
305 GUARD_ARRAY (out_neon, fftSize);
310 assert_true (CHECK_ARRAY_GUARD (out_c, fftSize));
311 assert_true (CHECK_ARRAY_GUARD (out_neon, fftSize));
314 snr = CAL_SNR_FLOAT32 (out_c, out_neon, fftSize);
321 void test_fft_r2c_1d_float32_performance()
329 fprintf (stdout,
"----------%30s start\n", __FUNCTION__);
330 fprintf (stdout,
"%25s%20s%20s%20s%20s\n",
"FFT Length",
"C Time (micro-s)",
"NEON Time (micro-s)",
"Time Savings",
"Performance Ratio");
334 fprintf (stdout,
"FFT size %d\n", fftSize);
338 memcpy (in_neon, testInput_f32, fftSize *
sizeof (
ne10_float32_t));
342 fprintf (stdout,
"======ERROR, FFT alloc fails\n");
351 for (i = 0; i < test_loop; i++)
359 for (i = 0; i < test_loop; i++)
365 time_savings = ( ( (
ne10_float32_t) (time_c - time_neon)) / time_c) * 100;
366 ne10_log (__FUNCTION__,
"Float FFT%21d%20lld%20lld%19.2f%%%18.2f:1\n", fftSize, time_c, time_neon, time_savings, time_speedup);
369 for (i = 1; i < (fftSize / 2); i++)
371 in_c[2 * i] = testInput_f32[2 * i];
372 in_c[2 * i + 1] = testInput_f32[2 * i + 1];
373 in_c[2 * (fftSize - i)] = in_c[2 * i];
374 in_c[2 * (fftSize - i) + 1] = -in_c[2 * i + 1];
376 in_c[0] = testInput_f32[0];
378 in_c[fftSize] = testInput_f32[1];
379 in_c[fftSize + 1] = 0;
386 for (i = 0; i < test_loop; i++)
394 for (i = 0; i < test_loop; i++)
400 time_savings = ( ( (
ne10_float32_t) (time_c - time_neon)) / time_c) * 100;
401 ne10_log (__FUNCTION__,
"Float FFT%21d%20lld%20lld%19.2f%%%18.2f:1\n", fftSize, time_c, time_neon, time_savings, time_speedup);
409 ne10_log_buffer_ptr = ne10_log_buffer;
415 in_c = guarded_in_c + ARRAY_GUARD_LEN;
416 in_neon = guarded_in_neon + ARRAY_GUARD_LEN;
421 out_c = guarded_out_c + ARRAY_GUARD_LEN;
422 out_neon = guarded_out_neon + ARRAY_GUARD_LEN;
426 testInput_f32[i] = (
ne10_float32_t) (drand48() * 32768.0f - 16384.0f);
430 static void my_test_teardown (
void)
438 void test_fft_c2c_1d_float32()
440 #if defined (SMOKE_TEST)||(REGRESSION_TEST) 441 test_fft_c2c_1d_float32_conformance();
444 #if defined (PERFORMANCE_TEST) 445 test_fft_c2c_1d_float32_performance();
449 void test_fft_r2c_1d_float32()
451 #if defined (SMOKE_TEST)||(REGRESSION_TEST) 452 test_fft_r2c_1d_float32_conformance();
455 #if defined (PERFORMANCE_TEST) 456 test_fft_r2c_1d_float32_performance();
460 void test_fixture_fft_c2c_1d_float32 (
void)
462 test_fixture_start();
466 run_test (test_fft_c2c_1d_float32);
468 fixture_teardown(my_test_teardown);
473 void test_fixture_fft_r2c_1d_float32 (
void)
475 test_fixture_start();
479 run_test (test_fft_r2c_1d_float32);
481 fixture_teardown(my_test_teardown);
494 fprintf (stdout,
"======ERROR, FFT alloc fails\n");
499 if (cfg_neon == NULL)
502 fprintf (stdout,
"======ERROR, FFT alloc fails\n");
void ne10_fft_c2r_1d_float32_c(ne10_float32_t *fout, ne10_fft_cpx_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)
Specific implementation of ne10_fft_c2r_1d_float32 using plain C.
ne10_fft_r2c_cfg_float32_t ne10_fft_alloc_r2c_float32(ne10_int32_t nfft)
Creates a configuration structure for variants of ne10_fft_r2c_1d_float32 and ne10_fft_c2r_1d_float32...
void ne10_fft_c2c_1d_float32_neon(ne10_fft_cpx_float32_t *fout, ne10_fft_cpx_float32_t *fin, ne10_fft_cfg_float32_t cfg, ne10_int32_t inverse_fft)
Specific implementation of ne10_fft_c2c_1d_float32 using NEON SIMD capabilities.
ne10_fft_cfg_float32_t ne10_fft_alloc_c2c_float32_neon(ne10_int32_t nfft)
Specific implementation of ne10_fft_alloc_c2c_float32 for ne10_fft_c2c_1d_float32_neon.
Structure for the floating point FFT state.
ne10_fft_cfg_float32_t ne10_fft_alloc_c2c_float32_c(ne10_int32_t nfft)
Specific implementation of ne10_fft_alloc_c2c_float32 for ne10_fft_c2c_1d_float32_c.
#define MIN_LENGTH_SAMPLES_CPX
void ne10_fft_c2c_1d_float32_c(ne10_fft_cpx_float32_t *fout, ne10_fft_cpx_float32_t *fin, ne10_fft_cfg_float32_t cfg, ne10_int32_t inverse_fft)
Specific implementation of ne10_fft_c2c_1d_float32 using plain C.
#define SNR_THRESHOLD_FLOAT32
void ne10_fft_c2r_1d_float32_neon(ne10_float32_t *fout, ne10_fft_cpx_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)
Specific implementation of ne10_fft_c2r_1d_float32 using NEON SIMD capabilities.
#define TEST_LENGTH_SAMPLES
#define MIN_LENGTH_SAMPLES_REAL
void ne10_fft_r2c_1d_float32_c(ne10_fft_cpx_float32_t *fout, ne10_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)
Specific implementation of ne10_fft_r2c_1d_float32 using plain C.
#define NE10_FFT_PARA_LEVEL
void ne10_fft_r2c_1d_float32_neon(ne10_fft_cpx_float32_t *fout, ne10_float32_t *fin, ne10_fft_r2c_cfg_float32_t cfg)
Specific implementation of ne10_fft_r2c_1d_float32 using NEON SIMD capabilities.