root / volk / lib / qa_16s_convert_8s_aligned16.cc @ d8031649
History | View | Annotate | Download (1.6 kB)
| 1 | #include <volk/volk.h> |
|---|---|
| 2 | #include <qa_16s_convert_8s_aligned16.h> |
| 3 | #include <volk/volk_16s_convert_8s_aligned16.h> |
| 4 | #include <cstdlib> |
| 5 | |
| 6 | //test for sse2
|
| 7 | |
| 8 | #ifndef LV_HAVE_SSE2
|
| 9 | |
| 10 | void qa_16s_convert_8s_aligned16::t1() {
|
| 11 | printf("sse2 not available... no test performed\n");
|
| 12 | } |
| 13 | |
| 14 | #else
|
| 15 | |
| 16 | void qa_16s_convert_8s_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 | int16_t input0[vlen] __attribute__ ((aligned (16)));
|
| 24 | |
| 25 | int8_t output_generic[vlen] __attribute__ ((aligned (16)));
|
| 26 | int8_t output_sse2[vlen] __attribute__ ((aligned (16)));
|
| 27 | |
| 28 | for(int i = 0; i < vlen; ++i) { |
| 29 | input0[i] = ((int16_t)(((float) (rand() - (RAND_MAX/2))) / static_cast<float>((RAND_MAX/2)) * 32768.0)); |
| 30 | } |
| 31 | printf("16s_convert_8s_aligned\n");
|
| 32 | |
| 33 | start = clock(); |
| 34 | for(int count = 0; count < ITERS; ++count) { |
| 35 | volk_16s_convert_8s_aligned16_manual(output_generic, input0, vlen, "generic");
|
| 36 | } |
| 37 | end = clock(); |
| 38 | total = (double)(end-start)/(double)CLOCKS_PER_SEC; |
| 39 | printf("generic_time: %f\n", total);
|
| 40 | |
| 41 | start = clock(); |
| 42 | for(int count = 0; count < ITERS; ++count) { |
| 43 | volk_16s_convert_8s_aligned16_manual(output_sse2, input0, vlen, "sse2");
|
| 44 | } |
| 45 | end = clock(); |
| 46 | total = (double)(end-start)/(double)CLOCKS_PER_SEC; |
| 47 | printf("sse2_time: %f\n", total);
|
| 48 | |
| 49 | for(int i = 0; i < 1; ++i) { |
| 50 | //printf("inputs: %d, %d\n", input0[i*2], input0[i*2 + 1]);
|
| 51 | //printf("generic... %d, ssse3... %d\n", output0[i], output1[i]);
|
| 52 | } |
| 53 | |
| 54 | for(int i = 0; i < vlen; ++i) { |
| 55 | //printf("%d -> %d...%d\n", input0[i], output_generic[i], output_sse2[i]);
|
| 56 | CPPUNIT_ASSERT_EQUAL(output_generic[i], output_sse2[i]); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | #endif
|