extern "C" { extern void vector_test(); } #include "allocator.h" #include #include #include #include #include template static void test() { std::cout << "----\r\n" << "N = " << NB << "\r\n"; #if defined(STATIC_TEST) PVector a; PVector b; #else PVector a(NB); PVector b(NB); #endif init_array(a,NB); init_array(b,NB); INIT_SYSTICK; START_CYCLE_MEASUREMENT; startSectionNB(1); #if defined(STATIC_TEST) PVector res = a + b; #else PVector res = copy(a + b); #endif stopSectionNB(1); STOP_CYCLE_MEASUREMENT; INIT_SYSTICK START_CYCLE_MEASUREMENT; #if defined(STATIC_TEST) PVector ref; #else PVector ref(NB); #endif cmsisdsp_add(a.const_ptr(),b.const_ptr(),ref.ptr(),NB); STOP_CYCLE_MEASUREMENT; if (!validate(res.const_ptr(),ref.const_ptr(),NB)) { printf("add failed \r\n"); } std::cout << "=====\r\n"; } template void test_view() { std::cout << "----\r\n" << "N = " << NB << "\r\n"; #if defined(STATIC_TEST) PVector a; PVector b; #else PVector a(NB); PVector b(NB); #endif init_array(a,NB); init_array(b,NB); //std::cout << a; //std::cout << "\r\n"; //std::cout << PVector(a.template sub<2>()); INIT_SYSTICK; START_CYCLE_MEASUREMENT; startSectionNB(1); #if defined(STATIC_TEST) PVector res = a.template sub<2>() + b.template sub<2>(); #else PVector res = a.template sub<2>() + b.template sub<2>(); #endif stopSectionNB(1); STOP_CYCLE_MEASUREMENT; PVector ref; INIT_SYSTICK; START_CYCLE_MEASUREMENT; PVector da(a.template sub<2>()); PVector db(b.template sub<2>()); cmsisdsp_add(da.const_ptr(),db.const_ptr(),ref.ptr(),NB/2); STOP_CYCLE_MEASUREMENT; if (!validate(res.const_ptr(),ref.const_ptr(),NB/2)) { printf("add failed \r\n"); } std::cout << "=====\r\n"; } template void test_fill() { std::cout << "----\r\n" << "N = " << NB << "\r\n"; INIT_SYSTICK; START_CYCLE_MEASUREMENT; startSectionNB(1); #if defined(STATIC_TEST) PVector res(T(1)); #else PVector res(NB,T(1)); #endif stopSectionNB(1); STOP_CYCLE_MEASUREMENT; } template void all_vector_test() { const int nb_tails = TailForTests::tail; const int nb_loops = TailForTests::loop; title("Vector"); // For benchmarks test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); // For tests test(); test(); test(); test(); test(); title("Vector View"); test_view(); test_view(); test_view(); test_view(); test_view(); if constexpr (nb_tails>1) { test_view(); } test_view(); test_view(); test_view(); title("Vector fill"); test_fill(); test_fill(); test_fill(); test_fill(); test_fill(); test_fill(); test_fill(); test_fill(); test_fill(); test_fill(); } void vector_test() { #if defined(VECTOR_TEST) #if defined(F64_DT) all_vector_test(); #endif #if defined(F32_DT) all_vector_test(); #endif #if defined(F16_DT) && !defined(DISABLEFLOAT16) all_vector_test(); #endif #if defined(Q31_DT) all_vector_test(); #endif #if defined(Q15_DT) all_vector_test(); #endif #if defined(Q7_DT) all_vector_test(); #endif #endif }