mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 04:30:33 +00:00
Merge branch 'next' of https://github.com/carlesfernandez/gnss-sdr into next
This commit is contained in:
commit
31d0366d73
@ -233,6 +233,156 @@ static inline void volk_gnsssdr_16ic_x2_dot_prod_16ic_u_sse2(lv_16sc_t* out, con
|
||||
#endif /* LV_HAVE_SSE2 */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_AVX2
|
||||
#include <immintrin.h>
|
||||
|
||||
static inline void volk_gnsssdr_16ic_x2_dot_prod_16ic_u_axv2(lv_16sc_t* out, const lv_16sc_t* in_a, const lv_16sc_t* in_b, unsigned int num_points)
|
||||
{
|
||||
lv_16sc_t dotProduct = lv_cmake((int16_t)0, (int16_t)0);
|
||||
|
||||
const unsigned int avx_iters = num_points / 8;
|
||||
|
||||
const lv_16sc_t* _in_a = in_a;
|
||||
const lv_16sc_t* _in_b = in_b;
|
||||
lv_16sc_t* _out = out;
|
||||
unsigned int i;
|
||||
|
||||
if (avx_iters > 0)
|
||||
{
|
||||
__m256i a, b, c, c_sr, mask_imag, mask_real, real, imag, imag1, imag2, b_sl, a_sl, realcacc, imagcacc, result;
|
||||
__VOLK_ATTR_ALIGNED(32) lv_16sc_t dotProductVector[8];
|
||||
|
||||
realcacc = _mm256_setzero_si256();
|
||||
imagcacc = _mm256_setzero_si256();
|
||||
|
||||
mask_imag = _mm256_set_epi8(255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0);
|
||||
mask_real = _mm256_set_epi8(0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255);
|
||||
|
||||
for(unsigned int number = 0; number < avx_iters; number++)
|
||||
{
|
||||
a = _mm256_loadu_si256((__m256i*)_in_a);
|
||||
__builtin_prefetch(_in_a + 16);
|
||||
b = _mm256_loadu_si256((__m256i*)_in_b);
|
||||
__builtin_prefetch(_in_b + 16);
|
||||
c = _mm256_mullo_epi16(a, b);
|
||||
|
||||
c_sr = _mm256_srli_si256(c, 2); // Shift a right by imm8 bytes while shifting in zeros, and store the results in dst.
|
||||
real = _mm256_subs_epi16(c, c_sr);
|
||||
|
||||
b_sl = _mm256_slli_si256(b, 2);
|
||||
a_sl = _mm256_slli_si256(a, 2);
|
||||
|
||||
imag1 = _mm256_mullo_epi16(a, b_sl);
|
||||
imag2 = _mm256_mullo_epi16(b, a_sl);
|
||||
|
||||
imag = _mm256_adds_epi16(imag1, imag2); //with saturation arithmetic!
|
||||
|
||||
realcacc = _mm256_adds_epi16(realcacc, real);
|
||||
imagcacc = _mm256_adds_epi16(imagcacc, imag);
|
||||
|
||||
_in_a += 8;
|
||||
_in_b += 8;
|
||||
}
|
||||
|
||||
realcacc = _mm256_and_si256(realcacc, mask_real);
|
||||
imagcacc = _mm256_and_si256(imagcacc, mask_imag);
|
||||
|
||||
result = _mm256_or_si256(realcacc, imagcacc);
|
||||
|
||||
_mm256_storeu_si256((__m256i*)dotProductVector, result); // Store the results back into the dot product vector
|
||||
|
||||
for (i = 0; i < 8; ++i)
|
||||
{
|
||||
dotProduct = lv_cmake(sat_adds16i(lv_creal(dotProduct), lv_creal(dotProductVector[i])), sat_adds16i(lv_cimag(dotProduct), lv_cimag(dotProductVector[i])));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < (num_points % 8); ++i)
|
||||
{
|
||||
lv_16sc_t tmp = (*_in_a++) * (*_in_b++);
|
||||
dotProduct = lv_cmake(sat_adds16i(lv_creal(dotProduct), lv_creal(tmp)), sat_adds16i(lv_cimag(dotProduct), lv_cimag(tmp)));
|
||||
}
|
||||
|
||||
*_out = dotProduct;
|
||||
}
|
||||
#endif /* LV_HAVE_AVX2 */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_AVX2
|
||||
#include <immintrin.h>
|
||||
|
||||
static inline void volk_gnsssdr_16ic_x2_dot_prod_16ic_a_axv2(lv_16sc_t* out, const lv_16sc_t* in_a, const lv_16sc_t* in_b, unsigned int num_points)
|
||||
{
|
||||
lv_16sc_t dotProduct = lv_cmake((int16_t)0, (int16_t)0);
|
||||
|
||||
const unsigned int avx_iters = num_points / 8;
|
||||
|
||||
const lv_16sc_t* _in_a = in_a;
|
||||
const lv_16sc_t* _in_b = in_b;
|
||||
lv_16sc_t* _out = out;
|
||||
unsigned int i;
|
||||
|
||||
if (avx_iters > 0)
|
||||
{
|
||||
__m256i a, b, c, c_sr, mask_imag, mask_real, real, imag, imag1, imag2, b_sl, a_sl, realcacc, imagcacc, result;
|
||||
__VOLK_ATTR_ALIGNED(32) lv_16sc_t dotProductVector[8];
|
||||
|
||||
realcacc = _mm256_setzero_si256();
|
||||
imagcacc = _mm256_setzero_si256();
|
||||
|
||||
mask_imag = _mm256_set_epi8(255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0);
|
||||
mask_real = _mm256_set_epi8(0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255);
|
||||
|
||||
for(unsigned int number = 0; number < avx_iters; number++)
|
||||
{
|
||||
a = _mm256_load_si256((__m256i*)_in_a);
|
||||
__builtin_prefetch(_in_a + 16);
|
||||
b = _mm256_load_si256((__m256i*)_in_b);
|
||||
__builtin_prefetch(_in_b + 16);
|
||||
c = _mm256_mullo_epi16(a, b);
|
||||
|
||||
c_sr = _mm256_srli_si256(c, 2); // Shift a right by imm8 bytes while shifting in zeros, and store the results in dst.
|
||||
real = _mm256_subs_epi16(c, c_sr);
|
||||
|
||||
b_sl = _mm256_slli_si256(b, 2);
|
||||
a_sl = _mm256_slli_si256(a, 2);
|
||||
|
||||
imag1 = _mm256_mullo_epi16(a, b_sl);
|
||||
imag2 = _mm256_mullo_epi16(b, a_sl);
|
||||
|
||||
imag = _mm256_adds_epi16(imag1, imag2); //with saturation arithmetic!
|
||||
|
||||
realcacc = _mm256_adds_epi16(realcacc, real);
|
||||
imagcacc = _mm256_adds_epi16(imagcacc, imag);
|
||||
|
||||
_in_a += 8;
|
||||
_in_b += 8;
|
||||
}
|
||||
|
||||
realcacc = _mm256_and_si256(realcacc, mask_real);
|
||||
imagcacc = _mm256_and_si256(imagcacc, mask_imag);
|
||||
|
||||
result = _mm256_or_si256(realcacc, imagcacc);
|
||||
|
||||
_mm256_store_si256((__m256i*)dotProductVector, result); // Store the results back into the dot product vector
|
||||
|
||||
for (i = 0; i < 8; ++i)
|
||||
{
|
||||
dotProduct = lv_cmake(sat_adds16i(lv_creal(dotProduct), lv_creal(dotProductVector[i])), sat_adds16i(lv_cimag(dotProduct), lv_cimag(dotProductVector[i])));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < (num_points % 8); ++i)
|
||||
{
|
||||
lv_16sc_t tmp = (*_in_a++) * (*_in_b++);
|
||||
dotProduct = lv_cmake(sat_adds16i(lv_creal(dotProduct), lv_creal(tmp)), sat_adds16i(lv_cimag(dotProduct), lv_cimag(tmp)));
|
||||
}
|
||||
|
||||
*_out = dotProduct;
|
||||
}
|
||||
#endif /* LV_HAVE_AVX2 */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_NEON
|
||||
#include <arm_neon.h>
|
||||
|
||||
@ -385,8 +535,8 @@ static inline void volk_gnsssdr_16ic_x2_dot_prod_16ic_neon_optvma(lv_16sc_t* out
|
||||
|
||||
// use 2 accumulators to remove inter-instruction data dependencies
|
||||
accumulator1.val[0] = vmla_s16(accumulator1.val[0], a_val.val[0], b_val.val[0]);
|
||||
accumulator1.val[1] = vmla_s16(accumulator1.val[1], a_val.val[0], b_val.val[1]);
|
||||
accumulator2.val[0] = vmls_s16(accumulator2.val[0], a_val.val[1], b_val.val[1]);
|
||||
accumulator1.val[1] = vmla_s16(accumulator1.val[1], a_val.val[0], b_val.val[1]);
|
||||
accumulator2.val[1] = vmla_s16(accumulator2.val[1], a_val.val[1], b_val.val[0]);
|
||||
|
||||
a_ptr += 4;
|
||||
|
@ -292,6 +292,190 @@ static inline void volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_u_sse2(lv_16sc_t* resul
|
||||
#endif /* LV_HAVE_SSE2 */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_AVX2
|
||||
#include <immintrin.h>
|
||||
|
||||
static inline void volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_a_avx2(lv_16sc_t* result, const lv_16sc_t* in_common, const lv_16sc_t** in_a, int num_a_vectors, unsigned int num_points)
|
||||
{
|
||||
lv_16sc_t dotProduct = lv_cmake(0,0);
|
||||
|
||||
const unsigned int sse_iters = num_points / 8;
|
||||
|
||||
const lv_16sc_t** _in_a = in_a;
|
||||
const lv_16sc_t* _in_common = in_common;
|
||||
lv_16sc_t* _out = result;
|
||||
|
||||
if (sse_iters > 0)
|
||||
{
|
||||
__VOLK_ATTR_ALIGNED(32) lv_16sc_t dotProductVector[8];
|
||||
|
||||
__m256i* realcacc = (__m256i*)volk_gnsssdr_malloc(num_a_vectors * sizeof(__m256i), volk_gnsssdr_get_alignment());
|
||||
__m256i* imagcacc = (__m256i*)volk_gnsssdr_malloc(num_a_vectors * sizeof(__m256i), volk_gnsssdr_get_alignment());
|
||||
|
||||
for (int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||
{
|
||||
realcacc[n_vec] = _mm256_setzero_si256();
|
||||
imagcacc[n_vec] = _mm256_setzero_si256();
|
||||
}
|
||||
|
||||
__m256i a, b, c, c_sr, mask_imag, mask_real, real, imag;
|
||||
|
||||
mask_imag = _mm256_set_epi8(255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0);
|
||||
mask_real = _mm256_set_epi8(0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255);
|
||||
|
||||
for(unsigned int number = 0; number < sse_iters; number++)
|
||||
{
|
||||
b = _mm256_load_si256((__m256i*)_in_common);
|
||||
__builtin_prefetch(_in_common + 16);
|
||||
for (int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||
{
|
||||
a = _mm256_load_si256((__m256i*)&(_in_a[n_vec][number*8]));
|
||||
|
||||
c = _mm256_mullo_epi16(a, b);
|
||||
|
||||
c_sr = _mm256_srli_si256(c, 2); // Shift a right by imm8 bytes while shifting in zeros, and store the results in dst.
|
||||
real = _mm256_subs_epi16(c, c_sr);
|
||||
|
||||
c_sr = _mm256_slli_si256(b, 2); // b3.r, b2.i ....
|
||||
c = _mm256_mullo_epi16(a, c_sr); // a3.i*b3.r, ....
|
||||
|
||||
c_sr = _mm256_slli_si256(a, 2); // a3.r, a2.i ....
|
||||
imag = _mm256_mullo_epi16(b, c_sr); // b3.i*a3.r, ....
|
||||
|
||||
imag = _mm256_adds_epi16(c, imag);
|
||||
|
||||
realcacc[n_vec] = _mm256_adds_epi16(realcacc[n_vec], real);
|
||||
imagcacc[n_vec] = _mm256_adds_epi16(imagcacc[n_vec], imag);
|
||||
}
|
||||
_in_common += 8;
|
||||
}
|
||||
|
||||
for (int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||
{
|
||||
realcacc[n_vec] = _mm256_and_si256(realcacc[n_vec], mask_real);
|
||||
imagcacc[n_vec] = _mm256_and_si256(imagcacc[n_vec], mask_imag);
|
||||
|
||||
a = _mm256_or_si256(realcacc[n_vec], imagcacc[n_vec]);
|
||||
|
||||
_mm256_store_si256((__m256i*)dotProductVector, a); // Store the results back into the dot product vector
|
||||
dotProduct = lv_cmake(0,0);
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
dotProduct = lv_cmake(sat_adds16i(lv_creal(dotProduct), lv_creal(dotProductVector[i])),
|
||||
sat_adds16i(lv_cimag(dotProduct), lv_cimag(dotProductVector[i])));
|
||||
}
|
||||
_out[n_vec] = dotProduct;
|
||||
}
|
||||
volk_gnsssdr_free(realcacc);
|
||||
volk_gnsssdr_free(imagcacc);
|
||||
}
|
||||
|
||||
for (int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||
{
|
||||
for(unsigned int n = sse_iters * 8; n < num_points; n++)
|
||||
{
|
||||
lv_16sc_t tmp = in_common[n] * in_a[n_vec][n];
|
||||
|
||||
_out[n_vec] = lv_cmake(sat_adds16i(lv_creal(_out[n_vec]), lv_creal(tmp)),
|
||||
sat_adds16i(lv_cimag(_out[n_vec]), lv_cimag(tmp)));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_AVX2 */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_AVX2
|
||||
#include <immintrin.h>
|
||||
|
||||
static inline void volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_u_avx2(lv_16sc_t* result, const lv_16sc_t* in_common, const lv_16sc_t** in_a, int num_a_vectors, unsigned int num_points)
|
||||
{
|
||||
lv_16sc_t dotProduct = lv_cmake(0,0);
|
||||
|
||||
const unsigned int sse_iters = num_points / 8;
|
||||
|
||||
const lv_16sc_t** _in_a = in_a;
|
||||
const lv_16sc_t* _in_common = in_common;
|
||||
lv_16sc_t* _out = result;
|
||||
|
||||
if (sse_iters > 0)
|
||||
{
|
||||
__VOLK_ATTR_ALIGNED(32) lv_16sc_t dotProductVector[8];
|
||||
|
||||
__m256i* realcacc = (__m256i*)volk_gnsssdr_malloc(num_a_vectors * sizeof(__m256i), volk_gnsssdr_get_alignment());
|
||||
__m256i* imagcacc = (__m256i*)volk_gnsssdr_malloc(num_a_vectors * sizeof(__m256i), volk_gnsssdr_get_alignment());
|
||||
|
||||
for (int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||
{
|
||||
realcacc[n_vec] = _mm256_setzero_si256();
|
||||
imagcacc[n_vec] = _mm256_setzero_si256();
|
||||
}
|
||||
|
||||
__m256i a, b, c, c_sr, mask_imag, mask_real, real, imag;
|
||||
|
||||
mask_imag = _mm256_set_epi8(255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0);
|
||||
mask_real = _mm256_set_epi8(0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255);
|
||||
|
||||
for(unsigned int number = 0; number < sse_iters; number++)
|
||||
{
|
||||
b = _mm256_loadu_si256((__m256i*)_in_common);
|
||||
__builtin_prefetch(_in_common + 16);
|
||||
for (int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||
{
|
||||
a = _mm256_loadu_si256((__m256i*)&(_in_a[n_vec][number*8]));
|
||||
|
||||
c = _mm256_mullo_epi16(a, b);
|
||||
|
||||
c_sr = _mm256_srli_si256(c, 2); // Shift a right by imm8 bytes while shifting in zeros, and store the results in dst.
|
||||
real = _mm256_subs_epi16(c, c_sr);
|
||||
|
||||
c_sr = _mm256_slli_si256(b, 2); // b3.r, b2.i ....
|
||||
c = _mm256_mullo_epi16(a, c_sr); // a3.i*b3.r, ....
|
||||
|
||||
c_sr = _mm256_slli_si256(a, 2); // a3.r, a2.i ....
|
||||
imag = _mm256_mullo_epi16(b, c_sr); // b3.i*a3.r, ....
|
||||
|
||||
imag = _mm256_adds_epi16(c, imag);
|
||||
|
||||
realcacc[n_vec] = _mm256_adds_epi16(realcacc[n_vec], real);
|
||||
imagcacc[n_vec] = _mm256_adds_epi16(imagcacc[n_vec], imag);
|
||||
}
|
||||
_in_common += 8;
|
||||
}
|
||||
|
||||
for (int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||
{
|
||||
realcacc[n_vec] = _mm256_and_si256(realcacc[n_vec], mask_real);
|
||||
imagcacc[n_vec] = _mm256_and_si256(imagcacc[n_vec], mask_imag);
|
||||
|
||||
a = _mm256_or_si256(realcacc[n_vec], imagcacc[n_vec]);
|
||||
|
||||
_mm256_store_si256((__m256i*)dotProductVector, a); // Store the results back into the dot product vector
|
||||
dotProduct = lv_cmake(0,0);
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
dotProduct = lv_cmake(sat_adds16i(lv_creal(dotProduct), lv_creal(dotProductVector[i])),
|
||||
sat_adds16i(lv_cimag(dotProduct), lv_cimag(dotProductVector[i])));
|
||||
}
|
||||
_out[n_vec] = dotProduct;
|
||||
}
|
||||
volk_gnsssdr_free(realcacc);
|
||||
volk_gnsssdr_free(imagcacc);
|
||||
}
|
||||
|
||||
for (int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||
{
|
||||
for(unsigned int n = sse_iters * 8; n < num_points; n++)
|
||||
{
|
||||
lv_16sc_t tmp = in_common[n] * in_a[n_vec][n];
|
||||
|
||||
_out[n_vec] = lv_cmake(sat_adds16i(lv_creal(_out[n_vec]), lv_creal(tmp)),
|
||||
sat_adds16i(lv_cimag(_out[n_vec]), lv_cimag(tmp)));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_AVX2 */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_NEON
|
||||
#include <arm_neon.h>
|
||||
|
||||
|
@ -134,6 +134,54 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_u_sse2(lv_16sc_t* r
|
||||
#endif /* LV_HAVE_SSE2 */
|
||||
|
||||
|
||||
#if LV_HAVE_AVX2
|
||||
|
||||
static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_a_avx2(lv_16sc_t* result, const lv_16sc_t* local_code, const lv_16sc_t* in, unsigned int num_points)
|
||||
{
|
||||
int num_a_vectors = 3;
|
||||
lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment());
|
||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
||||
{
|
||||
in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t)*num_points, volk_gnsssdr_get_alignment());
|
||||
memcpy((lv_16sc_t*)in_a[n], (lv_16sc_t*)in, sizeof(lv_16sc_t)*num_points);
|
||||
}
|
||||
|
||||
volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_a_avx2(result, local_code, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
||||
|
||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
||||
{
|
||||
volk_gnsssdr_free(in_a[n]);
|
||||
}
|
||||
volk_gnsssdr_free(in_a);
|
||||
}
|
||||
|
||||
#endif /* LV_HAVE_AVX2 */
|
||||
|
||||
|
||||
#if LV_HAVE_AVX2
|
||||
|
||||
static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_u_avx2(lv_16sc_t* result, const lv_16sc_t* local_code, const lv_16sc_t* in, unsigned int num_points)
|
||||
{
|
||||
int num_a_vectors = 3;
|
||||
lv_16sc_t** in_a = (lv_16sc_t**)volk_gnsssdr_malloc(sizeof(lv_16sc_t*) * num_a_vectors, volk_gnsssdr_get_alignment());
|
||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
||||
{
|
||||
in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t)*num_points, volk_gnsssdr_get_alignment());
|
||||
memcpy((lv_16sc_t*)in_a[n], (lv_16sc_t*)in, sizeof(lv_16sc_t)*num_points);
|
||||
}
|
||||
|
||||
volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_u_avx2(result, local_code, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
||||
|
||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
||||
{
|
||||
volk_gnsssdr_free(in_a[n]);
|
||||
}
|
||||
volk_gnsssdr_free(in_a);
|
||||
}
|
||||
|
||||
#endif /* LV_HAVE_AVX2 */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_NEON
|
||||
|
||||
static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_neon(lv_16sc_t* result, const lv_16sc_t* local_code, const lv_16sc_t* in, unsigned int num_points)
|
||||
|
@ -181,6 +181,115 @@ static inline void volk_gnsssdr_16ic_x2_multiply_16ic_u_sse2(lv_16sc_t* out, con
|
||||
#endif /* LV_HAVE_SSE2 */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_AVX2
|
||||
#include <immintrin.h>
|
||||
|
||||
static inline void volk_gnsssdr_16ic_x2_multiply_16ic_u_avx2(lv_16sc_t* out, const lv_16sc_t* in_a, const lv_16sc_t* in_b, unsigned int num_points)
|
||||
{
|
||||
unsigned int number = 0;
|
||||
const unsigned int avx2_points = num_points / 8;
|
||||
|
||||
const lv_16sc_t* _in_a = in_a;
|
||||
const lv_16sc_t* _in_b = in_b;
|
||||
lv_16sc_t* _out = out;
|
||||
|
||||
__m256i a, b, c, c_sr, real, imag, imag1, imag2, b_sl, a_sl, result;
|
||||
|
||||
const __m256i mask_imag = _mm256_set_epi8(255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0);
|
||||
const __m256i mask_real = _mm256_set_epi8(0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255);
|
||||
|
||||
for(;number < avx2_points; number++)
|
||||
{
|
||||
a = _mm256_loadu_si256((__m256i*)_in_a); // Load the ar + ai, br + bi as ar,ai,br,bi
|
||||
b = _mm256_loadu_si256((__m256i*)_in_b); // Load the cr + ci, dr + di as cr,ci,dr,di
|
||||
c = _mm256_mullo_epi16(a, b);
|
||||
|
||||
c_sr = _mm256_srli_si256(c, 2); // Shift a right by imm8 bytes while shifting in zeros, and store the results in dst.
|
||||
real = _mm256_subs_epi16(c, c_sr);
|
||||
real = _mm256_and_si256(real, mask_real); // a3.r*b3.r-a3.i*b3.i , 0, a3.r*b3.r- a3.i*b3.i
|
||||
|
||||
b_sl = _mm256_slli_si256(b, 2); // b3.r, b2.i ....
|
||||
a_sl = _mm256_slli_si256(a, 2); // a3.r, a2.i ....
|
||||
|
||||
imag1 = _mm256_mullo_epi16(a, b_sl); // a3.i*b3.r, ....
|
||||
imag2 = _mm256_mullo_epi16(b, a_sl); // b3.i*a3.r, ....
|
||||
|
||||
imag = _mm256_adds_epi16(imag1, imag2);
|
||||
imag = _mm256_and_si256(imag, mask_imag); // a3.i*b3.r+b3.i*a3.r, 0, ...
|
||||
|
||||
result = _mm256_or_si256(real, imag);
|
||||
|
||||
_mm256_storeu_si256((__m256i*)_out, result);
|
||||
|
||||
_in_a += 8;
|
||||
_in_b += 8;
|
||||
_out += 8;
|
||||
}
|
||||
|
||||
number = avx2_points * 8;
|
||||
for(;number < num_points; number++)
|
||||
{
|
||||
*_out++ = (*_in_a++) * (*_in_b++);
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_AVX2 */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_AVX2
|
||||
#include <immintrin.h>
|
||||
|
||||
static inline void volk_gnsssdr_16ic_x2_multiply_16ic_a_avx2(lv_16sc_t* out, const lv_16sc_t* in_a, const lv_16sc_t* in_b, unsigned int num_points)
|
||||
{
|
||||
unsigned int number = 0;
|
||||
const unsigned int avx2_points = num_points / 8;
|
||||
|
||||
const lv_16sc_t* _in_a = in_a;
|
||||
const lv_16sc_t* _in_b = in_b;
|
||||
lv_16sc_t* _out = out;
|
||||
|
||||
__m256i a, b, c, c_sr, real, imag, imag1, imag2, b_sl, a_sl, result;
|
||||
|
||||
const __m256i mask_imag = _mm256_set_epi8(255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0);
|
||||
const __m256i mask_real = _mm256_set_epi8(0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255);
|
||||
|
||||
for(;number < avx2_points; number++)
|
||||
{
|
||||
a = _mm256_load_si256((__m256i*)_in_a); // Load the ar + ai, br + bi as ar,ai,br,bi
|
||||
b = _mm256_load_si256((__m256i*)_in_b); // Load the cr + ci, dr + di as cr,ci,dr,di
|
||||
c = _mm256_mullo_epi16(a, b);
|
||||
|
||||
c_sr = _mm256_srli_si256(c, 2); // Shift a right by imm8 bytes while shifting in zeros, and store the results in dst.
|
||||
real = _mm256_subs_epi16(c, c_sr);
|
||||
real = _mm256_and_si256(real, mask_real); // a3.r*b3.r-a3.i*b3.i , 0, a3.r*b3.r- a3.i*b3.i
|
||||
|
||||
b_sl = _mm256_slli_si256(b, 2); // b3.r, b2.i ....
|
||||
a_sl = _mm256_slli_si256(a, 2); // a3.r, a2.i ....
|
||||
|
||||
imag1 = _mm256_mullo_epi16(a, b_sl); // a3.i*b3.r, ....
|
||||
imag2 = _mm256_mullo_epi16(b, a_sl); // b3.i*a3.r, ....
|
||||
|
||||
imag = _mm256_adds_epi16(imag1, imag2);
|
||||
imag = _mm256_and_si256(imag, mask_imag); // a3.i*b3.r+b3.i*a3.r, 0, ...
|
||||
|
||||
result = _mm256_or_si256(real, imag);
|
||||
|
||||
_mm256_store_si256((__m256i*)_out, result);
|
||||
|
||||
_in_a += 8;
|
||||
_in_b += 8;
|
||||
_out += 8;
|
||||
}
|
||||
|
||||
number = avx2_points * 8;
|
||||
for(;number < num_points; number++)
|
||||
{
|
||||
*_out++ = (*_in_a++) * (*_in_b++);
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_AVX2 */
|
||||
|
||||
|
||||
|
||||
#ifdef LV_HAVE_NEON
|
||||
#include <arm_neon.h>
|
||||
|
||||
|
@ -69,20 +69,22 @@ static inline void volk_gnsssdr_32fc_convert_16ic_u_sse2(lv_16sc_t* outputVector
|
||||
|
||||
float* inputVectorPtr = (float*)inputVector;
|
||||
int16_t* outputVectorPtr = (int16_t*)outputVector;
|
||||
float aux;
|
||||
|
||||
float min_val = SHRT_MIN;
|
||||
float max_val = SHRT_MAX;
|
||||
const float min_val = (float)SHRT_MIN;
|
||||
const float max_val = (float)SHRT_MAX;
|
||||
|
||||
__m128 inputVal1, inputVal2;
|
||||
__m128i intInputVal1, intInputVal2;
|
||||
__m128 ret1, ret2;
|
||||
__m128 vmin_val = _mm_set_ps1(min_val);
|
||||
__m128 vmax_val = _mm_set_ps1(max_val);
|
||||
const __m128 vmin_val = _mm_set_ps1(min_val);
|
||||
const __m128 vmax_val = _mm_set_ps1(max_val);
|
||||
|
||||
for(unsigned int i = 0; i < sse_iters; i++)
|
||||
{
|
||||
inputVal1 = _mm_loadu_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
inputVal2 = _mm_loadu_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
__builtin_prefetch(inputVectorPtr + 8);
|
||||
|
||||
// Clip
|
||||
ret1 = _mm_max_ps(_mm_min_ps(inputVal1, vmax_val), vmin_val);
|
||||
@ -99,11 +101,12 @@ static inline void volk_gnsssdr_32fc_convert_16ic_u_sse2(lv_16sc_t* outputVector
|
||||
|
||||
for(unsigned int i = sse_iters * 8; i < num_points * 2; i++)
|
||||
{
|
||||
if(inputVectorPtr[i] > max_val)
|
||||
inputVectorPtr[i] = max_val;
|
||||
else if(inputVectorPtr[i] < min_val)
|
||||
inputVectorPtr[i] = min_val;
|
||||
*outputVectorPtr++ = (int16_t)rintf(*inputVectorPtr++);
|
||||
aux = *inputVectorPtr++;
|
||||
if(aux > max_val)
|
||||
aux = max_val;
|
||||
else if(aux < min_val)
|
||||
aux = min_val;
|
||||
*outputVectorPtr++ = (int16_t)rintf(aux);
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_SSE2 */
|
||||
@ -118,20 +121,22 @@ static inline void volk_gnsssdr_32fc_convert_16ic_u_sse(lv_16sc_t* outputVector,
|
||||
|
||||
float* inputVectorPtr = (float*)inputVector;
|
||||
int16_t* outputVectorPtr = (int16_t*)outputVector;
|
||||
float aux;
|
||||
|
||||
float min_val = SHRT_MIN;
|
||||
float max_val = SHRT_MAX;
|
||||
const float min_val = (float)SHRT_MIN;
|
||||
const float max_val = (float)SHRT_MAX;
|
||||
|
||||
__m128 inputVal1, inputVal2;
|
||||
__m128i intInputVal1, intInputVal2; // is __m128i defined in xmmintrin.h?
|
||||
__m128 ret1, ret2;
|
||||
__m128 vmin_val = _mm_set_ps1(min_val);
|
||||
__m128 vmax_val = _mm_set_ps1(max_val);
|
||||
const __m128 vmin_val = _mm_set_ps1(min_val);
|
||||
const __m128 vmax_val = _mm_set_ps1(max_val);
|
||||
|
||||
for(unsigned int i = 0;i < sse_iters; i++)
|
||||
{
|
||||
inputVal1 = _mm_loadu_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
inputVal2 = _mm_loadu_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
__builtin_prefetch(inputVectorPtr + 8);
|
||||
|
||||
// Clip
|
||||
ret1 = _mm_max_ps(_mm_min_ps(inputVal1, vmax_val), vmin_val);
|
||||
@ -148,11 +153,12 @@ static inline void volk_gnsssdr_32fc_convert_16ic_u_sse(lv_16sc_t* outputVector,
|
||||
|
||||
for(unsigned int i = sse_iters * 8; i < num_points*2; i++)
|
||||
{
|
||||
if(inputVectorPtr[i] > max_val)
|
||||
inputVectorPtr[i] = max_val;
|
||||
else if(inputVectorPtr[i] < min_val)
|
||||
inputVectorPtr[i] = min_val;
|
||||
*outputVectorPtr++ = (int16_t)rintf(*inputVectorPtr++);
|
||||
aux = *inputVectorPtr++;
|
||||
if(aux > max_val)
|
||||
aux = max_val;
|
||||
else if(aux < min_val)
|
||||
aux = min_val;
|
||||
*outputVectorPtr++ = (int16_t)rintf(aux);
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_SSE */
|
||||
@ -167,20 +173,22 @@ static inline void volk_gnsssdr_32fc_convert_16ic_a_sse2(lv_16sc_t* outputVector
|
||||
|
||||
float* inputVectorPtr = (float*)inputVector;
|
||||
int16_t* outputVectorPtr = (int16_t*)outputVector;
|
||||
float aux;
|
||||
|
||||
float min_val = SHRT_MIN;
|
||||
float max_val = SHRT_MAX;
|
||||
const float min_val = (float)SHRT_MIN;
|
||||
const float max_val = (float)SHRT_MAX;
|
||||
|
||||
__m128 inputVal1, inputVal2;
|
||||
__m128i intInputVal1, intInputVal2;
|
||||
__m128 ret1, ret2;
|
||||
__m128 vmin_val = _mm_set_ps1(min_val);
|
||||
__m128 vmax_val = _mm_set_ps1(max_val);
|
||||
const __m128 vmin_val = _mm_set_ps1(min_val);
|
||||
const __m128 vmax_val = _mm_set_ps1(max_val);
|
||||
|
||||
for(unsigned int i = 0; i < sse_iters; i++)
|
||||
{
|
||||
inputVal1 = _mm_load_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
inputVal2 = _mm_load_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
__builtin_prefetch(inputVectorPtr + 8);
|
||||
|
||||
// Clip
|
||||
ret1 = _mm_max_ps(_mm_min_ps(inputVal1, vmax_val), vmin_val);
|
||||
@ -197,11 +205,12 @@ static inline void volk_gnsssdr_32fc_convert_16ic_a_sse2(lv_16sc_t* outputVector
|
||||
|
||||
for(unsigned int i = sse_iters * 8; i < num_points * 2; i++)
|
||||
{
|
||||
if(inputVectorPtr[i] > max_val)
|
||||
inputVectorPtr[i] = max_val;
|
||||
else if(inputVectorPtr[i] < min_val)
|
||||
inputVectorPtr[i] = min_val;
|
||||
*outputVectorPtr++ = (int16_t)rintf(*inputVectorPtr++);
|
||||
aux = *inputVectorPtr++;
|
||||
if(aux > max_val)
|
||||
aux = max_val;
|
||||
else if(aux < min_val)
|
||||
aux = min_val;
|
||||
*outputVectorPtr++ = (int16_t)rintf(aux);
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_SSE2 */
|
||||
@ -213,23 +222,24 @@ static inline void volk_gnsssdr_32fc_convert_16ic_a_sse2(lv_16sc_t* outputVector
|
||||
static inline void volk_gnsssdr_32fc_convert_16ic_a_sse(lv_16sc_t* outputVector, const lv_32fc_t* inputVector, unsigned int num_points)
|
||||
{
|
||||
const unsigned int sse_iters = num_points / 4;
|
||||
const float min_val = (float)SHRT_MIN;
|
||||
const float max_val = (float)SHRT_MAX;
|
||||
float aux;
|
||||
|
||||
float* inputVectorPtr = (float*)inputVector;
|
||||
int16_t* outputVectorPtr = (int16_t*)outputVector;
|
||||
|
||||
float min_val = SHRT_MIN;
|
||||
float max_val = SHRT_MAX;
|
||||
|
||||
__m128 inputVal1, inputVal2;
|
||||
__m128i intInputVal1, intInputVal2;
|
||||
__m128 ret1, ret2;
|
||||
__m128 vmin_val = _mm_set_ps1(min_val);
|
||||
__m128 vmax_val = _mm_set_ps1(max_val);
|
||||
const __m128 vmin_val = _mm_set_ps1(min_val);
|
||||
const __m128 vmax_val = _mm_set_ps1(max_val);
|
||||
|
||||
for(unsigned int i = 0;i < sse_iters; i++)
|
||||
{
|
||||
inputVal1 = _mm_load_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
inputVal2 = _mm_load_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
__builtin_prefetch(inputVectorPtr + 8);
|
||||
|
||||
// Clip
|
||||
ret1 = _mm_max_ps(_mm_min_ps(inputVal1, vmax_val), vmin_val);
|
||||
@ -246,11 +256,12 @@ static inline void volk_gnsssdr_32fc_convert_16ic_a_sse(lv_16sc_t* outputVector,
|
||||
|
||||
for(unsigned int i = sse_iters * 8; i < num_points * 2; i++)
|
||||
{
|
||||
if(inputVectorPtr[i] > max_val)
|
||||
inputVectorPtr[i] = max_val;
|
||||
else if(inputVectorPtr[i] < min_val)
|
||||
inputVectorPtr[i] = min_val;
|
||||
*outputVectorPtr++ = (int16_t)rintf(*inputVectorPtr++);
|
||||
aux = *inputVectorPtr++;
|
||||
if(aux > max_val)
|
||||
aux = max_val;
|
||||
else if(aux < min_val)
|
||||
aux = min_val;
|
||||
*outputVectorPtr++ = (int16_t)rintf(aux);
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_SSE */
|
||||
@ -266,8 +277,12 @@ static inline void volk_gnsssdr_32fc_convert_16ic_neon(lv_16sc_t* outputVector,
|
||||
float32_t* inputVectorPtr = (float32_t*)inputVector;
|
||||
int16_t* outputVectorPtr = (int16_t*)outputVector;
|
||||
|
||||
float32x4_t min_val = vmovq_n_f32(SHRT_MIN);
|
||||
float32x4_t max_val = vmovq_n_f32(SHRT_MAX);
|
||||
const float min_val_f = (float)SHRT_MIN;
|
||||
const float max_val_f = (float)SHRT_MAX;
|
||||
float32_t aux;
|
||||
|
||||
const float32x4_t min_val = vmovq_n_f32(min_val_f);
|
||||
const float32x4_t max_val = vmovq_n_f32(max_val_f);
|
||||
float32x4_t half = vdupq_n_f32(0.5f);
|
||||
float32x4_t ret1, ret2, a, b, sign, PlusHalf, Round;
|
||||
|
||||
@ -279,6 +294,7 @@ static inline void volk_gnsssdr_32fc_convert_16ic_neon(lv_16sc_t* outputVector,
|
||||
{
|
||||
a = vld1q_f32((const float32_t*)(inputVectorPtr)); inputVectorPtr += 4;
|
||||
b = vld1q_f32((const float32_t*)(inputVectorPtr)); inputVectorPtr += 4;
|
||||
__builtin_prefetch(inputVectorPtr + 8);
|
||||
|
||||
ret1 = vmaxq_f32(vminq_f32(a, max_val), min_val);
|
||||
ret2 = vmaxq_f32(vminq_f32(b, max_val), min_val);
|
||||
@ -304,11 +320,12 @@ static inline void volk_gnsssdr_32fc_convert_16ic_neon(lv_16sc_t* outputVector,
|
||||
|
||||
for(unsigned int i = neon_iters * 8; i < num_points * 2; i++)
|
||||
{
|
||||
if(inputVectorPtr[i] > SHRT_MAX)
|
||||
inputVectorPtr[i] = (int16_t)SHRT_MAX;
|
||||
else if(inputVectorPtr[i] < SHRT_MIN)
|
||||
inputVectorPtr[i] = (int16_t)SHRT_MIN;
|
||||
*outputVectorPtr++ = (int16_t)rintf(*inputVectorPtr++);
|
||||
aux = *inputVectorPtr++;
|
||||
if(aux > max_val_f)
|
||||
aux = max_val_f;
|
||||
else if(aux < min_val_f)
|
||||
aux = min_val_f;
|
||||
*outputVectorPtr++ = (int16_t)rintf(aux);
|
||||
}
|
||||
}
|
||||
|
||||
@ -321,16 +338,18 @@ static inline void volk_gnsssdr_32fc_convert_16ic_generic(lv_16sc_t* outputVecto
|
||||
{
|
||||
float* inputVectorPtr = (float*)inputVector;
|
||||
int16_t* outputVectorPtr = (int16_t*)outputVector;
|
||||
float min_val = SHRT_MIN;
|
||||
float max_val = SHRT_MAX;
|
||||
const float min_val = (float)SHRT_MIN;
|
||||
const float max_val = (float)SHRT_MAX;
|
||||
float aux;
|
||||
|
||||
for(unsigned int i = 0; i < num_points * 2; i++)
|
||||
{
|
||||
if(inputVectorPtr[i] > max_val)
|
||||
inputVectorPtr[i] = max_val;
|
||||
else if(inputVectorPtr[i] < min_val)
|
||||
inputVectorPtr[i] = min_val;
|
||||
outputVectorPtr[i] = (int16_t)rintf(inputVectorPtr[i]);
|
||||
aux = *inputVectorPtr++;
|
||||
if(aux > max_val)
|
||||
aux = max_val;
|
||||
else if(aux < min_val)
|
||||
aux = min_val;
|
||||
*outputVectorPtr++ = (int16_t)rintf(aux);
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_GENERIC */
|
||||
|
@ -62,34 +62,62 @@
|
||||
#include "volk_gnsssdr/volk_gnsssdr_complex.h"
|
||||
|
||||
|
||||
#ifdef LV_HAVE_GENERIC
|
||||
|
||||
static inline void volk_gnsssdr_32fc_convert_8ic_generic(lv_8sc_t* outputVector, const lv_32fc_t* inputVector, unsigned int num_points)
|
||||
{
|
||||
float* inputVectorPtr = (float*)inputVector;
|
||||
int8_t* outputVectorPtr = (int8_t*)outputVector;
|
||||
const float min_val = (float)SCHAR_MIN;
|
||||
const float max_val = (float)SCHAR_MAX;
|
||||
float aux;
|
||||
|
||||
for(unsigned int i = 0; i < num_points * 2; i++)
|
||||
{
|
||||
aux = *inputVectorPtr++ * max_val;
|
||||
if(aux > max_val)
|
||||
aux = max_val;
|
||||
else if(aux < min_val)
|
||||
aux = min_val;
|
||||
*outputVectorPtr++ = (int8_t)rintf(aux);
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_GENERIC */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_SSE2
|
||||
#include <emmintrin.h>
|
||||
|
||||
static inline void volk_gnsssdr_32fc_convert_8ic_u_sse2(lv_8sc_t* outputVector, const lv_32fc_t* inputVector, unsigned int num_points)
|
||||
{
|
||||
unsigned i = 0;
|
||||
const unsigned int sse_iters = num_points * 2 / 16;
|
||||
const unsigned int sse_iters = num_points / 8;
|
||||
|
||||
float* inputVectorPtr = (float*)inputVector;
|
||||
int8_t* outputVectorPtr = (int8_t*)outputVector;
|
||||
|
||||
float min_val = SCHAR_MIN;
|
||||
float max_val = SCHAR_MAX;
|
||||
const float min_val = (float)SCHAR_MIN;
|
||||
const float max_val = (float)SCHAR_MAX;
|
||||
float aux;
|
||||
|
||||
__m128 inputVal1, inputVal2, inputVal3, inputVal4;
|
||||
__m128i intInputVal1, intInputVal2, intInputVal3, intInputVal4;
|
||||
__m128i int8InputVal;
|
||||
__m128 ret1, ret2, ret3, ret4;
|
||||
__m128 vmin_val = _mm_set_ps1(min_val);
|
||||
__m128 vmax_val = _mm_set_ps1(max_val);
|
||||
const __m128 vmin_val = _mm_set_ps1(min_val);
|
||||
const __m128 vmax_val = _mm_set_ps1(max_val);
|
||||
|
||||
for(;i < sse_iters; i++)
|
||||
for(unsigned int i = 0; i < sse_iters; i++)
|
||||
{
|
||||
inputVal1 = _mm_loadu_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
inputVal2 = _mm_loadu_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
inputVal3 = _mm_loadu_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
inputVal4 = _mm_loadu_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
|
||||
inputVal1 = _mm_mul_ps(inputVal1, vmax_val);
|
||||
inputVal2 = _mm_mul_ps(inputVal2, vmax_val);
|
||||
inputVal3 = _mm_mul_ps(inputVal3, vmax_val);
|
||||
inputVal4 = _mm_mul_ps(inputVal4, vmax_val);
|
||||
|
||||
// Clip
|
||||
ret1 = _mm_max_ps(_mm_min_ps(inputVal1, vmax_val), vmin_val);
|
||||
ret2 = _mm_max_ps(_mm_min_ps(inputVal2, vmax_val), vmin_val);
|
||||
@ -109,39 +137,19 @@ static inline void volk_gnsssdr_32fc_convert_8ic_u_sse2(lv_8sc_t* outputVector,
|
||||
outputVectorPtr += 16;
|
||||
}
|
||||
|
||||
for(i = sse_iters * 16; i < num_points * 2; i++)
|
||||
for(unsigned int i = sse_iters * 16; i < num_points * 2; i++)
|
||||
{
|
||||
if(inputVectorPtr[i] > max_val)
|
||||
inputVectorPtr[i] = max_val;
|
||||
else if(inputVectorPtr[i] < min_val)
|
||||
inputVectorPtr[i] = min_val;
|
||||
*outputVectorPtr++ = (int8_t)rintf(*inputVectorPtr++);
|
||||
aux = *inputVectorPtr++ * max_val;
|
||||
if(aux > max_val)
|
||||
aux = max_val;
|
||||
else if(aux < min_val)
|
||||
aux = min_val;
|
||||
*outputVectorPtr++ = (int8_t)rintf(aux);
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_SSE2 */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_GENERIC
|
||||
|
||||
static inline void volk_gnsssdr_32fc_convert_8ic_generic(lv_8sc_t* outputVector, const lv_32fc_t* inputVector, unsigned int num_points)
|
||||
{
|
||||
float* inputVectorPtr = (float*)inputVector;
|
||||
int8_t* outputVectorPtr = (int8_t*)outputVector;
|
||||
float min_val = SCHAR_MIN;
|
||||
float max_val = SCHAR_MAX;
|
||||
|
||||
for(unsigned int i = 0; i < num_points * 2; i++)
|
||||
{
|
||||
if(inputVectorPtr[i] > max_val)
|
||||
inputVectorPtr[i] = max_val;
|
||||
else if(inputVectorPtr[i] < min_val)
|
||||
inputVectorPtr[i] = min_val;
|
||||
outputVectorPtr[i] = (int8_t)rintf(inputVectorPtr[i]);
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_GENERIC */
|
||||
|
||||
|
||||
#ifdef LV_HAVE_SSE2
|
||||
#include <emmintrin.h>
|
||||
|
||||
@ -152,15 +160,16 @@ static inline void volk_gnsssdr_32fc_convert_8ic_a_sse2(lv_8sc_t* outputVector,
|
||||
float* inputVectorPtr = (float*)inputVector;
|
||||
int8_t* outputVectorPtr = (int8_t*)outputVector;
|
||||
|
||||
float min_val = SCHAR_MIN;
|
||||
float max_val = SCHAR_MAX;
|
||||
const float min_val = (float)SCHAR_MIN;
|
||||
const float max_val = (float)SCHAR_MAX;
|
||||
float aux;
|
||||
|
||||
__m128 inputVal1, inputVal2, inputVal3, inputVal4;
|
||||
__m128i intInputVal1, intInputVal2, intInputVal3, intInputVal4;
|
||||
__m128i int8InputVal;
|
||||
__m128 ret1, ret2, ret3, ret4;
|
||||
__m128 vmin_val = _mm_set_ps1(min_val);
|
||||
__m128 vmax_val = _mm_set_ps1(max_val);
|
||||
const __m128 vmin_val = _mm_set_ps1(min_val);
|
||||
const __m128 vmax_val = _mm_set_ps1(max_val);
|
||||
|
||||
for(unsigned int i = 0; i < sse_iters; i++)
|
||||
{
|
||||
@ -169,6 +178,11 @@ static inline void volk_gnsssdr_32fc_convert_8ic_a_sse2(lv_8sc_t* outputVector,
|
||||
inputVal3 = _mm_load_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
inputVal4 = _mm_load_ps((float*)inputVectorPtr); inputVectorPtr += 4;
|
||||
|
||||
inputVal1 = _mm_mul_ps(inputVal1, vmax_val);
|
||||
inputVal2 = _mm_mul_ps(inputVal2, vmax_val);
|
||||
inputVal3 = _mm_mul_ps(inputVal3, vmax_val);
|
||||
inputVal4 = _mm_mul_ps(inputVal4, vmax_val);
|
||||
|
||||
// Clip
|
||||
ret1 = _mm_max_ps(_mm_min_ps(inputVal1, vmax_val), vmin_val);
|
||||
ret2 = _mm_max_ps(_mm_min_ps(inputVal2, vmax_val), vmin_val);
|
||||
@ -190,11 +204,12 @@ static inline void volk_gnsssdr_32fc_convert_8ic_a_sse2(lv_8sc_t* outputVector,
|
||||
|
||||
for(unsigned int i = sse_iters * 16; i < num_points * 2; i++)
|
||||
{
|
||||
if(inputVectorPtr[i] > max_val)
|
||||
inputVectorPtr[i] = max_val;
|
||||
else if(inputVectorPtr[i] < min_val)
|
||||
inputVectorPtr[i] = min_val;
|
||||
*outputVectorPtr++ = (int8_t)rintf(*inputVectorPtr++);
|
||||
aux = *inputVectorPtr++ * max_val;
|
||||
if(aux > max_val)
|
||||
aux = max_val;
|
||||
else if(aux < min_val)
|
||||
aux = min_val;
|
||||
*outputVectorPtr++ = (int8_t)rintf(aux);
|
||||
}
|
||||
}
|
||||
#endif /* LV_HAVE_SSE2 */
|
||||
@ -209,9 +224,12 @@ static inline void volk_gnsssdr_32fc_convert_8ic_neon(lv_8sc_t* outputVector, co
|
||||
|
||||
float32_t* inputVectorPtr = (float32_t*)inputVector;
|
||||
int8_t* outputVectorPtr = (int8_t*)outputVector;
|
||||
const float32_t max_val_f = (float32_t)SCHAR_MAX;
|
||||
const float32_t min_val_f = (float32_t)SCHAR_MIN;
|
||||
float32_t aux;
|
||||
|
||||
const float32x4_t min_val = vmovq_n_f32((float32_t)SCHAR_MIN);
|
||||
const float32x4_t max_val = vmovq_n_f32((float32_t)SCHAR_MAX);
|
||||
const float32x4_t min_val = vmovq_n_f32(min_val_f);
|
||||
const float32x4_t max_val = vmovq_n_f32(max_val_f);
|
||||
|
||||
const float32x4_t half = vdupq_n_f32(0.5f);
|
||||
|
||||
@ -225,6 +243,7 @@ static inline void volk_gnsssdr_32fc_convert_8ic_neon(lv_8sc_t* outputVector, co
|
||||
for(unsigned int i = 0; i < neon_iters; i++)
|
||||
{
|
||||
a = vld1q_f32((const float32_t*)inputVectorPtr); inputVectorPtr += 4;
|
||||
a = vmulq_f32(a, max_val);
|
||||
ret1 = vmaxq_f32(vminq_f32(a, max_val), min_val);
|
||||
sign = vcvtq_f32_u32((vshrq_n_u32(vreinterpretq_u32_f32(ret1), 31)));
|
||||
PlusHalf = vaddq_f32(ret1, half);
|
||||
@ -233,6 +252,7 @@ static inline void volk_gnsssdr_32fc_convert_8ic_neon(lv_8sc_t* outputVector, co
|
||||
intInputVal1 = vqmovn_s32(toint_a);
|
||||
|
||||
a = vld1q_f32((const float32_t*)inputVectorPtr); inputVectorPtr += 4;
|
||||
a = vmulq_f32(a, max_val);
|
||||
ret1 = vmaxq_f32(vminq_f32(a, max_val), min_val);
|
||||
sign = vcvtq_f32_u32((vshrq_n_u32(vreinterpretq_u32_f32(ret1), 31)));
|
||||
PlusHalf = vaddq_f32(ret1, half);
|
||||
@ -244,6 +264,7 @@ static inline void volk_gnsssdr_32fc_convert_8ic_neon(lv_8sc_t* outputVector, co
|
||||
res8_1 = vqmovn_s16(pack16_8_1);
|
||||
|
||||
a = vld1q_f32((const float32_t*)inputVectorPtr); inputVectorPtr += 4;
|
||||
a = vmulq_f32(a, max_val);
|
||||
ret1 = vmaxq_f32(vminq_f32(a, max_val), min_val);
|
||||
sign = vcvtq_f32_u32((vshrq_n_u32(vreinterpretq_u32_f32(ret1), 31)));
|
||||
PlusHalf = vaddq_f32(ret1, half);
|
||||
@ -252,6 +273,7 @@ static inline void volk_gnsssdr_32fc_convert_8ic_neon(lv_8sc_t* outputVector, co
|
||||
intInputVal1 = vqmovn_s32(toint_a);
|
||||
|
||||
a = vld1q_f32((const float32_t*)inputVectorPtr); inputVectorPtr += 4;
|
||||
a = vmulq_f32(a, max_val);
|
||||
ret1 = vmaxq_f32(vminq_f32(a, max_val), min_val);
|
||||
sign = vcvtq_f32_u32((vshrq_n_u32(vreinterpretq_u32_f32(ret1), 31)));
|
||||
PlusHalf = vaddq_f32(ret1, half);
|
||||
@ -270,11 +292,12 @@ static inline void volk_gnsssdr_32fc_convert_8ic_neon(lv_8sc_t* outputVector, co
|
||||
|
||||
for(unsigned int i = neon_iters * 16; i < num_points * 2; i++)
|
||||
{
|
||||
if(inputVectorPtr[i] > (float32_t)SCHAR_MAX)
|
||||
inputVectorPtr[i] = (float32_t)SCHAR_MAX;
|
||||
else if(inputVectorPtr[i] < (float32_t)SCHAR_MIN)
|
||||
inputVectorPtr[i] = (float32_t)SCHAR_MIN;
|
||||
*outputVectorPtr++ = (int8_t)rintf(*inputVectorPtr++);
|
||||
aux = *inputVectorPtr++ * max_val_f;
|
||||
if(aux > max_val_f)
|
||||
aux = max_val_f;
|
||||
else if(aux < min_val_f)
|
||||
aux = min_val_f;
|
||||
*outputVectorPtr++ = (int8_t)rintf(aux);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user