Statistics
| Branch: | Tag: | Revision:

root / volk / lib / qa_16s_branch_4_state_8_aligned16.cc @ 4c6316e1

History | View | Annotate | Download (4 kB)

1
#include <volk/volk.h>
2
#include <qa_16s_branch_4_state_8_aligned16.h>
3
#include <cstdlib>
4
#include <ctime>
5
6
//test for ssse3
7
8
#ifndef LV_HAVE_SSSE3
9
10
void qa_16s_branch_4_state_8_aligned16::t1() {
11
  printf("ssse3 not available... no test performed\n");
12
}
13
14
#else
15
16
void qa_16s_branch_4_state_8_aligned16::t1() {
17
  const int num_iters = 1000000;
18
  const int vlen = 32;
19
20
  static char permute0[16]__attribute__((aligned(16))) = {0x0e, 0x0f, 0x0a, 0x0b, 0x04, 0x05, 0x00, 0x01, 0x0c, 0x0d, 0x08, 0x09, 0x06, 0x07, 0x02, 0x03};
21
  static char permute1[16]__attribute__((aligned(16))) = {0x0c, 0x0d, 0x08, 0x09, 0x06, 0x07, 0x02, 0x03, 0x0e, 0x0f, 0x0a, 0x0b, 0x04, 0x05, 0x00, 0x01};
22
  static char permute2[16]__attribute__((aligned(16))) = {0x02, 0x03, 0x06, 0x07, 0x08, 0x09, 0x0c, 0x0d, 0x00, 0x01, 0x04, 0x05, 0x0a, 0x0b, 0x0e, 0x0f};
23
  static char permute3[16]__attribute__((aligned(16))) = {0x00, 0x01, 0x04, 0x05, 0x0a, 0x0b, 0x0e, 0x0f, 0x02, 0x03, 0x06, 0x07, 0x08, 0x09, 0x0c, 0x0d};
24
  static char* permuters[4] = {permute0, permute1, permute2, permute3};
25
  
26
  unsigned int num_bytes = vlen << 1;
27
28
  volk_environment_init();
29
  clock_t start, end;
30
  double total;
31
  
32
  __VOLK_ATTR_ALIGNED(16) short target[vlen];
33
  __VOLK_ATTR_ALIGNED(16) short target2[vlen];
34
  __VOLK_ATTR_ALIGNED(16) short target3[vlen];
35
  
36
  __VOLK_ATTR_ALIGNED(16) short src0[vlen];
37
  __VOLK_ATTR_ALIGNED(16) short permute_indexes[vlen] =  {
38
7, 5, 2, 0, 6, 4, 3, 1, 6, 4, 3, 1, 7, 5, 2, 0, 1, 3, 4, 6, 0, 2, 5, 7, 0, 2, 5, 7, 1, 3, 4, 6 };
39
  __VOLK_ATTR_ALIGNED(16) short cntl0[vlen] = {
40
    0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 };
41
  __VOLK_ATTR_ALIGNED(16) short cntl1[vlen] = {
42
    0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 };
43
  __VOLK_ATTR_ALIGNED(16) short cntl2[vlen] = {
44
    0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000 };
45
  __VOLK_ATTR_ALIGNED(16) short cntl3[vlen] =  {
46
    0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff };
47
  __VOLK_ATTR_ALIGNED(16) short scalars[4] = {1, 2, 3, 4};
48
  
49
  
50
51
  for(int i = 0; i < vlen; ++i) {
52
    src0[i] = i;
53
    
54
  }
55
  
56
57
  printf("16s_branch_4_state_8_aligned\n");
58
  
59
  
60
  start = clock();
61
  for(int i = 0; i < num_iters; ++i) {
62
    volk_16s_permute_and_scalar_add_aligned16_manual(target, src0, permute_indexes, cntl0, cntl1, cntl2, cntl3, scalars, num_bytes, "sse2");
63
  }
64
  end = clock();
65
  
66
  total = (double)(end-start)/(double)CLOCKS_PER_SEC;
67
68
  printf("permute_and_scalar_add_time: %f\n", total);
69
  
70
  
71
72
  start = clock();
73
  for(int i = 0; i < num_iters; ++i) {
74
    volk_16s_branch_4_state_8_aligned16_manual(target2, src0, permuters, cntl2, cntl3, scalars, "ssse3");
75
  }
76
  end = clock();
77
78
  total = (double)(end-start)/(double)CLOCKS_PER_SEC;
79
80
  printf("branch_4_state_8_time, ssse3: %f\n", total);
81
  
82
  start = clock();
83
  for(int i = 0; i < num_iters; ++i) {
84
    volk_16s_branch_4_state_8_aligned16_manual(target3, src0, permuters, cntl2, cntl3, scalars, "generic");
85
  }
86
  end = clock();
87
  
88
  total = (double)(end-start)/(double)CLOCKS_PER_SEC;
89
90
  printf("permute_and_scalar_add_time, generic: %f\n", total);
91
  
92
  
93
  
94
  for(int i = 0; i < vlen; ++i) {
95
    printf("psa... %d, b4s8... %d\n", target[i], target3[i]);
96
  }
97
  
98
  for(int i = 0; i < vlen; ++i) {
99
    
100
    CPPUNIT_ASSERT(target[i] == target2[i]);
101
    CPPUNIT_ASSERT(target[i] == target3[i]);
102
  }
103
}
104
105
106
#endif