root / volk / lib / qa_16sc_deinterleave_32f_aligned16.cc @ 82cafc43
History | View | Annotate | Download (2.6 kB)
| 1 | #include <volk/volk.h> |
|---|---|
| 2 | #include <qa_16sc_deinterleave_32f_aligned16.h> |
| 3 | #include <volk/volk_16sc_deinterleave_32f_aligned16.h> |
| 4 | #include <cstdlib> |
| 5 | #include <ctime> |
| 6 | |
| 7 | //test for sse
|
| 8 | |
| 9 | #ifndef LV_HAVE_SSE2
|
| 10 | |
| 11 | void qa_16sc_deinterleave_32f_aligned16::t1() {
|
| 12 | printf("sse2 not available... no test performed\n");
|
| 13 | } |
| 14 | |
| 15 | #else
|
| 16 | |
| 17 | void qa_16sc_deinterleave_32f_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 | std::complex<int16_t> input0[vlen] __attribute__ ((aligned (16)));
|
| 25 | |
| 26 | float output_generic[vlen] __attribute__ ((aligned (16))); |
| 27 | float output_generic1[vlen] __attribute__ ((aligned (16))); |
| 28 | float output_sse2[vlen] __attribute__ ((aligned (16))); |
| 29 | float output_sse21[vlen] __attribute__ ((aligned (16))); |
| 30 | float output_orc[vlen] __attribute__ ((aligned (16))); |
| 31 | float output_orc1[vlen] __attribute__ ((aligned (16))); |
| 32 | |
| 33 | int16_t* loadInput = (int16_t*)input0; |
| 34 | for(int i = 0; i < vlen*2; ++i) { |
| 35 | loadInput[i] =((int16_t)((((float) (rand() - (RAND_MAX/2))) / static_cast<float>((RAND_MAX/2))) * 32768.0)); |
| 36 | } |
| 37 | printf("16sc_deinterleave_32f_aligned\n");
|
| 38 | |
| 39 | start = clock(); |
| 40 | for(int count = 0; count < ITERS; ++count) { |
| 41 | volk_16sc_deinterleave_32f_aligned16_manual(output_generic, output_generic1, input0, 32768.0, vlen, "generic"); |
| 42 | } |
| 43 | end = clock(); |
| 44 | total = (double)(end-start)/(double)CLOCKS_PER_SEC; |
| 45 | printf("generic_time: %f\n", total);
|
| 46 | start = clock(); |
| 47 | for(int count = 0; count < ITERS; ++count) { |
| 48 | volk_16sc_deinterleave_32f_aligned16_manual(output_orc, output_orc1, input0, 32768.0, vlen, "orc"); |
| 49 | } |
| 50 | end = clock(); |
| 51 | total = (double)(end-start)/(double)CLOCKS_PER_SEC; |
| 52 | printf("orc_time: %f\n", total);
|
| 53 | start = clock(); |
| 54 | for(int count = 0; count < ITERS; ++count) { |
| 55 | volk_16sc_deinterleave_32f_aligned16_manual(output_sse2, output_sse21, input0, 32768.0, vlen, "sse"); |
| 56 | } |
| 57 | end = clock(); |
| 58 | total = (double)(end-start)/(double)CLOCKS_PER_SEC; |
| 59 | printf("sse_time: %f\n", total);
|
| 60 | |
| 61 | for(int i = 0; i < 1; ++i) { |
| 62 | //printf("inputs: %d, %d\n", input0[i*2], input0[i*2 + 1]);
|
| 63 | //printf("generic... %d, ssse3... %d\n", output0[i], output1[i]);
|
| 64 | } |
| 65 | |
| 66 | for(int i = 0; i < vlen; ++i) { |
| 67 | //printf("%d...%d\n", output0[i], output01[i]);
|
| 68 | CPPUNIT_ASSERT_DOUBLES_EQUAL(output_generic[i], output_sse2[i], fabs(output_generic[i])*1e-4); |
| 69 | CPPUNIT_ASSERT_DOUBLES_EQUAL(output_generic1[i], output_sse21[i], fabs(output_generic1[i])*1e-4); |
| 70 | CPPUNIT_ASSERT_DOUBLES_EQUAL(output_generic[i], output_orc[i], fabs(output_generic[i])*1e-4); |
| 71 | CPPUNIT_ASSERT_DOUBLES_EQUAL(output_generic1[i], output_orc1[i], fabs(output_generic1[i])*1e-4); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | #endif
|