extern "C" { extern void dot_test(); } #include "allocator.h" #include #include #include #include #include #include "dsp/basic_math_functions.h" #include "dsp/basic_math_functions_f16.h" template static void complex_test(const T scale) { std::cout << "----\r\n" << "N = " << NB << "\r\n"; #if defined(STATIC_TEST) PVector a; PVector b; PVector c; PVector d; PVector res; #else PVector a(NB); PVector b(NB); PVector c(NB); PVector d(NB); PVector res(NB); #endif init_array(a,NB); init_array(b,NB); init_array(c,NB); init_array(d,NB); INIT_SYSTICK; START_CYCLE_MEASUREMENT; startSectionNB(1); O result = dot(scale*(a+b),c*d); stopSectionNB(1); STOP_CYCLE_MEASUREMENT; O ref; PVector tmp1; PVector tmp2; INIT_SYSTICK; START_CYCLE_MEASUREMENT; cmsisdsp_dot_expr(a.const_ptr(), b.const_ptr(), c.const_ptr(), d.const_ptr(), tmp1.ptr(), tmp2.ptr(), scale, ref,NB); STOP_CYCLE_MEASUREMENT; if (!validate(result,ref)) { printf("dot expr failed \r\n"); } std::cout << "=====\r\n"; } template static void test() { std::cout << "----\r\n" << "N = " << NB << "\r\n"; #if defined(STATIC_TEST) PVector a; PVector b; PVector res; #else PVector a(NB); PVector b(NB); PVector res(NB); #endif init_array(a,NB); init_array(b,NB); INIT_SYSTICK; START_CYCLE_MEASUREMENT; startSectionNB(1); O result = dot(a,b); stopSectionNB(1); STOP_CYCLE_MEASUREMENT; O ref; INIT_SYSTICK; START_CYCLE_MEASUREMENT; cmsisdsp_dot(a.const_ptr(),b.const_ptr(),ref,NB); STOP_CYCLE_MEASUREMENT; if (!validate(result,ref)) { printf("dot failed \r\n"); } std::cout << "=====\r\n"; } template void all_dot_test() { const int nb_tails = TailForTests::tail; const int nb_loops = TailForTests::loop; using ACC = typename number_traits::accumulator; constexpr auto v = TestConstant::v; title("Dot product"); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); if constexpr (!std::is_same::value) { test(); } test(); test(); test(); test(); test(); title("Dot product with expressions"); complex_test(v); complex_test(v); complex_test(v); complex_test(v); complex_test(v); complex_test(v); complex_test(v); complex_test(v); complex_test(v); complex_test(v); if constexpr (!std::is_same::value) { complex_test(v); } complex_test(v); complex_test(v); complex_test(v); complex_test(v); complex_test(v); //print_map("Stats",max_stats); } void dot_test() { #if defined(DOT_TEST) #if defined(F64_DT) all_dot_test(); #endif #if defined(F32_DT) all_dot_test(); #endif #if defined(F16_DT) && !defined(DISABLEFLOAT16) all_dot_test(); #endif #if defined(Q31_DT) all_dot_test(); #endif #if defined(Q15_DT) all_dot_test(); #endif #if defined(Q7_DT) all_dot_test(); #endif #endif }