GNU Radio Manual and C++ API Reference  3.7.4
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
volk_16i_x5_add_quad_16i_x4.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_16i_x5_add_quad_16i_x4_a_H
2 #define INCLUDED_volk_16i_x5_add_quad_16i_x4_a_H
3 
4 
5 #include<inttypes.h>
6 #include<stdio.h>
7 
8 
9 
10 
11 
12 #ifdef LV_HAVE_SSE2
13 #include<xmmintrin.h>
14 #include<emmintrin.h>
15 
16 static inline void volk_16i_x5_add_quad_16i_x4_a_sse2(short* target0, short* target1, short* target2, short* target3, short* src0, short* src1, short* src2, short* src3, short* src4, unsigned int num_points) {
17 
18  const unsigned int num_bytes = num_points*2;
19 
20  __m128i xmm0, xmm1, xmm2, xmm3, xmm4;
21  __m128i *p_target0, *p_target1, *p_target2, *p_target3, *p_src0, *p_src1, *p_src2, *p_src3, *p_src4;
22  p_target0 = (__m128i*)target0;
23  p_target1 = (__m128i*)target1;
24  p_target2 = (__m128i*)target2;
25  p_target3 = (__m128i*)target3;
26 
27  p_src0 = (__m128i*)src0;
28  p_src1 = (__m128i*)src1;
29  p_src2 = (__m128i*)src2;
30  p_src3 = (__m128i*)src3;
31  p_src4 = (__m128i*)src4;
32 
33  int i = 0;
34 
35  int bound = (num_bytes >> 4);
36  int leftovers = (num_bytes >> 1) & 7;
37 
38  for(; i < bound; ++i) {
39  xmm0 = _mm_load_si128(p_src0);
40  xmm1 = _mm_load_si128(p_src1);
41  xmm2 = _mm_load_si128(p_src2);
42  xmm3 = _mm_load_si128(p_src3);
43  xmm4 = _mm_load_si128(p_src4);
44 
45  p_src0 += 1;
46  p_src1 += 1;
47 
48  xmm1 = _mm_add_epi16(xmm0, xmm1);
49  xmm2 = _mm_add_epi16(xmm0, xmm2);
50  xmm3 = _mm_add_epi16(xmm0, xmm3);
51  xmm4 = _mm_add_epi16(xmm0, xmm4);
52 
53 
54  p_src2 += 1;
55  p_src3 += 1;
56  p_src4 += 1;
57 
58  _mm_store_si128(p_target0, xmm1);
59  _mm_store_si128(p_target1, xmm2);
60  _mm_store_si128(p_target2, xmm3);
61  _mm_store_si128(p_target3, xmm4);
62 
63  p_target0 += 1;
64  p_target1 += 1;
65  p_target2 += 1;
66  p_target3 += 1;
67  }
68  /*asm volatile
69  (
70  ".%=volk_16i_x5_add_quad_16i_x4_a_sse2_L1:\n\t"
71  "cmp $0, %[bound]\n\t"
72  "je .%=volk_16i_x5_add_quad_16i_x4_a_sse2_END\n\t"
73  "movaps (%[src0]), %%xmm1\n\t"
74  "movaps (%[src1]), %%xmm2\n\t"
75  "movaps (%[src2]), %%xmm3\n\t"
76  "movaps (%[src3]), %%xmm4\n\t"
77  "movaps (%[src4]), %%xmm5\n\t"
78  "add $16, %[src0]\n\t"
79  "add $16, %[src1]\n\t"
80  "add $16, %[src2]\n\t"
81  "add $16, %[src3]\n\t"
82  "add $16, %[src4]\n\t"
83  "paddw %%xmm1, %%xmm2\n\t"
84  "paddw %%xmm1, %%xmm3\n\t"
85  "paddw %%xmm1, %%xmm4\n\t"
86  "paddw %%xmm1, %%xmm5\n\t"
87  "add $-1, %[bound]\n\t"
88  "movaps %%xmm2, (%[target0])\n\t"
89  "movaps %%xmm3, (%[target1])\n\t"
90  "movaps %%xmm4, (%[target2])\n\t"
91  "movaps %%xmm5, (%[target3])\n\t"
92  "add $16, %[target0]\n\t"
93  "add $16, %[target1]\n\t"
94  "add $16, %[target2]\n\t"
95  "add $16, %[target3]\n\t"
96  "jmp .%=volk_16i_x5_add_quad_16i_x4_a_sse2_L1\n\t"
97  ".%=volk_16i_x5_add_quad_16i_x4_a_sse2_END:\n\t"
98  :
99  :[bound]"r"(bound), [src0]"r"(src0), [src1]"r"(src1), [src2]"r"(src2), [src3]"r"(src3), [src4]"r"(src4), [target0]"r"(target0), [target1]"r"(target1), [target2]"r"(target2), [target3]"r"(target3)
100  :"xmm1", "xmm2", "xmm3", "xmm4", "xmm5"
101  );
102 
103  */
104 
105 
106  for(i = bound * 8; i < (bound * 8) + leftovers; ++i) {
107  target0[i] = src0[i] + src1[i];
108  target1[i] = src0[i] + src2[i];
109  target2[i] = src0[i] + src3[i];
110  target3[i] = src0[i] + src4[i];
111  }
112 }
113 #endif /*LV_HAVE_SSE2*/
114 
115 
116 #ifdef LV_HAVE_GENERIC
117 
118 static inline void volk_16i_x5_add_quad_16i_x4_generic(short* target0, short* target1, short* target2, short* target3, short* src0, short* src1, short* src2, short* src3, short* src4, unsigned int num_points) {
119 
120  const unsigned int num_bytes = num_points*2;
121 
122  int i = 0;
123 
124  int bound = num_bytes >> 1;
125 
126  for(i = 0; i < bound; ++i) {
127  target0[i] = src0[i] + src1[i];
128  target1[i] = src0[i] + src2[i];
129  target2[i] = src0[i] + src3[i];
130  target3[i] = src0[i] + src4[i];
131  }
132 }
133 
134 #endif /* LV_HAVE_GENERIC */
135 
136 
137 
138 
139 
140 #endif /*INCLUDED_volk_16i_x5_add_quad_16i_x4_a_H*/