GNU Radio 3.7.2 C++ API
volk_16i_x4_quad_max_star_16i.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_16i_x4_quad_max_star_16i_a_H
2 #define INCLUDED_volk_16i_x4_quad_max_star_16i_a_H
3 
4 
5 #include<inttypes.h>
6 #include<stdio.h>
7 
8 
9 
10 
11 
12 #ifdef LV_HAVE_SSE2
13 
14 #include<emmintrin.h>
15 
16 static inline void volk_16i_x4_quad_max_star_16i_a_sse2(short* target, short* src0, short* src1, short* src2, short* src3, unsigned int num_points) {
17 
18  const unsigned int num_bytes = num_points*2;
19 
20  int i = 0;
21 
22  int bound = (num_bytes >> 4);
23  int bound_copy = bound;
24  int leftovers = (num_bytes >> 1) & 7;
25 
26  __m128i *p_target, *p_src0, *p_src1, *p_src2, *p_src3;
27  p_target = (__m128i*) target;
28  p_src0 = (__m128i*)src0;
29  p_src1 = (__m128i*)src1;
30  p_src2 = (__m128i*)src2;
31  p_src3 = (__m128i*)src3;
32 
33 
34 
35  __m128i xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8;
36 
37  while(bound_copy > 0) {
38 
39  xmm1 = _mm_load_si128(p_src0);
40  xmm2 = _mm_load_si128(p_src1);
41  xmm3 = _mm_load_si128(p_src2);
42  xmm4 = _mm_load_si128(p_src3);
43 
44  xmm5 = _mm_setzero_si128();
45  xmm6 = _mm_setzero_si128();
46  xmm7 = xmm1;
47  xmm8 = xmm3;
48 
49 
50  xmm1 = _mm_sub_epi16(xmm2, xmm1);
51 
52 
53 
54  xmm3 = _mm_sub_epi16(xmm4, xmm3);
55 
56  xmm5 = _mm_cmpgt_epi16(xmm1, xmm5);
57  xmm6 = _mm_cmpgt_epi16(xmm3, xmm6);
58 
59 
60 
61  xmm2 = _mm_and_si128(xmm5, xmm2);
62  xmm4 = _mm_and_si128(xmm6, xmm4);
63  xmm5 = _mm_andnot_si128(xmm5, xmm7);
64  xmm6 = _mm_andnot_si128(xmm6, xmm8);
65 
66  xmm5 = _mm_add_epi16(xmm2, xmm5);
67  xmm6 = _mm_add_epi16(xmm4, xmm6);
68 
69 
70  xmm1 = _mm_xor_si128(xmm1, xmm1);
71  xmm2 = xmm5;
72  xmm5 = _mm_sub_epi16(xmm6, xmm5);
73  p_src0 += 1;
74  bound_copy -= 1;
75 
76  xmm1 = _mm_cmpgt_epi16(xmm5, xmm1);
77  p_src1 += 1;
78 
79  xmm6 = _mm_and_si128(xmm1, xmm6);
80 
81  xmm1 = _mm_andnot_si128(xmm1, xmm2);
82  p_src2 += 1;
83 
84 
85 
86  xmm1 = _mm_add_epi16(xmm6, xmm1);
87  p_src3 += 1;
88 
89 
90  _mm_store_si128(p_target, xmm1);
91  p_target += 1;
92 
93  }
94 
95 
96  /*asm volatile
97  (
98  "volk_16i_x4_quad_max_star_16i_a_sse2_L1:\n\t"
99  "cmp $0, %[bound]\n\t"
100  "je volk_16i_x4_quad_max_star_16i_a_sse2_END\n\t"
101 
102  "movaps (%[src0]), %%xmm1\n\t"
103  "movaps (%[src1]), %%xmm2\n\t"
104  "movaps (%[src2]), %%xmm3\n\t"
105  "movaps (%[src3]), %%xmm4\n\t"
106 
107  "pxor %%xmm5, %%xmm5\n\t"
108  "pxor %%xmm6, %%xmm6\n\t"
109  "movaps %%xmm1, %%xmm7\n\t"
110  "movaps %%xmm3, %%xmm8\n\t"
111  "psubw %%xmm2, %%xmm1\n\t"
112  "psubw %%xmm4, %%xmm3\n\t"
113 
114  "pcmpgtw %%xmm1, %%xmm5\n\t"
115  "pcmpgtw %%xmm3, %%xmm6\n\t"
116 
117  "pand %%xmm5, %%xmm2\n\t"
118  "pand %%xmm6, %%xmm4\n\t"
119  "pandn %%xmm7, %%xmm5\n\t"
120  "pandn %%xmm8, %%xmm6\n\t"
121 
122  "paddw %%xmm2, %%xmm5\n\t"
123  "paddw %%xmm4, %%xmm6\n\t"
124 
125  "pxor %%xmm1, %%xmm1\n\t"
126  "movaps %%xmm5, %%xmm2\n\t"
127 
128  "psubw %%xmm6, %%xmm5\n\t"
129  "add $16, %[src0]\n\t"
130  "add $-1, %[bound]\n\t"
131 
132  "pcmpgtw %%xmm5, %%xmm1\n\t"
133  "add $16, %[src1]\n\t"
134 
135  "pand %%xmm1, %%xmm6\n\t"
136 
137  "pandn %%xmm2, %%xmm1\n\t"
138  "add $16, %[src2]\n\t"
139 
140  "paddw %%xmm6, %%xmm1\n\t"
141  "add $16, %[src3]\n\t"
142 
143  "movaps %%xmm1, (%[target])\n\t"
144  "addw $16, %[target]\n\t"
145  "jmp volk_16i_x4_quad_max_star_16i_a_sse2_L1\n\t"
146 
147  "volk_16i_x4_quad_max_star_16i_a_sse2_END:\n\t"
148  :
149  :[bound]"r"(bound), [src0]"r"(src0), [src1]"r"(src1), [src2]"r"(src2), [src3]"r"(src3), [target]"r"(target)
150  :
151  );
152  */
153 
154  short temp0 = 0;
155  short temp1 = 0;
156  for(i = bound * 8; i < (bound * 8) + leftovers; ++i) {
157  temp0 = ((short)(src0[i] - src1[i]) > 0) ? src0[i] : src1[i];
158  temp1 = ((short)(src2[i] - src3[i])>0) ? src2[i] : src3[i];
159  target[i] = ((short)(temp0 - temp1)>0) ? temp0 : temp1;
160  }
161  return;
162 
163 
164 }
165 
166 #endif /*LV_HAVE_SSE2*/
167 
168 
169 #ifdef LV_HAVE_GENERIC
170 static inline void volk_16i_x4_quad_max_star_16i_generic(short* target, short* src0, short* src1, short* src2, short* src3, unsigned int num_points) {
171 
172  const unsigned int num_bytes = num_points*2;
173 
174  int i = 0;
175 
176  int bound = num_bytes >> 1;
177 
178  short temp0 = 0;
179  short temp1 = 0;
180  for(i = 0; i < bound; ++i) {
181  temp0 = ((short)(src0[i] - src1[i]) > 0) ? src0[i] : src1[i];
182  temp1 = ((short)(src2[i] - src3[i])>0) ? src2[i] : src3[i];
183  target[i] = ((short)(temp0 - temp1)>0) ? temp0 : temp1;
184  }
185 }
186 
187 
188 
189 
190 #endif /*LV_HAVE_GENERIC*/
191 
192 #endif /*INCLUDED_volk_16i_x4_quad_max_star_16i_a_H*/