Subversion Repositories dashGPS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef _COMPLEX_MATH_TEMPLATES_H_
  2. #define _COMPLEX_MATH_TEMPLATES_H_
  3.  
  4. /*--------------------------------------------------------------------------------*/
  5. /* Includes */
  6. /*--------------------------------------------------------------------------------*/
  7. #include "test_templates.h"
  8.  
  9. /*--------------------------------------------------------------------------------*/
  10. /* Group Specific Templates */
  11. /*--------------------------------------------------------------------------------*/
  12.  
  13. /**
  14.  *  Compare the real outputs from the function under test and the reference
  15.  *  function.
  16.  */
  17. #define COMPLEX_MATH_COMPARE_RE_INTERFACE(block_size, output_type)  \
  18.     TEST_ASSERT_BUFFERS_EQUAL(                                      \
  19.         complex_math_output_ref_a.data_ptr,                         \
  20.         complex_math_output_fut_a.data_ptr,                         \
  21.         block_size * sizeof(output_type))
  22.  
  23. /**
  24.  *  Compare the real and imaginary outputs from the function under test and the
  25.  *  reference function.
  26.  */
  27. #define COMPLEX_MATH_COMPARE_CMPLX_INTERFACE(block_size, output_type)   \
  28.     do                                                                  \
  29.     {                                                                   \
  30.         COMPLEX_MATH_COMPARE_RE_INTERFACE(block_size * 2, output_type); \
  31.     } while (0)
  32.  
  33.  
  34. /*
  35.  * Comparison SNR thresholds for the data types used in complex_math_tests.
  36.  */
  37. #define COMPLEX_MATH_SNR_THRESHOLD_float32_t 120
  38. #define COMPLEX_MATH_SNR_THRESHOLD_q31_t 100
  39. #define COMPLEX_MATH_SNR_THRESHOLD_q15_t 75
  40.  
  41. /**
  42.  *  Compare reference and fut outputs using SNR.
  43.  *
  44.  *  The output_suffix specifies which output buffers to use for the
  45.  *  comparison. An output_suffix of 'a' expands to the following buffers:
  46.  *
  47.  *  - complex_math_output_f32_ref_a
  48.  *  - complex_math_output_f32_fut_a
  49.  *  - complex_math_output_ref_a
  50.  *  - complex_math_output_fut_a
  51.  *
  52.  *  @note The outputs are converted to float32_t before comparison.
  53.  */
  54. #define COMPLEX_MATH_SNR_COMPARE_OUT_INTERFACE(block_size,      \
  55.                                                output_type,     \
  56.                                                output_suffix)   \
  57.     do                                                          \
  58.     {                                                           \
  59.         TEST_CONVERT_AND_ASSERT_SNR(                            \
  60.             complex_math_output_f32_ref_##output_suffix,        \
  61.             complex_math_output_ref_##output_suffix.data_ptr,   \
  62.             complex_math_output_f32_fut_##output_suffix,        \
  63.             complex_math_output_fut_##output_suffix.data_ptr,   \
  64.             block_size,                                         \
  65.             output_type,                                        \
  66.             COMPLEX_MATH_SNR_THRESHOLD_##output_type            \
  67.             );                                                  \
  68.     } while (0)
  69.  
  70. /**
  71.  *  Specification of #COMPLEX_MATH_SNR_COMPARE_INTERFACE() for real outputs.
  72.  */
  73. #define COMPLEX_MATH_SNR_COMPARE_RE_INTERFACE(block_size,       \
  74.                                                    output_type) \
  75.     COMPLEX_MATH_SNR_COMPARE_OUT_INTERFACE(block_size,          \
  76.                                            output_type,         \
  77.                                            a)
  78.  
  79. /**
  80.  *  Specification of #COMPLEX_MATH_SNR_COMPARE_INTERFACE() for complex outputs.
  81.  */
  82. #define COMPLEX_MATH_SNR_COMPARE_CMPLX_INTERFACE(block_size,    \
  83.                                                  output_type)   \
  84.         COMPLEX_MATH_SNR_COMPARE_OUT_INTERFACE(block_size * 2,  \
  85.                                                output_type,     \
  86.                                                a)
  87.  
  88. /**
  89.  *  Compare reference and fut split outputs using SNR.
  90.  *
  91.  *  'Split' refers to two separate output buffers; one for real and one for
  92.  *  complex.
  93.  */
  94. #define COMPLEX_MATH_SNR_COMPARE_SPLIT_INTERFACE(block_size,    \
  95.                                                  output_type)   \
  96.         do                                                      \
  97.         {                                                       \
  98.             COMPLEX_MATH_SNR_COMPARE_OUT_INTERFACE(block_size,  \
  99.                                                    output_type, \
  100.                                                    a);          \
  101.             COMPLEX_MATH_SNR_COMPARE_OUT_INTERFACE(block_size,  \
  102.                                                    output_type, \
  103.                                                    b);          \
  104.         } while (0)
  105.  
  106.  
  107. /*--------------------------------------------------------------------------------*/
  108. /* Input Interfaces */
  109. /*--------------------------------------------------------------------------------*/
  110. /*
  111.  *  General:
  112.  *  Input interfaces provide inputs to functions inside test templates.  They
  113.  *  ONLY provide the inputs.  The output variables should be hard coded.
  114.  *
  115.  *  The input interfaces must have the following format:
  116.  *
  117.  *  ARM_xxx_INPUT_INTERFACE() or
  118.  *  REF_xxx_INPUT_INTERFACE()
  119.  *
  120.  *  The xxx must be lowercase, and is intended to be the indentifying substring
  121.  *  in the function's name.  Acceptable values are 'sub' or 'add' from the
  122.  *  functions arm_add_q31.
  123.  */
  124.  
  125. #define ARM_cmplx_conj_INPUT_INTERFACE(input, block_size)           \
  126.     PAREN(input, complex_math_output_fut_a.data_ptr, block_size)
  127.  
  128. #define REF_cmplx_conj_INPUT_INTERFACE(input, block_size)           \
  129.     PAREN(input, complex_math_output_ref_a.data_ptr, block_size)
  130.  
  131. #define ARM_cmplx_dot_prod_INPUT_INTERFACE(input_a, input_b, block_size) \
  132.     PAREN(input_a, input_b, block_size,                                 \
  133.           complex_math_output_fut_a.data_ptr,                          \
  134.           complex_math_output_fut_b.data_ptr)
  135.  
  136. #define REF_cmplx_dot_prod_INPUT_INTERFACE(input_a, input_b, block_size) \
  137.     PAREN(input_a, input_b, block_size,                                 \
  138.           complex_math_output_ref_a.data_ptr,                          \
  139.           complex_math_output_ref_b.data_ptr)
  140.  
  141. #define ARM_cmplx_mag_INPUT_INTERFACE(input, block_size)            \
  142.     PAREN(input, complex_math_output_fut_a.data_ptr, block_size)
  143.  
  144. #define REF_cmplx_mag_INPUT_INTERFACE(input, block_size)            \
  145.     PAREN(input, complex_math_output_ref_a.data_ptr, block_size)
  146.  
  147. #define ARM_cmplx_mag_squared_INPUT_INTERFACE(input, block_size)    \
  148.     PAREN(input, complex_math_output_fut_a.data_ptr, block_size)
  149.  
  150. #define REF_cmplx_mag_squared_INPUT_INTERFACE(input, block_size)    \
  151.     PAREN(input, complex_math_output_ref_a.data_ptr, block_size)
  152.  
  153. #define ARM_cmplx_mult_cmplx_INPUT_INTERFACE(input_a, input_b, block_size) \
  154.     PAREN(input_a, input_b, complex_math_output_fut_a.data_ptr, block_size)
  155.  
  156. #define REF_cmplx_mult_cmplx_INPUT_INTERFACE(input_a, input_b, block_size) \
  157.     PAREN(input_a, input_b, complex_math_output_ref_a.data_ptr, block_size)
  158.  
  159. #define ARM_cmplx_mult_real_INPUT_INTERFACE(input_a, input_b, block_size) \
  160.     PAREN(input_a, input_b, complex_math_output_fut_a.data_ptr, block_size)
  161.  
  162. #define REF_cmplx_mult_real_INPUT_INTERFACE(input_a, input_b, block_size) \
  163.     PAREN(input_a, input_b, complex_math_output_ref_a.data_ptr, block_size)
  164.  
  165. /*--------------------------------------------------------------------------------*/
  166. /* Test Templates */
  167. /*--------------------------------------------------------------------------------*/
  168.  
  169. /**
  170.  *  Specialization of #TEST_TEMPLATE_BUF1_BLK() for complex math tests.
  171.  *
  172.  *  @note This macro relies on the existance of ARM_xxx_INPUT_INTERFACE and
  173.  *  REF_xxx_INPUT_INTERFACEs.
  174.  */
  175. #define COMPLEX_MATH_DEFINE_TEST_TEMPLATE_BUF1_BLK(fn_name,         \
  176.                                                    suffix,          \
  177.                                                    input_type,      \
  178.                                                    output_type,     \
  179.                                                    comparison_interface) \
  180.     JTEST_DEFINE_TEST(arm_##fn_name##_##suffix##_test,              \
  181.                       arm_##fn_name##_##suffix)                     \
  182.     {                                                               \
  183.         TEST_TEMPLATE_BUF1_BLK(                                     \
  184.             complex_math_f_all,                                     \
  185.             complex_math_block_sizes,                               \
  186.             input_type,                                             \
  187.             output_type,                                            \
  188.             arm_##fn_name##_##suffix,                               \
  189.             ARM_##fn_name##_INPUT_INTERFACE,                        \
  190.             ref_##fn_name##_##suffix,                               \
  191.             REF_##fn_name##_INPUT_INTERFACE,                        \
  192.             comparison_interface);                                  \
  193.     }
  194.  
  195. /**
  196.  *  Specialization of #TEST_TEMPLATE_BUF2_BLK1() for complex math tests.
  197.  *
  198.  *  @note This macro relies on the existance of ARM_xxx_INPUT_INTERFACE and
  199.  *  REF_xxx_INPUT_INTERFACEs.
  200.  */
  201. #define COMPLEX_MATH_DEFINE_TEST_TEMPLATE_BUF2_BLK(fn_name,         \
  202.                                                    suffix,          \
  203.                                                    input_type,      \
  204.                                                    output_type,     \
  205.                                                    comparison_interface) \
  206.     JTEST_DEFINE_TEST(arm_##fn_name##_##suffix##_test,              \
  207.                       arm_##fn_name##_##suffix)                     \
  208.     {                                                               \
  209.         TEST_TEMPLATE_BUF2_BLK(                                     \
  210.             complex_math_f_all,                                     \
  211.             complex_math_f_all,                                     \
  212.             complex_math_block_sizes,                               \
  213.             input_type,                                             \
  214.             output_type,                                            \
  215.             arm_##fn_name##_##suffix,                               \
  216.             ARM_##fn_name##_INPUT_INTERFACE,                        \
  217.             ref_##fn_name##_##suffix,                               \
  218.             REF_##fn_name##_INPUT_INTERFACE,                        \
  219.             comparison_interface);                                  \
  220.     }
  221.  
  222. #endif /* _COMPLEX_MATH_TEMPLATES_H_ */
  223.