1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#include <volk/volk.h>
#include <qa_16s_permute_and_scalar_add_aligned16.h>
#include <volk/volk_16s_permute_and_scalar_add_aligned16.h>
#include <cstdlib>
#include <ctime>
//test for sse2
#ifndef LV_HAVE_SSE2
void qa_16s_permute_and_scalar_add_aligned16::t1() {
printf("sse2 not available... no test performed\n");
}
#else
void qa_16s_permute_and_scalar_add_aligned16::t1() {
const int vlen = 64;
unsigned int num_bytes = vlen << 1;
volk_environment_init();
clock_t start, end;
double total;
__VOLK_ATTR_ALIGNED(16) short target[vlen];
__VOLK_ATTR_ALIGNED(16) short target2[vlen];
__VOLK_ATTR_ALIGNED(16) short src0[vlen];
__VOLK_ATTR_ALIGNED(16) short permute_indexes[vlen];
__VOLK_ATTR_ALIGNED(16) short cntl0[vlen];
__VOLK_ATTR_ALIGNED(16) short cntl1[vlen];
__VOLK_ATTR_ALIGNED(16) short cntl2[vlen];
__VOLK_ATTR_ALIGNED(16) short cntl3[vlen];
__VOLK_ATTR_ALIGNED(16) short scalars[4] = {1, 2, 3, 4};
for(int i = 0; i < vlen; ++i) {
src0[i] = i;
permute_indexes[i] = (3 * i)%vlen;
cntl0[i] = 0xff;
cntl1[i] = 0xff * (i%2);
cntl2[i] = 0xff * ((i>>1)%2);
cntl3[i] = 0xff * ((i%4) == 3);
}
printf("16s_permute_and_scalar_add_aligned\n");
start = clock();
for(int i = 0; i < 100000; ++i) {
volk_16s_permute_and_scalar_add_aligned16_manual(target, src0, permute_indexes, cntl0, cntl1, cntl2, cntl3, scalars, num_bytes, "generic");
}
end = clock();
total = (double)(end-start)/(double)CLOCKS_PER_SEC;
printf("generic_time: %f\n", total);
start = clock();
for(int i = 0; i < 100000; ++i) {
volk_16s_permute_and_scalar_add_aligned16_manual(target2, src0, permute_indexes, cntl0, cntl1, cntl2, cntl3, scalars, num_bytes, "sse2");
}
end = clock();
total = (double)(end-start)/(double)CLOCKS_PER_SEC;
printf("sse2_time: %f\n", total);
for(int i = 0; i < vlen; ++i) {
//printf("generic... %d, sse2... %d\n", target[i], target2[i]);
}
for(int i = 0; i < vlen; ++i) {
CPPUNIT_ASSERT(target[i] == target2[i]);
}
}
#endif
|