[hamradio-commits] [gnss-sdr] 32/303: Add AVX and unaligned protokernels

Carles Fernandez carles_fernandez-guest at moszumanska.debian.org
Mon Feb 13 22:35:45 UTC 2017


This is an automated email from the git hooks/post-receive script.

carles_fernandez-guest pushed a commit to branch master
in repository gnss-sdr.

commit 8ba309d92d1955204f1d6a2e634babef2f16fa79
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date:   Tue Sep 20 00:02:03 2016 +0200

    Add AVX and unaligned protokernels
---
 .../volk_gnsssdr/volk_gnsssdr_32f_index_max_32u.h  | 267 +++++++++++++++++++++
 1 file changed, 267 insertions(+)

diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_index_max_32u.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_index_max_32u.h
index 8ea27b9..56666d5 100644
--- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_index_max_32u.h
+++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32f_index_max_32u.h
@@ -59,6 +59,140 @@
 #include <inttypes.h>
 #include <stdio.h>
 
+#ifdef LV_HAVE_AVX
+#include <immintrin.h>
+
+static inline void volk_gnsssdr_32f_index_max_32u_a_avx(uint32_t* target, const float* src0, uint32_t num_points)
+{
+    if(num_points > 0)
+        {
+            uint32_t number = 0;
+            const uint32_t quarterPoints = num_points / 8;
+
+            float* inputPtr = (float*)src0;
+
+            __m256 indexIncrementValues = _mm256_set1_ps(8);
+            __m256 currentIndexes = _mm256_set_ps(-1,-2,-3,-4,-5,-6,-7,-8);
+
+            float max = src0[0];
+            float index = 0;
+            __m256 maxValues = _mm256_set1_ps(max);
+            __m256 maxValuesIndex = _mm256_setzero_ps();
+            __m256 compareResults;
+            __m256 currentValues;
+
+            __VOLK_ATTR_ALIGNED(32) float maxValuesBuffer[8];
+            __VOLK_ATTR_ALIGNED(32) float maxIndexesBuffer[8];
+
+            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);
+                }
+
+            // Calculate the largest value from the remaining 8 points
+            _mm256_store_ps(maxValuesBuffer, maxValues);
+            _mm256_store_ps(maxIndexesBuffer, maxValuesIndex);
+
+            for(number = 0; number < 8; number++)
+                {
+                    if(maxValuesBuffer[number] > max)
+                        {
+                            index = maxIndexesBuffer[number];
+                            max = maxValuesBuffer[number];
+                        }
+                }
+
+            number = quarterPoints * 8;
+            for(;number < num_points; number++)
+                {
+                    if(src0[number] > max)
+                        {
+                            index = number;
+                            max = src0[number];
+                        }
+                }
+            target[0] = (uint32_t)index;
+        }
+}
+
+#endif /*LV_HAVE_AVX*/
+
+
+#ifdef LV_HAVE_AVX
+#include <immintrin.h>
+
+static inline void volk_gnsssdr_32f_index_max_32u_u_avx(uint32_t* target, const float* src0, uint32_t num_points)
+{
+    if(num_points > 0)
+        {
+            uint32_t number = 0;
+            const uint32_t quarterPoints = num_points / 8;
+
+            float* inputPtr = (float*)src0;
+
+            __m256 indexIncrementValues = _mm256_set1_ps(8);
+            __m256 currentIndexes = _mm256_set_ps(-1,-2,-3,-4,-5,-6,-7,-8);
+
+            float max = src0[0];
+            float index = 0;
+            __m256 maxValues = _mm256_set1_ps(max);
+            __m256 maxValuesIndex = _mm256_setzero_ps();
+            __m256 compareResults;
+            __m256 currentValues;
+
+            __VOLK_ATTR_ALIGNED(32) float maxValuesBuffer[8];
+            __VOLK_ATTR_ALIGNED(32) float maxIndexesBuffer[8];
+
+            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);
+                }
+
+            // Calculate the largest value from the remaining 8 points
+            _mm256_store_ps(maxValuesBuffer, maxValues);
+            _mm256_store_ps(maxIndexesBuffer, maxValuesIndex);
+
+            for(number = 0; number < 8; number++)
+                {
+                    if(maxValuesBuffer[number] > max)
+                        {
+                            index = maxIndexesBuffer[number];
+                            max = maxValuesBuffer[number];
+                        }
+                }
+
+            number = quarterPoints * 8;
+            for(;number < num_points; number++)
+                {
+                    if(src0[number] > max)
+                        {
+                            index = number;
+                            max = src0[number];
+                        }
+                }
+            target[0] = (uint32_t)index;
+        }
+}
+
+#endif /*LV_HAVE_AVX*/
+
+
 #ifdef LV_HAVE_SSE4_1
 #include<smmintrin.h>
 
@@ -125,6 +259,72 @@ static inline void volk_gnsssdr_32f_index_max_32u_a_sse4_1(uint32_t* target, con
 #endif /*LV_HAVE_SSE4_1*/
 
 
+#ifdef LV_HAVE_SSE4_1
+#include<smmintrin.h>
+
+static inline void volk_gnsssdr_32f_index_max_32u_u_sse4_1(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;
+
+            __m128 indexIncrementValues = _mm_set1_ps(4);
+            __m128 currentIndexes = _mm_set_ps(-1,-2,-3,-4);
+
+            float max = src0[0];
+            float index = 0;
+            __m128 maxValues = _mm_set1_ps(max);
+            __m128 maxValuesIndex = _mm_setzero_ps();
+            __m128 compareResults;
+            __m128 currentValues;
+
+            __VOLK_ATTR_ALIGNED(16) float maxValuesBuffer[4];
+            __VOLK_ATTR_ALIGNED(16) float maxIndexesBuffer[4];
+
+            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);
+                }
+
+            // Calculate the largest value from the remaining 4 points
+            _mm_store_ps(maxValuesBuffer, maxValues);
+            _mm_store_ps(maxIndexesBuffer, 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_SSE4_1*/
+
+
 #ifdef LV_HAVE_SSE
 
 #include<xmmintrin.h>
@@ -192,6 +392,73 @@ static inline void volk_gnsssdr_32f_index_max_32u_a_sse(uint32_t* target, const
 #endif /*LV_HAVE_SSE*/
 
 
+#ifdef LV_HAVE_SSE
+
+#include<xmmintrin.h>
+
+static inline void volk_gnsssdr_32f_index_max_32u_u_sse(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;
+
+            __m128 indexIncrementValues = _mm_set1_ps(4);
+            __m128 currentIndexes = _mm_set_ps(-1,-2,-3,-4);
+
+            float max = src0[0];
+            float index = 0;
+            __m128 maxValues = _mm_set1_ps(max);
+            __m128 maxValuesIndex = _mm_setzero_ps();
+            __m128 compareResults;
+            __m128 currentValues;
+
+            __VOLK_ATTR_ALIGNED(16) float maxValuesBuffer[4];
+            __VOLK_ATTR_ALIGNED(16) float maxIndexesBuffer[4];
+
+            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_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));
+                }
+
+            // Calculate the largest value from the remaining 4 points
+            _mm_store_ps(maxValuesBuffer, maxValues);
+            _mm_store_ps(maxIndexesBuffer, 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_SSE*/
+
+
 #ifdef LV_HAVE_GENERIC
 
 static inline void volk_gnsssdr_32f_index_max_32u_generic(uint32_t* target, const float* src0, uint32_t num_points)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git



More information about the pkg-hamradio-commits mailing list