diff options
-rw-r--r-- | volk/lib/qa_16sc_magnitude_32f_aligned16.cc | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/volk/lib/qa_16sc_magnitude_32f_aligned16.cc b/volk/lib/qa_16sc_magnitude_32f_aligned16.cc index 06dff2fd5..2c9e48f6e 100644 --- a/volk/lib/qa_16sc_magnitude_32f_aligned16.cc +++ b/volk/lib/qa_16sc_magnitude_32f_aligned16.cc @@ -8,7 +8,47 @@ #ifndef LV_HAVE_SSE3 void qa_16sc_magnitude_32f_aligned16::t1() { - printf("sse3 not available... no test performed\n"); + clock_t start, end; + double total; + const int vlen = 3201; + const int ITERS = 10000; + std::complex<int16_t> input0[vlen] __attribute__ ((aligned (16))); + + float output_generic[vlen] __attribute__ ((aligned (16))); + float output_known[vlen] __attribute__ ((aligned (16))); + + int16_t* inputLoad = (int16_t*)input0; + for(int i = 0; i < 2*vlen; ++i) { + inputLoad[i] = (int16_t)(rand() - (RAND_MAX/2)); + } + printf("16sc_magnitude_32f_aligned\n"); + + float scale = 32768.0; + for(int i = 0; i < vlen; ++i) { + float re = (float)(input0[i].real())/scale; + float im = (float)(input0[i].imag())/scale; + output_known[i] = sqrt(re*re + im*im); + } + + start = clock(); + for(int count = 0; count < ITERS; ++count) { + volk_16sc_magnitude_32f_aligned16_manual(output_generic, input0, scale, vlen, "generic"); + } + end = clock(); + total = (double)(end-start)/(double)CLOCKS_PER_SEC; + printf("generic_time: %f\n", total); + + /* + for(int i = 0; i < 100; ++i) { + printf("inputs: %d + j%d\n", input0[i].real(), input0[i].imag()); + printf("generic... %f == %f\n", output_generic[i], output_known[i]); + } + */ + + for(int i = 0; i < vlen; ++i) { + //printf("%d...%d\n", output0[i], output01[i]); + CPPUNIT_ASSERT_DOUBLES_EQUAL(output_generic[i], output_known[i], fabs(output_generic[i])*1e-4); + } } #else |