Vector Optimized Library of Kernels  2.0
Architecture-tuned implementations of math kernels
volk_16i_branch_4_state_8.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012, 2014 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
56 #ifndef INCLUDED_volk_16i_branch_4_state_8_a_H
57 #define INCLUDED_volk_16i_branch_4_state_8_a_H
58 
59 #include <inttypes.h>
60 #include <stdio.h>
61 
62 #ifdef LV_HAVE_SSSE3
63 
64 #include <xmmintrin.h>
65 #include <emmintrin.h>
66 #include <tmmintrin.h>
67 
68 static inline void
69 volk_16i_branch_4_state_8_a_ssse3(short* target, short* src0, char** permuters, short* cntl2, short* cntl3, short* scalars)
70 {
71  __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9, xmm10, xmm11;
72  __m128i *p_target, *p_src0, *p_cntl2, *p_cntl3, *p_scalars;
73 
74  p_target = (__m128i*)target;
75  p_src0 = (__m128i*)src0;
76  p_cntl2 = (__m128i*)cntl2;
77  p_cntl3 = (__m128i*)cntl3;
78  p_scalars = (__m128i*)scalars;
79 
80  int i = 0;
81 
82  int bound = 1;
83 
84  xmm0 = _mm_load_si128(p_scalars);
85 
86  xmm1 = _mm_shufflelo_epi16(xmm0, 0);
87  xmm2 = _mm_shufflelo_epi16(xmm0, 0x55);
88  xmm3 = _mm_shufflelo_epi16(xmm0, 0xaa);
89  xmm4 = _mm_shufflelo_epi16(xmm0, 0xff);
90 
91  xmm1 = _mm_shuffle_epi32(xmm1, 0x00);
92  xmm2 = _mm_shuffle_epi32(xmm2, 0x00);
93  xmm3 = _mm_shuffle_epi32(xmm3, 0x00);
94  xmm4 = _mm_shuffle_epi32(xmm4, 0x00);
95 
96  xmm0 = _mm_load_si128((__m128i*)permuters[0]);
97  xmm6 = _mm_load_si128((__m128i*)permuters[1]);
98  xmm8 = _mm_load_si128((__m128i*)permuters[2]);
99  xmm10 = _mm_load_si128((__m128i*)permuters[3]);
100 
101  for(; i < bound; ++i) {
102  xmm5 = _mm_load_si128(p_src0);
103  xmm0 = _mm_shuffle_epi8(xmm5, xmm0);
104  xmm6 = _mm_shuffle_epi8(xmm5, xmm6);
105  xmm8 = _mm_shuffle_epi8(xmm5, xmm8);
106  xmm10 = _mm_shuffle_epi8(xmm5, xmm10);
107 
108  p_src0 += 4;
109 
110  xmm5 = _mm_add_epi16(xmm1, xmm2);
111 
112  xmm6 = _mm_add_epi16(xmm2, xmm6);
113  xmm8 = _mm_add_epi16(xmm1, xmm8);
114 
115  xmm7 = _mm_load_si128(p_cntl2);
116  xmm9 = _mm_load_si128(p_cntl3);
117 
118  xmm0 = _mm_add_epi16(xmm5, xmm0);
119 
120  xmm7 = _mm_and_si128(xmm7, xmm3);
121  xmm9 = _mm_and_si128(xmm9, xmm4);
122 
123  xmm5 = _mm_load_si128(&p_cntl2[1]);
124  xmm11 = _mm_load_si128(&p_cntl3[1]);
125 
126  xmm7 = _mm_add_epi16(xmm7, xmm9);
127 
128  xmm5 = _mm_and_si128(xmm5, xmm3);
129  xmm11 = _mm_and_si128(xmm11, xmm4);
130 
131  xmm0 = _mm_add_epi16(xmm0, xmm7);
132 
133 
134  xmm7 = _mm_load_si128(&p_cntl2[2]);
135  xmm9 = _mm_load_si128(&p_cntl3[2]);
136 
137  xmm5 = _mm_add_epi16(xmm5, xmm11);
138 
139  xmm7 = _mm_and_si128(xmm7, xmm3);
140  xmm9 = _mm_and_si128(xmm9, xmm4);
141 
142  xmm6 = _mm_add_epi16(xmm6, xmm5);
143 
144 
145  xmm5 = _mm_load_si128(&p_cntl2[3]);
146  xmm11 = _mm_load_si128(&p_cntl3[3]);
147 
148  xmm7 = _mm_add_epi16(xmm7, xmm9);
149 
150  xmm5 = _mm_and_si128(xmm5, xmm3);
151  xmm11 = _mm_and_si128(xmm11, xmm4);
152 
153  xmm8 = _mm_add_epi16(xmm8, xmm7);
154 
155  xmm5 = _mm_add_epi16(xmm5, xmm11);
156 
157  _mm_store_si128(p_target, xmm0);
158  _mm_store_si128(&p_target[1], xmm6);
159 
160  xmm10 = _mm_add_epi16(xmm5, xmm10);
161 
162  _mm_store_si128(&p_target[2], xmm8);
163 
164  _mm_store_si128(&p_target[3], xmm10);
165 
166  p_target += 3;
167  }
168 }
169 
170 
171 #endif /*LV_HAVE_SSEs*/
172 
173 #ifdef LV_HAVE_GENERIC
174 static inline void
175 volk_16i_branch_4_state_8_generic(short* target, short* src0, char** permuters, short* cntl2, short* cntl3, short* scalars)
176 {
177  int i = 0;
178 
179  int bound = 4;
180 
181  for(; i < bound; ++i) {
182  target[i* 8] = src0[((char)permuters[i][0])/2]
183  + ((i + 1)%2 * scalars[0])
184  + (((i >> 1)^1) * scalars[1])
185  + (cntl2[i * 8] & scalars[2])
186  + (cntl3[i * 8] & scalars[3]);
187  target[i* 8 + 1] = src0[((char)permuters[i][1 * 2])/2]
188  + ((i + 1)%2 * scalars[0])
189  + (((i >> 1)^1) * scalars[1])
190  + (cntl2[i * 8 + 1] & scalars[2])
191  + (cntl3[i * 8 + 1] & scalars[3]);
192  target[i* 8 + 2] = src0[((char)permuters[i][2 * 2])/2]
193  + ((i + 1)%2 * scalars[0])
194  + (((i >> 1)^1) * scalars[1])
195  + (cntl2[i * 8 + 2] & scalars[2])
196  + (cntl3[i * 8 + 2] & scalars[3]);
197  target[i* 8 + 3] = src0[((char)permuters[i][3 * 2])/2]
198  + ((i + 1)%2 * scalars[0])
199  + (((i >> 1)^1) * scalars[1])
200  + (cntl2[i * 8 + 3] & scalars[2])
201  + (cntl3[i * 8 + 3] & scalars[3]);
202  target[i* 8 + 4] = src0[((char)permuters[i][4 * 2])/2]
203  + ((i + 1)%2 * scalars[0])
204  + (((i >> 1)^1) * scalars[1])
205  + (cntl2[i * 8 + 4] & scalars[2])
206  + (cntl3[i * 8 + 4] & scalars[3]);
207  target[i* 8 + 5] = src0[((char)permuters[i][5 * 2])/2]
208  + ((i + 1)%2 * scalars[0])
209  + (((i >> 1)^1) * scalars[1])
210  + (cntl2[i * 8 + 5] & scalars[2])
211  + (cntl3[i * 8 + 5] & scalars[3]);
212  target[i* 8 + 6] = src0[((char)permuters[i][6 * 2])/2]
213  + ((i + 1)%2 * scalars[0])
214  + (((i >> 1)^1) * scalars[1])
215  + (cntl2[i * 8 + 6] & scalars[2])
216  + (cntl3[i * 8 + 6] & scalars[3]);
217  target[i* 8 + 7] = src0[((char)permuters[i][7 * 2])/2]
218  + ((i + 1)%2 * scalars[0])
219  + (((i >> 1)^1) * scalars[1])
220  + (cntl2[i * 8 + 7] & scalars[2])
221  + (cntl3[i * 8 + 7] & scalars[3]);
222  }
223 }
224 
225 #endif /*LV_HAVE_GENERIC*/
226 
227 
228 #endif /*INCLUDED_volk_16i_branch_4_state_8_a_H*/
static void volk_16i_branch_4_state_8_a_ssse3(short *target, short *src0, char **permuters, short *cntl2, short *cntl3, short *scalars)
Definition: volk_16i_branch_4_state_8.h:69
static void volk_16i_branch_4_state_8_generic(short *target, short *src0, char **permuters, short *cntl2, short *cntl3, short *scalars)
Definition: volk_16i_branch_4_state_8.h:175
for i
Definition: volk_config_fixed.tmpl.h:25