59 #ifndef INCLUDED_volk_16i_permute_and_scalar_add_a_H 60 #define INCLUDED_volk_16i_permute_and_scalar_add_a_H 67 #include <emmintrin.h> 68 #include <xmmintrin.h> 72 short* permute_indexes,
78 unsigned int num_points)
81 const unsigned int num_bytes = num_points * 2;
83 __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
85 __m128i *p_target, *p_cntl0, *p_cntl1, *p_cntl2, *p_cntl3, *p_scalars;
87 short* p_permute_indexes = permute_indexes;
89 p_target = (__m128i*)target;
90 p_cntl0 = (__m128i*)cntl0;
91 p_cntl1 = (__m128i*)cntl1;
92 p_cntl2 = (__m128i*)cntl2;
93 p_cntl3 = (__m128i*)cntl3;
94 p_scalars = (__m128i*)scalars;
98 int bound = (num_bytes >> 4);
99 int leftovers = (num_bytes >> 1) & 7;
101 xmm0 = _mm_load_si128(p_scalars);
103 xmm1 = _mm_shufflelo_epi16(xmm0, 0);
104 xmm2 = _mm_shufflelo_epi16(xmm0, 0x55);
105 xmm3 = _mm_shufflelo_epi16(xmm0, 0xaa);
106 xmm4 = _mm_shufflelo_epi16(xmm0, 0xff);
108 xmm1 = _mm_shuffle_epi32(xmm1, 0x00);
109 xmm2 = _mm_shuffle_epi32(xmm2, 0x00);
110 xmm3 = _mm_shuffle_epi32(xmm3, 0x00);
111 xmm4 = _mm_shuffle_epi32(xmm4, 0x00);
114 for (;
i < bound; ++
i) {
115 xmm0 = _mm_setzero_si128();
116 xmm5 = _mm_setzero_si128();
117 xmm6 = _mm_setzero_si128();
118 xmm7 = _mm_setzero_si128();
120 xmm0 = _mm_insert_epi16(xmm0, src0[p_permute_indexes[0]], 0);
121 xmm5 = _mm_insert_epi16(xmm5, src0[p_permute_indexes[1]], 1);
122 xmm6 = _mm_insert_epi16(xmm6, src0[p_permute_indexes[2]], 2);
123 xmm7 = _mm_insert_epi16(xmm7, src0[p_permute_indexes[3]], 3);
124 xmm0 = _mm_insert_epi16(xmm0, src0[p_permute_indexes[4]], 4);
125 xmm5 = _mm_insert_epi16(xmm5, src0[p_permute_indexes[5]], 5);
126 xmm6 = _mm_insert_epi16(xmm6, src0[p_permute_indexes[6]], 6);
127 xmm7 = _mm_insert_epi16(xmm7, src0[p_permute_indexes[7]], 7);
129 xmm0 = _mm_add_epi16(xmm0, xmm5);
130 xmm6 = _mm_add_epi16(xmm6, xmm7);
132 p_permute_indexes += 8;
134 xmm0 = _mm_add_epi16(xmm0, xmm6);
136 xmm5 = _mm_load_si128(p_cntl0);
137 xmm6 = _mm_load_si128(p_cntl1);
138 xmm7 = _mm_load_si128(p_cntl2);
140 xmm5 = _mm_and_si128(xmm5, xmm1);
141 xmm6 = _mm_and_si128(xmm6, xmm2);
142 xmm7 = _mm_and_si128(xmm7, xmm3);
144 xmm0 = _mm_add_epi16(xmm0, xmm5);
146 xmm5 = _mm_load_si128(p_cntl3);
148 xmm6 = _mm_add_epi16(xmm6, xmm7);
152 xmm5 = _mm_and_si128(xmm5, xmm4);
154 xmm0 = _mm_add_epi16(xmm0, xmm6);
159 xmm0 = _mm_add_epi16(xmm0, xmm5);
163 _mm_store_si128(p_target, xmm0);
168 for (
i = bound * 8;
i < (bound * 8) + leftovers; ++
i) {
169 target[
i] = src0[permute_indexes[
i]] + (cntl0[
i] & scalars[0]) +
170 (cntl1[
i] & scalars[1]) + (cntl2[
i] & scalars[2]) +
171 (cntl3[
i] & scalars[3]);
177 #ifdef LV_HAVE_GENERIC 180 short* permute_indexes,
186 unsigned int num_points)
188 const unsigned int num_bytes = num_points * 2;
192 int bound = num_bytes >> 1;
194 for (
i = 0;
i < bound; ++
i) {
195 target[
i] = src0[permute_indexes[
i]] + (cntl0[
i] & scalars[0]) +
196 (cntl1[
i] & scalars[1]) + (cntl2[
i] & scalars[2]) +
197 (cntl3[
i] & scalars[3]);
static void volk_16i_permute_and_scalar_add_generic(short *target, short *src0, short *permute_indexes, short *cntl0, short *cntl1, short *cntl2, short *cntl3, short *scalars, unsigned int num_points)
Definition: volk_16i_permute_and_scalar_add.h:178
static void volk_16i_permute_and_scalar_add_a_sse2(short *target, short *src0, short *permute_indexes, short *cntl0, short *cntl1, short *cntl2, short *cntl3, short *scalars, unsigned int num_points)
Definition: volk_16i_permute_and_scalar_add.h:70
for i
Definition: volk_config_fixed.tmpl.h:25