root / volk / lib / qa_32f_calc_spectral_noise_floor_aligned16.cc @ 23914465
History | View | Annotate | Download (1.7 kB)
| 1 | #include <volk/volk.h> |
|---|---|
| 2 | #include <qa_32f_calc_spectral_noise_floor_aligned16.h> |
| 3 | #include <volk/volk_32f_calc_spectral_noise_floor_aligned16.h> |
| 4 | #include <cstdlib> |
| 5 | #include <math.h> |
| 6 | |
| 7 | //test for sse
|
| 8 | |
| 9 | #ifndef LV_HAVE_SSE
|
| 10 | |
| 11 | void qa_32f_calc_spectral_noise_floor_aligned16::t1() {
|
| 12 | printf("sse not available... no test performed\n");
|
| 13 | } |
| 14 | |
| 15 | #else
|
| 16 | |
| 17 | void qa_32f_calc_spectral_noise_floor_aligned16::t1() {
|
| 18 | |
| 19 | volk_environment_init(); |
| 20 | clock_t start, end; |
| 21 | double total;
|
| 22 | const int vlen = 3201; |
| 23 | const int ITERS = 100000; |
| 24 | float input0[vlen] __attribute__ ((aligned (16))); |
| 25 | |
| 26 | float output0[1] __attribute__ ((aligned (16))); |
| 27 | float output01[1] __attribute__ ((aligned (16))); |
| 28 | |
| 29 | for(int i = 0; i < vlen; ++i) { |
| 30 | input0[i] = ((float) (rand() - (RAND_MAX/2))) / static_cast<float>((RAND_MAX/2)); |
| 31 | } |
| 32 | printf("32f_calc_spectral_noise_floor_aligned\n");
|
| 33 | |
| 34 | start = clock(); |
| 35 | for(int count = 0; count < ITERS; ++count) { |
| 36 | volk_32f_calc_spectral_noise_floor_aligned16_manual(output0, input0, 20, vlen, "generic"); |
| 37 | } |
| 38 | end = clock(); |
| 39 | total = (double)(end-start)/(double)CLOCKS_PER_SEC; |
| 40 | printf("generic_time: %f\n", total);
|
| 41 | start = clock(); |
| 42 | for(int count = 0; count < ITERS; ++count) { |
| 43 | volk_32f_calc_spectral_noise_floor_aligned16_manual(output01, input0, 20, vlen, "sse"); |
| 44 | } |
| 45 | end = clock(); |
| 46 | total = (double)(end-start)/(double)CLOCKS_PER_SEC; |
| 47 | printf("sse_time: %f\n", total);
|
| 48 | for(int i = 0; i < 1; ++i) { |
| 49 | //printf("inputs: %d, %d\n", input0[i*2], input0[i*2 + 1]);
|
| 50 | //printf("generic... %d, ssse3... %d\n", output0[i], output1[i]);
|
| 51 | } |
| 52 | |
| 53 | for(int i = 0; i < 1; ++i) { |
| 54 | //printf("%d...%d\n", output0[i], output01[i]);
|
| 55 | CPPUNIT_ASSERT_DOUBLES_EQUAL(output0[i], output01[i], fabs(output0[i])*1e-4); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | #endif
|