GNU Radio 3.7.2 C++ API
volk_16i_max_star_16i.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_16i_max_star_16i_a_H
2 #define INCLUDED_volk_16i_max_star_16i_a_H
3 
4 
5 #include<inttypes.h>
6 #include<stdio.h>
7 
8 
9 #ifdef LV_HAVE_SSSE3
10 
11 #include<xmmintrin.h>
12 #include<emmintrin.h>
13 #include<tmmintrin.h>
14 
15 static inline void volk_16i_max_star_16i_a_ssse3(short* target, short* src0, unsigned int num_points) {
16 
17  const unsigned int num_bytes = num_points*2;
18 
19  short candidate = src0[0];
20  short cands[8];
21  __m128i xmm0, xmm1, xmm3, xmm4, xmm5, xmm6;
22 
23 
24  __m128i *p_src0;
25 
26  p_src0 = (__m128i*)src0;
27 
28  int bound = num_bytes >> 4;
29  int leftovers = (num_bytes >> 1) & 7;
30 
31  int i = 0;
32 
33 
34  xmm1 = _mm_setzero_si128();
35  xmm0 = _mm_setzero_si128();
36  //_mm_insert_epi16(xmm0, candidate, 0);
37 
38  xmm0 = _mm_shuffle_epi8(xmm0, xmm1);
39 
40 
41  for(i = 0; i < bound; ++i) {
42  xmm1 = _mm_load_si128(p_src0);
43  p_src0 += 1;
44  //xmm2 = _mm_sub_epi16(xmm1, xmm0);
45 
46 
47 
48 
49 
50 
51  xmm3 = _mm_cmpgt_epi16(xmm0, xmm1);
52  xmm4 = _mm_cmpeq_epi16(xmm0, xmm1);
53  xmm5 = _mm_cmpgt_epi16(xmm1, xmm0);
54 
55  xmm6 = _mm_xor_si128(xmm4, xmm5);
56 
57  xmm3 = _mm_and_si128(xmm3, xmm0);
58  xmm4 = _mm_and_si128(xmm6, xmm1);
59 
60  xmm0 = _mm_add_epi16(xmm3, xmm4);
61 
62 
63  }
64 
65  _mm_store_si128((__m128i*)cands, xmm0);
66 
67  for(i = 0; i < 8; ++i) {
68  candidate = ((short)(candidate - cands[i]) > 0) ? candidate : cands[i];
69  }
70 
71 
72 
73  for(i = 0; i < leftovers; ++i) {
74 
75  candidate = ((short)(candidate - src0[(bound << 3) + i]) > 0) ? candidate : src0[(bound << 3) + i];
76  }
77 
78  target[0] = candidate;
79 
80 
81 
82 
83 
84 }
85 
86 #endif /*LV_HAVE_SSSE3*/
87 
88 #ifdef LV_HAVE_GENERIC
89 
90 static inline void volk_16i_max_star_16i_generic(short* target, short* src0, unsigned int num_points) {
91 
92  const unsigned int num_bytes = num_points*2;
93 
94  int i = 0;
95 
96  int bound = num_bytes >> 1;
97 
98  short candidate = src0[0];
99  for(i = 1; i < bound; ++i) {
100  candidate = ((short)(candidate - src0[i]) > 0) ? candidate : src0[i];
101  }
102  target[0] = candidate;
103 
104 }
105 
106 
107 #endif /*LV_HAVE_GENERIC*/
108 
109 
110 #endif /*INCLUDED_volk_16i_max_star_16i_a_H*/