mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-16 12:12:57 +00:00
Adding neon implementation
Input data have been re-scaled to avoid saturation problems
This commit is contained in:
parent
d2a95c2638
commit
a4e2ceb9c4
@ -49,9 +49,9 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_generic(lv_16sc_t*
|
|||||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
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());
|
in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment());
|
||||||
memcpy(in_a[n], in, sizeof(lv_16sc_t) * num_points);
|
memcpy((lv_16sc_t*)in_a[n], (lv_16sc_t*)in, sizeof(lv_16sc_t) * num_points);
|
||||||
}
|
}
|
||||||
result = (lv_16sc_t*)calloc(num_points, sizeof(lv_16sc_t));
|
|
||||||
volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_generic(result, local_code, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_generic(result, local_code, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
||||||
|
|
||||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
for(unsigned int n = 0; n < num_a_vectors; n++)
|
||||||
@ -73,7 +73,7 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_a_sse2(lv_16sc_t* r
|
|||||||
in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment());
|
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);
|
memcpy((lv_16sc_t*)in_a[n], (lv_16sc_t*)in, sizeof(lv_16sc_t) * num_points);
|
||||||
}
|
}
|
||||||
result = (lv_16sc_t*)calloc(num_points, sizeof(lv_16sc_t));
|
|
||||||
volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_a_sse2(result, local_code, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_a_sse2(result, local_code, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
||||||
|
|
||||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
for(unsigned int n = 0; n < num_a_vectors; n++)
|
||||||
@ -94,9 +94,9 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_u_sse2(lv_16sc_t* r
|
|||||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
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());
|
in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t)*num_points, volk_gnsssdr_get_alignment());
|
||||||
memcpy(in_a[n], in, sizeof(lv_16sc_t)*num_points);
|
memcpy((lv_16sc_t*)in_a[n], (lv_16sc_t*)in, sizeof(lv_16sc_t)*num_points);
|
||||||
}
|
}
|
||||||
result = (lv_16sc_t*)calloc(num_points, sizeof(lv_16sc_t));
|
|
||||||
volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_u_sse2(result, local_code, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_u_sse2(result, local_code, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
||||||
|
|
||||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
for(unsigned int n = 0; n < num_a_vectors; n++)
|
||||||
@ -117,9 +117,9 @@ static inline void volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic_neon(lv_16sc_t* res
|
|||||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
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());
|
in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t)*num_points, volk_gnsssdr_get_alignment());
|
||||||
memcpy(in_a[n], in, sizeof(lv_16sc_t)*num_points);
|
memcpy((lv_16sc_t*)in_a[n], (lv_16sc_t*)in, sizeof(lv_16sc_t)*num_points);
|
||||||
}
|
}
|
||||||
result = (lv_16sc_t*)calloc(num_points, sizeof(lv_16sc_t));
|
|
||||||
volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_neon(result, local_code, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
volk_gnsssdr_16ic_x2_dot_prod_16ic_xn_neon(result, local_code, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
||||||
|
|
||||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
for(unsigned int n = 0; n < num_a_vectors; n++)
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
/*!
|
/*!
|
||||||
* \file volk_gnsssdr_16ic_x2_dot_prod_16ic_xn.h
|
* \file volk_gnsssdr_16ic_x2_dot_prod_16ic_xn.h
|
||||||
* \brief Volk protokernel: multiplies N 16 bits vectors by a common vector phase rotated and accumulates the results in N 16 bits short complex outputs.
|
* \brief Volk protokernel: multiplies N 16 bits vectors by a common vector
|
||||||
|
* phase rotated and accumulates the results in N 16 bits short complex outputs.
|
||||||
* \authors <ul>
|
* \authors <ul>
|
||||||
* <li> Javier Arribas, 2015. jarribas(at)cttc.es
|
* <li> Javier Arribas, 2015. jarribas(at)cttc.es
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* Volk protokernel that multiplies N 16 bits vectors by a common vector, which is phase-rotated by phase offset and phase increment, and accumulates the results in N 16 bits short complex outputs.
|
* Volk protokernel that multiplies N 16 bits vectors by a common vector, which is
|
||||||
|
* phase-rotated by phase offset and phase increment, and accumulates the results
|
||||||
|
* in N 16 bits short complex outputs.
|
||||||
* It is optimized to perform the N tap correlation process in GNSS receivers.
|
* It is optimized to perform the N tap correlation process in GNSS receivers.
|
||||||
*
|
*
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
@ -43,9 +46,11 @@
|
|||||||
|
|
||||||
#ifdef LV_HAVE_GENERIC
|
#ifdef LV_HAVE_GENERIC
|
||||||
/*!
|
/*!
|
||||||
\brief Multiplies the reference complex vector with multiple versions of another complex vector, accumulates the results and stores them in the output vector
|
\brief Rotates and multiplies the reference complex vector with multiple versions of another complex vector, accumulates the results and stores them in the output vector
|
||||||
\param[out] result Array of num_a_vectors components with the multiple versions of in_a multiplied and accumulated The vector where the accumulated result will be stored
|
\param[out] result Array of num_a_vectors components with the multiple versions of in_a multiplied and accumulated The vector where the accumulated result will be stored
|
||||||
\param[in] in_common Pointer to one of the vectors to be multiplied and accumulated (reference vector)
|
\param[in] in_common Pointer to one of the vectors to be rotated, multiplied and accumulated (reference vector)
|
||||||
|
\param[in] phase_inc Phase increment = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad))
|
||||||
|
\param[in,out] phase Initial / final phase
|
||||||
\param[in] in_a Pointer to an array of pointers to multiple versions of the other vector to be multiplied and accumulated
|
\param[in] in_a Pointer to an array of pointers to multiple versions of the other vector to be multiplied and accumulated
|
||||||
\param[in] num_a_vectors Number of vectors to be multiplied by the reference vector and accumulated
|
\param[in] num_a_vectors Number of vectors to be multiplied by the reference vector and accumulated
|
||||||
\param[in] num_points The Number of complex values to be multiplied together, accumulated and stored into result
|
\param[in] num_points The Number of complex values to be multiplied together, accumulated and stored into result
|
||||||
@ -79,9 +84,11 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_generic(lv_16sc
|
|||||||
#include <pmmintrin.h>
|
#include <pmmintrin.h>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Multiplies the reference complex vector with multiple versions of another complex vector, accumulates the results and stores them in the output vector
|
\brief Rotates and multiplies the reference complex vector with multiple versions of another complex vector, accumulates the results and stores them in the output vector
|
||||||
\param[out] result Array of num_a_vectors components with the multiple versions of in_a multiplied and accumulated The vector where the accumulated result will be stored
|
\param[out] result Array of num_a_vectors components with the multiple versions of in_a multiplied and accumulated The vector where the accumulated result will be stored
|
||||||
\param[in] in_common Pointer to one of the vectors to be multiplied and accumulated (reference vector)
|
\param[in] in_common Pointer to one of the vectors to be rotated, multiplied and accumulated (reference vector)
|
||||||
|
\param[in] phase_inc Phase increment = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad))
|
||||||
|
\param[in,out] phase Initial / final phase
|
||||||
\param[in] in_a Pointer to an array of pointers to multiple versions of the other vector to be multiplied and accumulated
|
\param[in] in_a Pointer to an array of pointers to multiple versions of the other vector to be multiplied and accumulated
|
||||||
\param[in] num_a_vectors Number of vectors to be multiplied by the reference vector and accumulated
|
\param[in] num_a_vectors Number of vectors to be multiplied by the reference vector and accumulated
|
||||||
\param[in] num_points The Number of complex values to be multiplied together, accumulated and stored into result
|
\param[in] num_points The Number of complex values to be multiplied together, accumulated and stored into result
|
||||||
@ -193,7 +200,6 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_a_sse3(lv_16sc_
|
|||||||
|
|
||||||
realcacc[n_vec] = _mm_adds_epi16 (realcacc[n_vec], real);
|
realcacc[n_vec] = _mm_adds_epi16 (realcacc[n_vec], real);
|
||||||
imagcacc[n_vec] = _mm_adds_epi16 (imagcacc[n_vec], imag);
|
imagcacc[n_vec] = _mm_adds_epi16 (imagcacc[n_vec], imag);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,9 +246,11 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_a_sse3(lv_16sc_
|
|||||||
#include <pmmintrin.h>
|
#include <pmmintrin.h>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Multiplies the reference complex vector with multiple versions of another complex vector, accumulates the results and stores them in the output vector
|
\brief Rotates and multiplies the reference complex vector with multiple versions of another complex vector, accumulates the results and stores them in the output vector
|
||||||
\param[out] result Array of num_a_vectors components with the multiple versions of in_a multiplied and accumulated The vector where the accumulated result will be stored
|
\param[out] result Array of num_a_vectors components with the multiple versions of in_a multiplied and accumulated The vector where the accumulated result will be stored
|
||||||
\param[in] in_common Pointer to one of the vectors to be multiplied and accumulated (reference vector)
|
\param[in] in_common Pointer to one of the vectors to be rotated, multiplied and accumulated (reference vector)
|
||||||
|
\param[in] phase_inc Phase increment = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad))
|
||||||
|
\param[in,out] phase Initial / final phase
|
||||||
\param[in] in_a Pointer to an array of pointers to multiple versions of the other vector to be multiplied and accumulated
|
\param[in] in_a Pointer to an array of pointers to multiple versions of the other vector to be multiplied and accumulated
|
||||||
\param[in] num_a_vectors Number of vectors to be multiplied by the reference vector and accumulated
|
\param[in] num_a_vectors Number of vectors to be multiplied by the reference vector and accumulated
|
||||||
\param[in] num_points The Number of complex values to be multiplied together, accumulated and stored into result
|
\param[in] num_points The Number of complex values to be multiplied together, accumulated and stored into result
|
||||||
@ -354,7 +362,6 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_u_sse3(lv_16sc_
|
|||||||
|
|
||||||
realcacc[n_vec] = _mm_adds_epi16(realcacc[n_vec], real);
|
realcacc[n_vec] = _mm_adds_epi16(realcacc[n_vec], real);
|
||||||
imagcacc[n_vec] = _mm_adds_epi16(imagcacc[n_vec], imag);
|
imagcacc[n_vec] = _mm_adds_epi16(imagcacc[n_vec], imag);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,7 +400,179 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_u_sse3(lv_16sc_
|
|||||||
sat_adds16i(lv_cimag(_out[n_vec]), lv_cimag(tmp)));
|
sat_adds16i(lv_cimag(_out[n_vec]), lv_cimag(tmp)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* LV_HAVE_SSE3 */
|
#endif /* LV_HAVE_SSE3 */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef LV_HAVE_NEON
|
||||||
|
#include <arm_neon.h>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Rotates and multiplies the reference complex vector with multiple versions of another complex vector, accumulates the results and stores them in the output vector
|
||||||
|
\param[out] result Array of num_a_vectors components with the multiple versions of in_a multiplied and accumulated The vector where the accumulated result will be stored
|
||||||
|
\param[in] in_common Pointer to one of the vectors to be rotated, multiplied and accumulated (reference vector)
|
||||||
|
\param[in] phase_inc Phase increment = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad))
|
||||||
|
\param[in,out] phase Initial / final phase
|
||||||
|
\param[in] in_a Pointer to an array of pointers to multiple versions of the other vector to be multiplied and accumulated
|
||||||
|
\param[in] num_a_vectors Number of vectors to be multiplied by the reference vector and accumulated
|
||||||
|
\param[in] num_points The Number of complex values to be multiplied together, accumulated and stored into result
|
||||||
|
*/
|
||||||
|
static inline void volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_neon(lv_16sc_t* out, const lv_16sc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const lv_16sc_t** in_a, int num_a_vectors, unsigned int num_points)
|
||||||
|
{
|
||||||
|
const unsigned int neon_iters = num_points / 4;
|
||||||
|
|
||||||
|
const lv_16sc_t** _in_a = in_a;
|
||||||
|
const lv_16sc_t* _in_common = in_common;
|
||||||
|
lv_16sc_t* _out = out;
|
||||||
|
|
||||||
|
lv_16sc_t tmp16_, tmp;
|
||||||
|
lv_32fc_t tmp32_;
|
||||||
|
|
||||||
|
if (neon_iters > 0)
|
||||||
|
{
|
||||||
|
lv_16sc_t dotProduct = lv_cmake(0,0);
|
||||||
|
|
||||||
|
lv_32fc_t ___phase4 = phase_inc * phase_inc * phase_inc * phase_inc;
|
||||||
|
__VOLK_ATTR_ALIGNED(16) float32_t __phase4_real[4] = { lv_creal(___phase4), lv_creal(___phase4), lv_creal(___phase4), lv_creal(___phase4) };
|
||||||
|
__VOLK_ATTR_ALIGNED(16) float32_t __phase4_imag[4] = { lv_cimag(___phase4), lv_cimag(___phase4), lv_cimag(___phase4), lv_cimag(___phase4) };
|
||||||
|
|
||||||
|
float32x4_t _phase4_real = vld1q_f32(__phase4_real);
|
||||||
|
float32x4_t _phase4_imag = vld1q_f32(__phase4_imag);
|
||||||
|
|
||||||
|
lv_32fc_t phase2 = (lv_32fc_t)(*phase) * phase_inc;
|
||||||
|
lv_32fc_t phase3 = phase2 * phase_inc;
|
||||||
|
lv_32fc_t phase4 = phase3 * phase_inc;
|
||||||
|
|
||||||
|
__VOLK_ATTR_ALIGNED(16) float32_t __phase_real[4] = { lv_creal((*phase)), lv_creal(phase2), lv_creal(phase3), lv_creal(phase4) };
|
||||||
|
__VOLK_ATTR_ALIGNED(16) float32_t __phase_imag[4] = { lv_cimag((*phase)), lv_cimag(phase2), lv_cimag(phase3), lv_cimag(phase4) };
|
||||||
|
|
||||||
|
float32x4_t _phase_real = vld1q_f32(__phase_real);
|
||||||
|
float32x4_t _phase_imag = vld1q_f32(__phase_imag);
|
||||||
|
|
||||||
|
int16x4x2_t a_val, c_val;
|
||||||
|
__VOLK_ATTR_ALIGNED(16) lv_16sc_t dotProductVector[4];
|
||||||
|
float32x4_t half = vdupq_n_f32(0.5f);
|
||||||
|
int16x4x2_t tmp16;
|
||||||
|
int32x4x2_t tmp32i;
|
||||||
|
float32x4x2_t tmp32f, tmp_real, tmp_imag;
|
||||||
|
float32x4_t sign, PlusHalf, Round;
|
||||||
|
|
||||||
|
int16x4x2_t* accumulator;
|
||||||
|
accumulator = (int16x4x2_t*)calloc(num_a_vectors, sizeof(int16x4x2_t));
|
||||||
|
|
||||||
|
int16x4x2_t tmp_real16, tmp_imag16;
|
||||||
|
|
||||||
|
for(int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||||
|
{
|
||||||
|
accumulator[n_vec].val[0] = vdup_n_s16(0);
|
||||||
|
accumulator[n_vec].val[1] = vdup_n_s16(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(unsigned int number = 0; number < neon_iters; number++)
|
||||||
|
{
|
||||||
|
/* load 4 complex numbers (int 16 bits each component) */
|
||||||
|
tmp16 = vld2_s16((int16_t*)_in_common);
|
||||||
|
__builtin_prefetch(_in_common + 8);
|
||||||
|
_in_common += 4;
|
||||||
|
|
||||||
|
/* promote them to int 32 bits */
|
||||||
|
tmp32i.val[0] = vmovl_s16(tmp16.val[0]);
|
||||||
|
tmp32i.val[1] = vmovl_s16(tmp16.val[1]);
|
||||||
|
|
||||||
|
/* promote them to float 32 bits */
|
||||||
|
tmp32f.val[0] = vcvtq_f32_s32(tmp32i.val[0]);
|
||||||
|
tmp32f.val[1] = vcvtq_f32_s32(tmp32i.val[1]);
|
||||||
|
|
||||||
|
/* complex multiplication of four complex samples (float 32 bits each component) */
|
||||||
|
tmp_real.val[0] = vmulq_f32(tmp32f.val[0], _phase_real);
|
||||||
|
tmp_real.val[1] = vmulq_f32(tmp32f.val[1], _phase_imag);
|
||||||
|
tmp_imag.val[0] = vmulq_f32(tmp32f.val[0], _phase_imag);
|
||||||
|
tmp_imag.val[1] = vmulq_f32(tmp32f.val[1], _phase_real);
|
||||||
|
|
||||||
|
tmp32f.val[0] = vsubq_f32(tmp_real.val[0], tmp_real.val[1]);
|
||||||
|
tmp32f.val[1] = vaddq_f32(tmp_imag.val[0], tmp_imag.val[1]);
|
||||||
|
|
||||||
|
/* downcast results to int32 */
|
||||||
|
/* in __aarch64__ we can do that with vcvtaq_s32_f32(ret1); vcvtaq_s32_f32(ret2); */
|
||||||
|
sign = vcvtq_f32_u32((vshrq_n_u32(vreinterpretq_u32_f32(tmp32f.val[0]), 31)));
|
||||||
|
PlusHalf = vaddq_f32(tmp32f.val[0], half);
|
||||||
|
Round = vsubq_f32(PlusHalf, sign);
|
||||||
|
tmp32i.val[0] = vcvtq_s32_f32(Round);
|
||||||
|
|
||||||
|
sign = vcvtq_f32_u32((vshrq_n_u32(vreinterpretq_u32_f32(tmp32f.val[1]), 31)));
|
||||||
|
PlusHalf = vaddq_f32(tmp32f.val[1], half);
|
||||||
|
Round = vsubq_f32(PlusHalf, sign);
|
||||||
|
tmp32i.val[1] = vcvtq_s32_f32(Round);
|
||||||
|
|
||||||
|
/* downcast results to int16 */
|
||||||
|
tmp16.val[0] = vqmovn_s32(tmp32i.val[0]);
|
||||||
|
tmp16.val[1] = vqmovn_s32(tmp32i.val[1]);
|
||||||
|
|
||||||
|
/* compute next four phases */
|
||||||
|
tmp_real.val[0] = vmulq_f32(_phase_real, _phase4_real);
|
||||||
|
tmp_real.val[1] = vmulq_f32(_phase_imag, _phase4_imag);
|
||||||
|
tmp_imag.val[0] = vmulq_f32(_phase_real, _phase4_imag);
|
||||||
|
tmp_imag.val[1] = vmulq_f32(_phase_imag, _phase4_real);
|
||||||
|
|
||||||
|
_phase_real = vsubq_f32(tmp_real.val[0], tmp_real.val[1]);
|
||||||
|
_phase_imag = vaddq_f32(tmp_imag.val[0], tmp_imag.val[1]);
|
||||||
|
|
||||||
|
for (int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||||
|
{
|
||||||
|
a_val = vld2_s16((int16_t*)&(_in_a[n_vec][number*4])); //load (2 byte imag, 2 byte real) x 4 into 128 bits reg
|
||||||
|
|
||||||
|
// multiply the real*real and imag*imag to get real result
|
||||||
|
// a0r*b0r|a1r*b1r|a2r*b2r|a3r*b3r
|
||||||
|
tmp_real16.val[0] = vmul_s16(a_val.val[0], tmp16.val[0]);
|
||||||
|
// a0i*b0i|a1i*b1i|a2i*b2i|a3i*b3i
|
||||||
|
tmp_real16.val[1] = vmul_s16(a_val.val[1], tmp16.val[1]);
|
||||||
|
|
||||||
|
// Multiply cross terms to get the imaginary result
|
||||||
|
// a0r*b0i|a1r*b1i|a2r*b2i|a3r*b3i
|
||||||
|
tmp_imag16.val[0] = vmul_s16(a_val.val[0], tmp16.val[1]);
|
||||||
|
// a0i*b0r|a1i*b1r|a2i*b2r|a3i*b3r
|
||||||
|
tmp_imag16.val[1] = vmul_s16(a_val.val[1], tmp16.val[0]);
|
||||||
|
|
||||||
|
c_val.val[0] = vsub_s16(tmp_real16.val[0], tmp_real16.val[1]);
|
||||||
|
c_val.val[1] = vadd_s16(tmp_imag16.val[0], tmp_imag16.val[1]);
|
||||||
|
|
||||||
|
accumulator[n_vec].val[0] = vadd_s16(accumulator[n_vec].val[0], c_val.val[0]);
|
||||||
|
accumulator[n_vec].val[1] = vadd_s16(accumulator[n_vec].val[1], c_val.val[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||||
|
{
|
||||||
|
vst2_s16((int16_t*)dotProductVector, accumulator[n_vec]); // Store the results back into the dot product vector
|
||||||
|
dotProduct = lv_cmake(0,0);
|
||||||
|
for (int i = 0; i < 4; ++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;
|
||||||
|
}
|
||||||
|
free(accumulator);
|
||||||
|
vst1q_f32((float32_t*)__phase_real, _phase_real);
|
||||||
|
vst1q_f32((float32_t*)__phase_imag, _phase_imag);
|
||||||
|
|
||||||
|
(*phase) = lv_cmake((float32_t)__phase_real[0], (float32_t)__phase_imag[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int n = neon_iters * 4; n < num_points; n++)
|
||||||
|
{
|
||||||
|
tmp16_ = *_in_common++;
|
||||||
|
tmp32_ = lv_cmake((float32_t)lv_creal(tmp16_), (float32_t)lv_cimag(tmp16_)) * (*phase);
|
||||||
|
tmp16_ = lv_cmake((int16_t)rintf(lv_creal(tmp32_)), (int16_t)rintf(lv_cimag(tmp32_)));
|
||||||
|
(*phase) *= phase_inc;
|
||||||
|
for (int n_vec = 0; n_vec < num_a_vectors; n_vec++)
|
||||||
|
{
|
||||||
|
tmp = tmp16_ * _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_NEON */
|
||||||
|
|
||||||
#endif /*INCLUDED_volk_gnsssdr_16ic_xn_dot_prod_16ic_xn_H*/
|
#endif /*INCLUDED_volk_gnsssdr_16ic_xn_dot_prod_16ic_xn_H*/
|
||||||
|
@ -57,9 +57,8 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_generic(lv_
|
|||||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
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());
|
in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment());
|
||||||
memcpy(in_a[n], in, sizeof(lv_16sc_t) * num_points);
|
memcpy((lv_16sc_t*)in_a[n], (lv_16sc_t*)in, sizeof(lv_16sc_t) * num_points);
|
||||||
}
|
}
|
||||||
result = (lv_16sc_t*)calloc(num_points, sizeof(lv_16sc_t));
|
|
||||||
volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_generic(result, local_code, phase_inc[0], phase,(const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_generic(result, local_code, phase_inc[0], phase,(const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
||||||
|
|
||||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
for(unsigned int n = 0; n < num_a_vectors; n++)
|
||||||
@ -89,7 +88,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_a_sse3(lv_1
|
|||||||
in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment());
|
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);
|
memcpy((lv_16sc_t*)in_a[n], (lv_16sc_t*)in, sizeof(lv_16sc_t) * num_points);
|
||||||
}
|
}
|
||||||
result = (lv_16sc_t*)calloc(num_points, sizeof(lv_16sc_t));
|
|
||||||
volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_a_sse3(result, local_code, phase_inc[0], phase, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_a_sse3(result, local_code, phase_inc[0], phase, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
||||||
|
|
||||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
for(unsigned int n = 0; n < num_a_vectors; n++)
|
||||||
@ -120,7 +119,7 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_u_sse3(lv_1
|
|||||||
in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment());
|
in_a[n] = (lv_16sc_t*)volk_gnsssdr_malloc(sizeof(lv_16sc_t) * num_points, volk_gnsssdr_get_alignment());
|
||||||
memcpy(in_a[n], in, sizeof(lv_16sc_t) * num_points);
|
memcpy(in_a[n], in, sizeof(lv_16sc_t) * num_points);
|
||||||
}
|
}
|
||||||
result = (lv_16sc_t*)calloc(num_points, sizeof(lv_16sc_t));
|
|
||||||
volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_u_sse3(result, local_code, phase_inc[0], phase, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn_u_sse3(result, local_code, phase_inc[0], phase, (const lv_16sc_t**) in_a, num_a_vectors, num_points);
|
||||||
|
|
||||||
for(unsigned int n = 0; n < num_a_vectors; n++)
|
for(unsigned int n = 0; n < num_a_vectors; n++)
|
||||||
@ -132,6 +131,37 @@ static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_u_sse3(lv_1
|
|||||||
|
|
||||||
#endif // SSE3
|
#endif // SSE3
|
||||||
|
|
||||||
|
#ifdef LV_HAVE_NEON
|
||||||
|
|
||||||
|
static inline void volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_neon(lv_16sc_t* result, const lv_16sc_t* local_code, const lv_16sc_t* in, unsigned int num_points)
|
||||||
|
{
|
||||||
|
// phases must be normalized. Phase rotator expects a complex exponential input!
|
||||||
|
float rem_carrier_phase_in_rad = 0.345;
|
||||||
|
float phase_step_rad = 0.123;
|
||||||
|
lv_32fc_t phase[1];
|
||||||
|
phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), -sin(rem_carrier_phase_in_rad));
|
||||||
|
lv_32fc_t phase_inc[1];
|
||||||
|
phase_inc[0] = lv_cmake(cos(phase_step_rad), -sin(phase_step_rad));
|
||||||
|
|
||||||
|
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_rotator_dot_prod_16ic_xn_neon(result, local_code, phase_inc[0], phase, (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 // NEON
|
||||||
|
|
||||||
#endif // INCLUDED_volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_H
|
#endif // INCLUDED_volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic_H
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,10 +76,8 @@ void load_random_data(void *data, volk_gnsssdr_type_t type, unsigned int n)
|
|||||||
else ((uint32_t *)data)[i] = (uint32_t) scaled_rand;
|
else ((uint32_t *)data)[i] = (uint32_t) scaled_rand;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// 16 bits dot product saturates very fast even with moderate length vectors
|
if(type.is_signed) ((int16_t *)data)[i] = (int16_t) scaled_rand % 1;
|
||||||
// we produce here only 4 bits input range
|
else ((uint16_t *)data)[i] = (uint16_t) scaled_rand % 1;
|
||||||
if(type.is_signed) ((int16_t *)data)[i] = (int16_t)((int16_t) scaled_rand % 16);
|
|
||||||
else ((uint16_t *)data)[i] = (uint16_t) (int16_t)((int16_t) scaled_rand % 16);
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if(type.is_signed) ((int8_t *)data)[i] = (int8_t) scaled_rand;
|
if(type.is_signed) ((int8_t *)data)[i] = (int8_t) scaled_rand;
|
||||||
|
Loading…
Reference in New Issue
Block a user