Vector Optimized Library of Kernels  2.2
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  xmm0 = _mm_load_si128(p_scalars);
81 
82  xmm1 = _mm_shufflelo_epi16(xmm0, 0);
83  xmm2 = _mm_shufflelo_epi16(xmm0, 0x55);
84  xmm3 = _mm_shufflelo_epi16(xmm0, 0xaa);
85  xmm4 = _mm_shufflelo_epi16(xmm0, 0xff);
86 
87  xmm1 = _mm_shuffle_epi32(xmm1, 0x00);
88  xmm2 = _mm_shuffle_epi32(xmm2, 0x00);
89  xmm3 = _mm_shuffle_epi32(xmm3, 0x00);
90  xmm4 = _mm_shuffle_epi32(xmm4, 0x00);
91 
92  xmm0 = _mm_load_si128((__m128i*)permuters[0]);
93  xmm6 = _mm_load_si128((__m128i*)permuters[1]);
94  xmm8 = _mm_load_si128((__m128i*)permuters[2]);
95  xmm10 = _mm_load_si128((__m128i*)permuters[3]);
96 
97  xmm5 = _mm_load_si128(p_src0);
98  xmm0 = _mm_shuffle_epi8(xmm5, xmm0);
99  xmm6 = _mm_shuffle_epi8(xmm5, xmm6);
100  xmm8 = _mm_shuffle_epi8(xmm5, xmm8);
101  xmm10 = _mm_shuffle_epi8(xmm5, xmm10);
102 
103  xmm5 = _mm_add_epi16(xmm1, xmm2);
104 
105  xmm6 = _mm_add_epi16(xmm2, xmm6);
106  xmm8 = _mm_add_epi16(xmm1, xmm8);
107 
108  xmm7 = _mm_load_si128(p_cntl2);
109  xmm9 = _mm_load_si128(p_cntl3);
110 
111  xmm0 = _mm_add_epi16(xmm5, xmm0);
112 
113  xmm7 = _mm_and_si128(xmm7, xmm3);
114  xmm9 = _mm_and_si128(xmm9, xmm4);
115 
116  xmm5 = _mm_load_si128(&p_cntl2[1]);
117  xmm11 = _mm_load_si128(&p_cntl3[1]);
118 
119  xmm7 = _mm_add_epi16(xmm7, xmm9);
120 
121  xmm5 = _mm_and_si128(xmm5, xmm3);
122  xmm11 = _mm_and_si128(xmm11, xmm4);
123 
124  xmm0 = _mm_add_epi16(xmm0, xmm7);
125 
126 
127  xmm7 = _mm_load_si128(&p_cntl2[2]);
128  xmm9 = _mm_load_si128(&p_cntl3[2]);
129 
130  xmm5 = _mm_add_epi16(xmm5, xmm11);
131 
132  xmm7 = _mm_and_si128(xmm7, xmm3);
133  xmm9 = _mm_and_si128(xmm9, xmm4);
134 
135  xmm6 = _mm_add_epi16(xmm6, xmm5);
136 
137 
138  xmm5 = _mm_load_si128(&p_cntl2[3]);
139  xmm11 = _mm_load_si128(&p_cntl3[3]);
140 
141  xmm7 = _mm_add_epi16(xmm7, xmm9);
142 
143  xmm5 = _mm_and_si128(xmm5, xmm3);
144  xmm11 = _mm_and_si128(xmm11, xmm4);
145 
146  xmm8 = _mm_add_epi16(xmm8, xmm7);
147 
148  xmm5 = _mm_add_epi16(xmm5, xmm11);
149 
150  _mm_store_si128(p_target, xmm0);
151  _mm_store_si128(&p_target[1], xmm6);
152 
153  xmm10 = _mm_add_epi16(xmm5, xmm10);
154 
155  _mm_store_si128(&p_target[2], xmm8);
156 
157  _mm_store_si128(&p_target[3], xmm10);
158 }
159 
160 
161 #endif /*LV_HAVE_SSEs*/
162 
163 #ifdef LV_HAVE_GENERIC
164 static inline void
165 volk_16i_branch_4_state_8_generic(short* target, short* src0, char** permuters, short* cntl2, short* cntl3, short* scalars)
166 {
167  int i = 0;
168 
169  int bound = 4;
170 
171  for(; i < bound; ++i) {
172  target[i* 8] = src0[((char)permuters[i][0])/2]
173  + ((i + 1)%2 * scalars[0])
174  + (((i >> 1)^1) * scalars[1])
175  + (cntl2[i * 8] & scalars[2])
176  + (cntl3[i * 8] & scalars[3]);
177  target[i* 8 + 1] = src0[((char)permuters[i][1 * 2])/2]
178  + ((i + 1)%2 * scalars[0])
179  + (((i >> 1)^1) * scalars[1])
180  + (cntl2[i * 8 + 1] & scalars[2])
181  + (cntl3[i * 8 + 1] & scalars[3]);
182  target[i* 8 + 2] = src0[((char)permuters[i][2 * 2])/2]
183  + ((i + 1)%2 * scalars[0])
184  + (((i >> 1)^1) * scalars[1])
185  + (cntl2[i * 8 + 2] & scalars[2])
186  + (cntl3[i * 8 + 2] & scalars[3]);
187  target[i* 8 + 3] = src0[((char)permuters[i][3 * 2])/2]
188  + ((i + 1)%2 * scalars[0])
189  + (((i >> 1)^1) * scalars[1])
190  + (cntl2[i * 8 + 3] & scalars[2])
191  + (cntl3[i * 8 + 3] & scalars[3]);
192  target[i* 8 + 4] = src0[((char)permuters[i][4 * 2])/2]
193  + ((i + 1)%2 * scalars[0])
194  + (((i >> 1)^1) * scalars[1])
195  + (cntl2[i * 8 + 4] & scalars[2])
196  + (cntl3[i * 8 + 4] & scalars[3]);
197  target[i* 8 + 5] = src0[((char)permuters[i][5 * 2])/2]
198  + ((i + 1)%2 * scalars[0])
199  + (((i >> 1)^1) * scalars[1])
200  + (cntl2[i * 8 + 5] & scalars[2])
201  + (cntl3[i * 8 + 5] & scalars[3]);
202  target[i* 8 + 6] = src0[((char)permuters[i][6 * 2])/2]
203  + ((i + 1)%2 * scalars[0])
204  + (((i >> 1)^1) * scalars[1])
205  + (cntl2[i * 8 + 6] & scalars[2])
206  + (cntl3[i * 8 + 6] & scalars[3]);
207  target[i* 8 + 7] = src0[((char)permuters[i][7 * 2])/2]
208  + ((i + 1)%2 * scalars[0])
209  + (((i >> 1)^1) * scalars[1])
210  + (cntl2[i * 8 + 7] & scalars[2])
211  + (cntl3[i * 8 + 7] & scalars[3]);
212  }
213 }
214 
215 #endif /*LV_HAVE_GENERIC*/
216 
217 
218 #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:165
for i
Definition: volk_config_fixed.tmpl.h:25