1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 20:20:35 +00:00

Add NEON protokernel to volk_gnsssdr_32f_index_max_32u kernel

This commit is contained in:
Carles Fernandez 2016-09-22 20:05:48 +02:00
parent 8ba309d92d
commit 2b5ac76f8a

View File

@ -86,13 +86,9 @@ static inline void volk_gnsssdr_32f_index_max_32u_a_avx(uint32_t* target, const
for(;number < quarterPoints; number++)
{
currentValues = _mm256_load_ps(inputPtr); inputPtr += 8;
currentIndexes = _mm256_add_ps(currentIndexes, indexIncrementValues);
//compareResults = _mm_cmpgt_ps(maxValues, currentValues);
compareResults = _mm256_cmp_ps(maxValues, currentValues, 0x1e);
maxValuesIndex = _mm256_blendv_ps(currentIndexes, maxValuesIndex, compareResults);
maxValues = _mm256_blendv_ps(currentValues, maxValues, compareResults);
}
@ -153,13 +149,9 @@ static inline void volk_gnsssdr_32f_index_max_32u_u_avx(uint32_t* target, const
for(;number < quarterPoints; number++)
{
currentValues = _mm256_loadu_ps(inputPtr); inputPtr += 8;
currentIndexes = _mm256_add_ps(currentIndexes, indexIncrementValues);
//compareResults = _mm_cmpgt_ps(maxValues, currentValues);
compareResults = _mm256_cmp_ps(maxValues, currentValues, 0x1e);
maxValuesIndex = _mm256_blendv_ps(currentIndexes, maxValuesIndex, compareResults);
maxValues = _mm256_blendv_ps(currentValues, maxValues, compareResults);
}
@ -223,9 +215,7 @@ static inline void volk_gnsssdr_32f_index_max_32u_a_sse4_1(uint32_t* target, con
currentValues = _mm_load_ps(inputPtr); inputPtr += 4;
currentIndexes = _mm_add_ps(currentIndexes, indexIncrementValues);
compareResults = _mm_cmpgt_ps(maxValues, currentValues);
maxValuesIndex = _mm_blendv_ps(currentIndexes, maxValuesIndex, compareResults);
maxValues = _mm_blendv_ps(currentValues, maxValues, compareResults);
}
@ -286,12 +276,9 @@ static inline void volk_gnsssdr_32f_index_max_32u_u_sse4_1(uint32_t* target, con
for(;number < quarterPoints; number++)
{
currentValues = _mm_loadu_ps(inputPtr); inputPtr += 4;
currentIndexes = _mm_add_ps(currentIndexes, indexIncrementValues);
compareResults = _mm_cmpgt_ps(maxValues, currentValues);
maxValuesIndex = _mm_blendv_ps(currentIndexes, maxValuesIndex, compareResults);
maxValues = _mm_blendv_ps(currentValues, maxValues, compareResults);
}
@ -355,11 +342,8 @@ static inline void volk_gnsssdr_32f_index_max_32u_a_sse(uint32_t* target, const
{
currentValues = _mm_load_ps(inputPtr); inputPtr += 4;
currentIndexes = _mm_add_ps(currentIndexes, indexIncrementValues);
compareResults = _mm_cmpgt_ps(maxValues, currentValues);
maxValuesIndex = _mm_or_ps(_mm_and_ps(compareResults, maxValuesIndex) , _mm_andnot_ps(compareResults, currentIndexes));
maxValues = _mm_or_ps(_mm_and_ps(compareResults, maxValues) , _mm_andnot_ps(compareResults, currentValues));
}
@ -422,11 +406,8 @@ static inline void volk_gnsssdr_32f_index_max_32u_u_sse(uint32_t* target, const
{
currentValues = _mm_loadu_ps(inputPtr); inputPtr += 4;
currentIndexes = _mm_add_ps(currentIndexes, indexIncrementValues);
compareResults = _mm_cmpgt_ps(maxValues, currentValues);
maxValuesIndex = _mm_or_ps(_mm_and_ps(compareResults, maxValuesIndex) , _mm_andnot_ps(compareResults, currentIndexes));
maxValues = _mm_or_ps(_mm_and_ps(compareResults, maxValues) , _mm_andnot_ps(compareResults, currentValues));
}
@ -485,4 +466,68 @@ static inline void volk_gnsssdr_32f_index_max_32u_generic(uint32_t* target, cons
#endif /*LV_HAVE_GENERIC*/
#ifdef LV_HAVE_NEON
#include <arm_neon.h>
static inline void volk_gnsssdr_32f_index_max_32u_neon(uint32_t* target, const float* src0, uint32_t num_points)
{
if(num_points > 0)
{
uint32_t number = 0;
const uint32_t quarterPoints = num_points / 4;
float* inputPtr = (float*)src0;
float32x4_t indexIncrementValues = vdupq_n_f32(4);
__VOLK_ATTR_ALIGNED(16) float currentIndexes_float[4] = { -4.0f, -3.0f, -2.0f, -1.0f };
float32x4_t currentIndexes = vld1q_f32(currentIndexes_float);
float max = src0[0];
float index = 0;
float32x4_t maxValues = vdupq_n_f32(max);
uint32x4_t maxValuesIndex = vmovq_n_u32(0);
uint32x4_t compareResults;
uint32x4_t currentIndexes_u;
float32x4_t currentValues;
__VOLK_ATTR_ALIGNED(16) float maxValuesBuffer[4];
__VOLK_ATTR_ALIGNED(16) float maxIndexesBuffer[4];
for(;number < quarterPoints; number++)
{
currentValues = vld1q_f32(inputPtr); inputPtr += 4;
currentIndexes = vaddq_f32(currentIndexes, indexIncrementValues);
currentIndexes_u = vcvtq_u32_f32(currentIndexes);
compareResults = vcgtq_f32( maxValues, currentValues);
maxValuesIndex = vorrq_u32( vandq_u32( compareResults, maxValuesIndex ), vbicq_u32(currentIndexes_u, compareResults) );
maxValues = vmaxq_f32(currentValues, maxValues);
}
// Calculate the largest value from the remaining 4 points
vst1q_f32(maxValuesBuffer, maxValues);
vst1q_f32(maxIndexesBuffer, vcvtq_f32_u32(maxValuesIndex));
for(number = 0; number < 4; number++)
{
if(maxValuesBuffer[number] > max)
{
index = maxIndexesBuffer[number];
max = maxValuesBuffer[number];
}
}
number = quarterPoints * 4;
for(;number < num_points; number++)
{
if(src0[number] > max)
{
index = number;
max = src0[number];
}
}
target[0] = (uint32_t)index;
}
}
#endif /*LV_HAVE_NEON*/
#endif /*INCLUDED_volk_gnsssdr_32f_index_max_32u_H*/