tests: lib: cmsis_dsp: filtering: Test vector FIR functions

This commit adds support for testing the vector implementation of the
FIR filter functions when the MVE is enabled.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2022-05-04 12:08:26 +09:00
commit 8c160e0d5a
5 changed files with 115 additions and 15 deletions

View file

@ -16,6 +16,8 @@
#define SNR_ERROR_THRESH ((float32_t)60)
#define REL_ERROR_THRESH (1.0e-2)
#define COEFF_PADDING (4)
static void test_arm_fir_f16(void)
{
size_t sample_index, block_index;
@ -28,6 +30,10 @@ static void test_arm_fir_f16(void)
const float16_t *ref = (const float16_t *)ref_val;
float16_t *state, *output_buf, *output;
arm_fir_instance_f16 inst;
#if defined(CONFIG_ARMV8_1_M_MVEF) && defined(CONFIG_FPU)
float16_t coeff_padded[32];
int round;
#endif
/* Allocate buffers */
state = malloc(2 * 47 * sizeof(float16_t));
@ -44,10 +50,24 @@ static void test_arm_fir_f16(void)
block_size = config[0];
tap_count = config[1];
/* Initialise instance */
arm_fir_init_f16(&inst, tap_count, coeff, state, block_size);
#if defined(CONFIG_ARMV8_1_M_MVEF) && defined(CONFIG_FPU)
/* Copy coefficients and pad to zero */
memset(coeff_padded, 127, sizeof(coeff_padded));
round = tap_count / COEFF_PADDING;
if ((round * COEFF_PADDING) < tap_count) {
round++;
}
round = round * COEFF_PADDING;
memset(coeff_padded, 0, round * sizeof(float16_t));
memcpy(coeff_padded, coeff, tap_count * sizeof(float16_t));
#endif
/* TODO: Add MEVF support */
/* Initialise instance */
#if defined(CONFIG_ARMV8_1_M_MVEF) && defined(CONFIG_FPU)
arm_fir_init_f16(&inst, tap_count, coeff_padded, state, block_size);
#else
arm_fir_init_f16(&inst, tap_count, coeff, state, block_size);
#endif
/* Reset input pointer */
input = (const float16_t *)in_val;

View file

@ -16,6 +16,8 @@
#define SNR_ERROR_THRESH ((float32_t)120)
#define REL_ERROR_THRESH (3.0e-5)
#define COEFF_PADDING (4)
static void test_arm_fir_f32(void)
{
size_t sample_index, block_index;
@ -28,6 +30,10 @@ static void test_arm_fir_f32(void)
const float32_t *ref = (const float32_t *)ref_val;
float32_t *state, *output_buf, *output;
arm_fir_instance_f32 inst;
#if defined(CONFIG_ARMV8_1_M_MVEF) && defined(CONFIG_FPU)
float32_t coeff_padded[32];
int round;
#endif
/* Allocate buffers */
state = malloc(2 * 47 * sizeof(float32_t));
@ -44,10 +50,24 @@ static void test_arm_fir_f32(void)
block_size = config[0];
tap_count = config[1];
/* Initialise instance */
arm_fir_init_f32(&inst, tap_count, coeff, state, block_size);
#if defined(CONFIG_ARMV8_1_M_MVEF) && defined(CONFIG_FPU)
/* Copy coefficients and pad to zero */
memset(coeff_padded, 127, sizeof(coeff_padded));
round = tap_count / COEFF_PADDING;
if ((round * COEFF_PADDING) < tap_count) {
round++;
}
round = round * COEFF_PADDING;
memset(coeff_padded, 0, round * sizeof(float32_t));
memcpy(coeff_padded, coeff, tap_count * sizeof(float32_t));
#endif
/* TODO: Add MEVF support */
/* Initialise instance */
#if defined(CONFIG_ARMV8_1_M_MVEF) && defined(CONFIG_FPU)
arm_fir_init_f32(&inst, tap_count, coeff_padded, state, block_size);
#else
arm_fir_init_f32(&inst, tap_count, coeff, state, block_size);
#endif
/* Reset input pointer */
input = (const float32_t *)in_val;

View file

@ -16,6 +16,8 @@
#define SNR_ERROR_THRESH ((float32_t)59)
#define ABS_ERROR_THRESH_Q15 ((q15_t)2)
#define COEFF_PADDING (8)
static void test_arm_fir_q15(void)
{
size_t sample_index, block_index;
@ -28,6 +30,10 @@ static void test_arm_fir_q15(void)
const q15_t *ref = (const q15_t *)ref_val;
q15_t *state, *output_buf, *output;
arm_fir_instance_q15 inst;
#if defined(CONFIG_ARMV8_1_M_MVEI) && defined(CONFIG_FPU)
q15_t coeff_padded[32];
int round;
#endif
/* Allocate buffers */
state = malloc(3 * 41 * sizeof(q15_t));
@ -44,10 +50,24 @@ static void test_arm_fir_q15(void)
block_size = config[0];
tap_count = config[1];
/* Initialise instance */
arm_fir_init_q15(&inst, tap_count, coeff, state, block_size);
#if defined(CONFIG_ARMV8_1_M_MVEI) && defined(CONFIG_FPU)
/* Copy coefficients and pad to zero */
memset(coeff_padded, 127, sizeof(coeff_padded));
round = tap_count / COEFF_PADDING;
if ((round * COEFF_PADDING) < tap_count) {
round++;
}
round = round * COEFF_PADDING;
memset(coeff_padded, 0, round * sizeof(q15_t));
memcpy(coeff_padded, coeff, tap_count * sizeof(q15_t));
#endif
/* TODO: Add MEVI support */
/* Initialise instance */
#if defined(CONFIG_ARMV8_1_M_MVEI) && defined(CONFIG_FPU)
arm_fir_init_q15(&inst, tap_count, coeff_padded, state, block_size);
#else
arm_fir_init_q15(&inst, tap_count, coeff, state, block_size);
#endif
/* Reset input pointer */
input = (const q15_t *)in_val;

View file

@ -16,6 +16,8 @@
#define SNR_ERROR_THRESH ((float32_t)100)
#define ABS_ERROR_THRESH_Q31 ((q31_t)2)
#define COEFF_PADDING (4)
static void test_arm_fir_q31(void)
{
size_t sample_index, block_index;
@ -28,6 +30,10 @@ static void test_arm_fir_q31(void)
const q31_t *ref = (const q31_t *)ref_val;
q31_t *state, *output_buf, *output;
arm_fir_instance_q31 inst;
#if defined(CONFIG_ARMV8_1_M_MVEI) && defined(CONFIG_FPU)
q31_t coeff_padded[32];
int round;
#endif
/* Allocate buffers */
state = malloc(3 * 47 * sizeof(q31_t));
@ -44,10 +50,24 @@ static void test_arm_fir_q31(void)
block_size = config[0];
tap_count = config[1];
/* Initialise instance */
arm_fir_init_q31(&inst, tap_count, coeff, state, block_size);
#if defined(CONFIG_ARMV8_1_M_MVEI) && defined(CONFIG_FPU)
/* Copy coefficients and pad to zero */
memset(coeff_padded, 127, sizeof(coeff_padded));
round = tap_count / COEFF_PADDING;
if ((round * COEFF_PADDING) < tap_count) {
round++;
}
round = round * COEFF_PADDING;
memset(coeff_padded, 0, round * sizeof(q31_t));
memcpy(coeff_padded, coeff, tap_count * sizeof(q31_t));
#endif
/* TODO: Add MEVI support */
/* Initialise instance */
#if defined(CONFIG_ARMV8_1_M_MVEI) && defined(CONFIG_FPU)
arm_fir_init_q31(&inst, tap_count, coeff_padded, state, block_size);
#else
arm_fir_init_q31(&inst, tap_count, coeff, state, block_size);
#endif
/* Reset input pointer */
input = (const q31_t *)in_val;

View file

@ -16,6 +16,8 @@
#define SNR_ERROR_THRESH ((float32_t)10)
#define ABS_ERROR_THRESH_Q7 ((q7_t)2)
#define COEFF_PADDING (16)
static void test_arm_fir_q7(void)
{
size_t sample_index, block_index;
@ -28,6 +30,10 @@ static void test_arm_fir_q7(void)
const q7_t *ref = (const q7_t *)ref_val;
q7_t *state, *output_buf, *output;
arm_fir_instance_q7 inst;
#if defined(CONFIG_ARMV8_1_M_MVEI) && defined(CONFIG_FPU)
q7_t coeff_padded[32];
int round;
#endif
/* Allocate buffers */
state = malloc(47 * sizeof(q7_t));
@ -44,10 +50,24 @@ static void test_arm_fir_q7(void)
block_size = config[0];
tap_count = config[1];
/* Initialise instance */
arm_fir_init_q7(&inst, tap_count, coeff, state, block_size);
#if defined(CONFIG_ARMV8_1_M_MVEI) && defined(CONFIG_FPU)
/* Copy coefficients and pad to zero */
memset(coeff_padded, 127, sizeof(coeff_padded));
round = tap_count / COEFF_PADDING;
if ((round * COEFF_PADDING) < tap_count) {
round++;
}
round = round * COEFF_PADDING;
memset(coeff_padded, 0, round * sizeof(q7_t));
memcpy(coeff_padded, coeff, tap_count * sizeof(q7_t));
#endif
/* TODO: Add MEVI support */
/* Initialise instance */
#if defined(CONFIG_ARMV8_1_M_MVEI) && defined(CONFIG_FPU)
arm_fir_init_q7(&inst, tap_count, coeff_padded, state, block_size);
#else
arm_fir_init_q7(&inst, tap_count, coeff, state, block_size);
#endif
/* Reset input pointer */
input = (const q7_t *)in_val;