diff options
author | joshua <joshua@joshuayun.com> | 2023-12-30 23:54:31 -0500 |
---|---|---|
committer | joshua <joshua@joshuayun.com> | 2023-12-30 23:54:31 -0500 |
commit | 86608c6770cf08c138a2bdab5855072f64be09ef (patch) | |
tree | 494a61b3ef37e76f9235a0d10f5c93d97290a35f /Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests | |
download | sdr-software-master.tar.gz |
Diffstat (limited to 'Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests')
4 files changed, 339 insertions, 0 deletions
diff --git a/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_templates.h b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_templates.h new file mode 100644 index 0000000..958ef78 --- /dev/null +++ b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_templates.h @@ -0,0 +1,267 @@ +#ifndef _BASIC_MATH_TEMPLATES_H_
+#define _BASIC_MATH_TEMPLATES_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Includes */
+/*--------------------------------------------------------------------------------*/
+#include "test_templates.h"
+
+/*--------------------------------------------------------------------------------*/
+/* Group Specific Templates */
+/*--------------------------------------------------------------------------------*/
+
+/**
+ * Compare the outputs used by basic math tests for the function under test and
+ * the reference function.
+ */
+#define BASIC_MATH_COMPARE_INTERFACE(block_size, output_type) \
+ TEST_ASSERT_BUFFERS_EQUAL( \
+ basic_math_output_ref.data_ptr, \
+ basic_math_output_fut.data_ptr, \
+ block_size * sizeof(output_type))
+
+/*
+ * Comparison SNR thresholds for the data types used in basic_math_tests.
+ */
+#define BASIC_MATH_SNR_THRESHOLD_float32_t 120
+#define BASIC_MATH_SNR_THRESHOLD_q31_t 100
+#define BASIC_MATH_SNR_THRESHOLD_q15_t 75
+#define BASIC_MATH_SNR_THRESHOLD_q7_t 25
+
+/**
+ * Compare reference and fut outputs using SNR.
+ *
+ * @note The outputs are converted to float32_t before comparison.
+ */
+#define BASIC_MATH_SNR_COMPARE_INTERFACE(block_size, output_type) \
+ do \
+ { \
+ TEST_CONVERT_AND_ASSERT_SNR( \
+ basic_math_output_f32_ref, \
+ basic_math_output_ref.data_ptr, \
+ basic_math_output_f32_fut, \
+ basic_math_output_fut.data_ptr, \
+ block_size, \
+ output_type, \
+ BASIC_MATH_SNR_THRESHOLD_##output_type \
+ ); \
+ } while (0)
+
+
+/**
+ * Compare reference and fut outputs using SNR.
+ *
+ * @note The outputs are converted to float32_t before comparison.
+ */
+#define BASIC_MATH_SNR_ELT1_COMPARE_INTERFACE(block_size, output_type) \
+ do \
+ { \
+ TEST_CONVERT_AND_ASSERT_SNR( \
+ basic_math_output_f32_ref, \
+ basic_math_output_ref.data_ptr, \
+ basic_math_output_f32_fut, \
+ basic_math_output_fut.data_ptr, \
+ 1, \
+ output_type, \
+ BASIC_MATH_SNR_THRESHOLD_##output_type \
+ ); \
+ } while (0)
+
+
+
+/*--------------------------------------------------------------------------------*/
+/* Input Interfaces */
+/*--------------------------------------------------------------------------------*/
+/*
+ * General:
+ * Input interfaces provide inputs to functions inside test templates. They
+ * ONLY provide the inputs. The output variables should be hard coded.
+ *
+ * The input interfaces must have the following format:
+ *
+ * ARM_xxx_INPUT_INTERFACE() or
+ * REF_xxx_INPUT_INTERFACE()
+ *
+ * The xxx must be lowercase, and is intended to be the indentifying substring
+ * in the function's name. Acceptable values are 'sub' or 'add' from the
+ * functions arm_add_q31.
+ */
+
+#define ARM_abs_INPUT_INTERFACE(input, block_size) \
+ PAREN(input, basic_math_output_fut.data_ptr, block_size)
+
+#define REF_abs_INPUT_INTERFACE(input, block_size) \
+ PAREN(input, basic_math_output_ref.data_ptr, block_size)
+
+#define ARM_add_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, basic_math_output_fut.data_ptr, block_size) \
+
+#define REF_add_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, basic_math_output_ref.data_ptr, block_size) \
+
+#define ARM_dot_prod_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, block_size, basic_math_output_fut.data_ptr) \
+
+#define REF_dot_prod_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, block_size, basic_math_output_ref.data_ptr) \
+
+#define ARM_mult_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, basic_math_output_fut.data_ptr, block_size) \
+
+#define REF_mult_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, basic_math_output_ref.data_ptr, block_size) \
+
+#define ARM_negate_INPUT_INTERFACE(input, block_size) \
+ PAREN(input, basic_math_output_fut.data_ptr, block_size)
+
+#define REF_negate_INPUT_INTERFACE(input, block_size) \
+ PAREN(input, basic_math_output_ref.data_ptr, block_size)
+
+#define ARM_offset_INPUT_INTERFACE(input, elt, block_size) \
+ PAREN(input, elt, basic_math_output_fut.data_ptr, block_size) \
+
+#define REF_offset_INPUT_INTERFACE(input, elt, block_size) \
+ PAREN(input, elt, basic_math_output_ref.data_ptr, block_size) \
+
+#define ARM_shift_INPUT_INTERFACE(input, elt, block_size) \
+ PAREN(input, elt, basic_math_output_fut.data_ptr, block_size) \
+
+#define REF_shift_INPUT_INTERFACE(input, elt, block_size) \
+ PAREN(input, elt, basic_math_output_ref.data_ptr, block_size) \
+
+#define ARM_scale_float_INPUT_INTERFACE(input, elt, block_size) \
+ PAREN(input, elt, basic_math_output_fut.data_ptr, block_size) \
+
+#define REF_scale_float_INPUT_INTERFACE(input, elt, block_size) \
+ PAREN(input, elt, basic_math_output_ref.data_ptr, block_size) \
+
+/* These two are for the fixed point functions */
+#define ARM_scale_INPUT_INTERFACE(input, elt1, elt2, block_size) \
+ PAREN(input, elt1, elt2, basic_math_output_fut.data_ptr, block_size) \
+
+#define REF_scale_INPUT_INTERFACE(input, elt1, elt2, block_size) \
+ PAREN(input, elt1, elt2, basic_math_output_ref.data_ptr, block_size) \
+
+#define ARM_sub_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, basic_math_output_fut.data_ptr, block_size) \
+
+#define REF_sub_INPUT_INTERFACE(input_a, input_b, block_size) \
+ PAREN(input_a, input_b, basic_math_output_ref.data_ptr, block_size) \
+
+
+/*--------------------------------------------------------------------------------*/
+/* Test Templates */
+/*--------------------------------------------------------------------------------*/
+
+/**
+ * Specialization of #TEST_TEMPLATE_BUF1_BLK() for basic math tests.
+ *
+ * @note This macro relies on the existance of ARM_xxx_INPUT_INTERFACE and
+ * REF_xxx_INPUT_INTERFACEs.
+ */
+#define BASIC_MATH_DEFINE_TEST_TEMPLATE_BUF1_BLK(fn_name, \
+ suffix, \
+ input_type, \
+ output_type) \
+ JTEST_DEFINE_TEST(arm_##fn_name##_##suffix##_test, \
+ arm_##fn_name##_##suffix) \
+ { \
+ TEST_TEMPLATE_BUF1_BLK( \
+ basic_math_f_all, \
+ basic_math_block_sizes, \
+ input_type, \
+ output_type, \
+ arm_##fn_name##_##suffix, \
+ ARM_##fn_name##_INPUT_INTERFACE, \
+ ref_##fn_name##_##suffix, \
+ REF_##fn_name##_INPUT_INTERFACE, \
+ BASIC_MATH_COMPARE_INTERFACE); \
+ }
+
+/**
+ * Specialization of #TEST_TEMPLATE_BUF2_BLK() for basic math tests.
+ *
+ * @note This macro relies on the existance of ARM_xxx_INPUT_INTERFACE and
+ * REF_xxx_INPUT_INTERFACEs.
+ */
+#define BASIC_MATH_DEFINE_TEST_TEMPLATE_BUF2_BLK(fn_name, \
+ suffix, \
+ input_type, \
+ output_type, \
+ comparison_interface) \
+ JTEST_DEFINE_TEST(arm_##fn_name##_##suffix##_test, \
+ arm_##fn_name##_##suffix) \
+ { \
+ TEST_TEMPLATE_BUF2_BLK( \
+ basic_math_f_all, \
+ basic_math_f_all, \
+ basic_math_block_sizes, \
+ input_type, \
+ output_type, \
+ arm_##fn_name##_##suffix, \
+ ARM_##fn_name##_INPUT_INTERFACE, \
+ ref_##fn_name##_##suffix, \
+ REF_##fn_name##_INPUT_INTERFACE, \
+ comparison_interface); \
+ }
+
+/**
+ * Specialization of #TEST_TEMPLATE_BUF1_ELT1_BLK() for basic math tests.
+ *
+ * @note This macro relies on the existance of ARM_xxx_INPUT_INTERFACE and
+ * REF_xxx_INPUT_INTERFACEs.
+ */
+#define BASIC_MATH_DEFINE_TEST_TEMPLATE_BUF1_ELT1_BLK(fn_name, \
+ suffix, \
+ input_type, \
+ elt_type, \
+ output_type) \
+ JTEST_DEFINE_TEST(arm_##fn_name##_##suffix##_test, \
+ arm_##fn_name##_##suffix) \
+ { \
+ TEST_TEMPLATE_BUF1_ELT1_BLK( \
+ basic_math_f_all, \
+ basic_math_elts, \
+ basic_math_block_sizes, \
+ input_type, \
+ elt_type, \
+ output_type, \
+ arm_##fn_name##_##suffix, \
+ ARM_##fn_name##_INPUT_INTERFACE, \
+ ref_##fn_name##_##suffix, \
+ REF_##fn_name##_INPUT_INTERFACE, \
+ BASIC_MATH_COMPARE_INTERFACE); \
+ }
+
+/**
+ * Specialization of #TEST_TEMPLATE_BUF1_ELT2_BLK() for basic math tests.
+ *
+ * @note This macro relies on the existance of ARM_xxx_INPUT_INTERFACE and
+ * REF_xxx_INPUT_INTERFACEs.
+ */
+#define BASIC_MATH_DEFINE_TEST_TEMPLATE_BUF1_ELT2_BLK(fn_name, \
+ suffix, \
+ input_type, \
+ elt1_type, \
+ elt2_type, \
+ output_type) \
+ JTEST_DEFINE_TEST(arm_##fn_name##_##suffix##_test, \
+ arm_##fn_name##_##suffix) \
+ { \
+ TEST_TEMPLATE_BUF1_ELT2_BLK( \
+ basic_math_f_all, \
+ basic_math_elts, \
+ basic_math_elts2, \
+ basic_math_block_sizes, \
+ input_type, \
+ elt1_type, \
+ elt2_type, \
+ output_type, \
+ arm_##fn_name##_##suffix, \
+ ARM_##fn_name##_INPUT_INTERFACE, \
+ ref_##fn_name##_##suffix, \
+ REF_##fn_name##_INPUT_INTERFACE, \
+ BASIC_MATH_COMPARE_INTERFACE); \
+ }
+
+#endif /* _BASIC_MATH_TEMPLATES_H_ */
diff --git a/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_test_data.h b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_test_data.h new file mode 100644 index 0000000..2f0b239 --- /dev/null +++ b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_test_data.h @@ -0,0 +1,46 @@ +#ifndef ARM_BASIC_MATH_TEST_DATA_H
+#define ARM_BASIC_MATH_TEST_DATA_H
+
+/*--------------------------------------------------------------------------------*/
+/* Includes */
+/*--------------------------------------------------------------------------------*/
+
+#include "arr_desc.h"
+#include "arm_math.h"
+
+/*--------------------------------------------------------------------------------*/
+/* Macros and Defines */
+/*--------------------------------------------------------------------------------*/
+#define BASIC_MATH_MAX_INPUT_ELEMENTS 32
+#define BASIC_MATH_BIGGEST_INPUT_TYPE float32_t
+
+/*--------------------------------------------------------------------------------*/
+/* Declare Variables */
+/*--------------------------------------------------------------------------------*/
+
+/* Input/Output Buffers */
+ARR_DESC_DECLARE(basic_math_output_fut);
+ARR_DESC_DECLARE(basic_math_output_ref);
+
+extern BASIC_MATH_BIGGEST_INPUT_TYPE
+basic_math_output_f32_ref[BASIC_MATH_MAX_INPUT_ELEMENTS];
+
+extern BASIC_MATH_BIGGEST_INPUT_TYPE
+basic_math_output_f32_fut[BASIC_MATH_MAX_INPUT_ELEMENTS];
+
+/* Block Sizes*/
+ARR_DESC_DECLARE(basic_math_block_sizes);
+
+/* Numbers */
+ARR_DESC_DECLARE(basic_math_elts);
+ARR_DESC_DECLARE(basic_math_elts2);
+ARR_DESC_DECLARE(basic_math_eltsf);
+
+/* Float Inputs */
+ARR_DESC_DECLARE(basic_math_zeros);
+ARR_DESC_DECLARE(basic_math_f_2);
+ARR_DESC_DECLARE(basic_math_f_15);
+ARR_DESC_DECLARE(basic_math_f_32);
+ARR_DESC_DECLARE(basic_math_f_all);
+
+#endif
diff --git a/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_test_group.h b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_test_group.h new file mode 100644 index 0000000..ece92c7 --- /dev/null +++ b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_test_group.h @@ -0,0 +1,9 @@ +#ifndef _BASIC_MATH_TEST_GROUP_H_
+#define _BASIC_MATH_TEST_GROUP_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Declare Test Groups */
+/*--------------------------------------------------------------------------------*/
+JTEST_DECLARE_GROUP(basic_math_tests);
+
+#endif /* _BASIC_MATH_TEST_GROUP_H_ */
diff --git a/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_tests.h b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_tests.h new file mode 100644 index 0000000..0550444 --- /dev/null +++ b/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/basic_math_tests/basic_math_tests.h @@ -0,0 +1,17 @@ +#ifndef _BASIC_MATH_TESTS_H_
+#define _BASIC_MATH_TESTS_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Test/Group Declarations */
+/*--------------------------------------------------------------------------------*/
+JTEST_DECLARE_GROUP(abs_tests);
+JTEST_DECLARE_GROUP(add_tests);
+JTEST_DECLARE_GROUP(dot_prod_tests);
+JTEST_DECLARE_GROUP(mult_tests);
+JTEST_DECLARE_GROUP(negate_tests);
+JTEST_DECLARE_GROUP(offset_tests);
+JTEST_DECLARE_GROUP(scale_tests);
+JTEST_DECLARE_GROUP(shift_tests);
+JTEST_DECLARE_GROUP(sub_tests);
+
+#endif /* _BASIC_MATH_TESTS_H_ */
|