Subversion Repositories AFRtranscoder

Rev

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

  1. #ifndef _FAST_MATH_TEMPLATES_H_
  2. #define _FAST_MATH_TEMPLATES_H_
  3.  
  4. /*--------------------------------------------------------------------------------*/
  5. /* Includes */
  6. /*--------------------------------------------------------------------------------*/
  7.  
  8. #include "test_templates.h"
  9. #include <string.h>             /* memcpy() */
  10.  
  11. /*--------------------------------------------------------------------------------*/
  12. /* Group Specific Templates */
  13. /*--------------------------------------------------------------------------------*/
  14.  
  15. /**
  16.  * Comparison SNR thresholds for the data types used in transform_tests.
  17.  */
  18. #define FAST_MATH_SNR_THRESHOLD_float32_t 95
  19. #define FAST_MATH_SNR_THRESHOLD_q31_t     95
  20. #define FAST_MATH_SNR_THRESHOLD_q15_t     45
  21.  
  22. /**
  23.  *  Compare the outputs from the function under test and the reference
  24.  *  function using SNR.
  25.  */
  26. #define FAST_MATH_SNR_COMPARE_INTERFACE(block_size,     \
  27.                                         output_type)    \
  28.     do                                                  \
  29.     {                                                   \
  30.         TEST_CONVERT_AND_ASSERT_SNR(                    \
  31.             fast_math_output_f32_ref,                   \
  32.             (output_type *) fast_math_output_ref,       \
  33.             fast_math_output_f32_fut,                   \
  34.             (output_type *) fast_math_output_fut,       \
  35.             block_size,                                 \
  36.             output_type,                                \
  37.             FAST_MATH_SNR_THRESHOLD_##output_type       \
  38.             );                                          \
  39.     } while (0)
  40.  
  41.  
  42. /*--------------------------------------------------------------------------------*/
  43. /* TEST Templates */
  44. /*--------------------------------------------------------------------------------*/
  45.  
  46. #define SQRT_TEST_TEMPLATE_ELT1(suffix)                             \
  47.                                                                     \
  48.     JTEST_DEFINE_TEST(arm_sqrt_##suffix##_test, arm_sqrt_##suffix)  \
  49.     {                                                               \
  50.         uint32_t i;                                                 \
  51.                                                                     \
  52.         JTEST_COUNT_CYCLES(                                         \
  53.             for(i=0;i<FAST_MATH_MAX_LEN;i++)                        \
  54.             {                                                       \
  55.                 arm_sqrt_##suffix(                                  \
  56.                     (suffix##_t)fast_math_##suffix##_inputs[i]      \
  57.                     ,(suffix##_t*)fast_math_output_fut + i);        \
  58.             });                                                     \
  59.                                                                     \
  60.         for(i=0;i<FAST_MATH_MAX_LEN;i++)                            \
  61.         {                                                           \
  62.             ref_sqrt_##suffix(                                      \
  63.                 (suffix##_t)fast_math_##suffix##_inputs[i]          \
  64.                 ,(suffix##_t*)fast_math_output_ref + i);            \
  65.         }                                                           \
  66.                                                                     \
  67.         FAST_MATH_SNR_COMPARE_INTERFACE(                            \
  68.             FAST_MATH_MAX_LEN,                                      \
  69.             suffix##_t);                                            \
  70.                                                                     \
  71.         return JTEST_TEST_PASSED;                                   \
  72.     }
  73.  
  74.  
  75. #define SIN_COS_TEST_TEMPLATE_ELT1(suffix, type, func)                  \
  76.                                                                         \
  77.         JTEST_DEFINE_TEST(arm_##func##_##suffix##_test, arm_##func##_##suffix) \
  78.         {                                                               \
  79.             uint32_t i;                                                 \
  80.                                                                         \
  81.             JTEST_COUNT_CYCLES(                                         \
  82.                 for(i=0;i<FAST_MATH_MAX_LEN;i++)                        \
  83.                 {                                                       \
  84.                     *((type*)fast_math_output_fut + i) = arm_##func##_##suffix( \
  85.                         fast_math_##suffix##_inputs[i]);                \
  86.                 });                                                     \
  87.                                                                         \
  88.             JTEST_COUNT_CYCLES(                                         \
  89.                 for(i=0;i<FAST_MATH_MAX_LEN;i++)                        \
  90.                 {                                                       \
  91.                     *((type*)fast_math_output_ref + i) = ref_##func##_##suffix( \
  92.                         fast_math_##suffix##_inputs[i]);                \
  93.                 });                                                     \
  94.                                                                         \
  95.             FAST_MATH_SNR_COMPARE_INTERFACE(                            \
  96.                 FAST_MATH_MAX_LEN,                                      \
  97.                 type);                                                  \
  98.                                                                         \
  99.             return JTEST_TEST_PASSED;                                   \
  100.         }
  101.  
  102. #endif /* _FAST_MATH_TEMPLATES_H_ */
  103.