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