GNU Radio 3.6.5 C++ API
|
00001 #ifndef INCLUDED_volk_32f_accumulator_s32f_a_H 00002 #define INCLUDED_volk_32f_accumulator_s32f_a_H 00003 00004 #include <volk/volk_common.h> 00005 #include <inttypes.h> 00006 #include <stdio.h> 00007 00008 #ifdef LV_HAVE_SSE 00009 #include <xmmintrin.h> 00010 /*! 00011 \brief Accumulates the values in the input buffer 00012 \param result The accumulated result 00013 \param inputBuffer The buffer of data to be accumulated 00014 \param num_points The number of values in inputBuffer to be accumulated 00015 */ 00016 static inline void volk_32f_accumulator_s32f_a_sse(float* result, const float* inputBuffer, unsigned int num_points){ 00017 float returnValue = 0; 00018 unsigned int number = 0; 00019 const unsigned int quarterPoints = num_points / 4; 00020 00021 const float* aPtr = inputBuffer; 00022 __VOLK_ATTR_ALIGNED(16) float tempBuffer[4]; 00023 00024 __m128 accumulator = _mm_setzero_ps(); 00025 __m128 aVal = _mm_setzero_ps(); 00026 00027 for(;number < quarterPoints; number++){ 00028 aVal = _mm_load_ps(aPtr); 00029 accumulator = _mm_add_ps(accumulator, aVal); 00030 aPtr += 4; 00031 } 00032 _mm_store_ps(tempBuffer,accumulator); // Store the results back into the C container 00033 returnValue = tempBuffer[0]; 00034 returnValue += tempBuffer[1]; 00035 returnValue += tempBuffer[2]; 00036 returnValue += tempBuffer[3]; 00037 00038 number = quarterPoints * 4; 00039 for(;number < num_points; number++){ 00040 returnValue += (*aPtr++); 00041 } 00042 *result = returnValue; 00043 } 00044 #endif /* LV_HAVE_SSE */ 00045 00046 #ifdef LV_HAVE_GENERIC 00047 /*! 00048 \brief Accumulates the values in the input buffer 00049 \param result The accumulated result 00050 \param inputBuffer The buffer of data to be accumulated 00051 \param num_points The number of values in inputBuffer to be accumulated 00052 */ 00053 static inline void volk_32f_accumulator_s32f_a_generic(float* result, const float* inputBuffer, unsigned int num_points){ 00054 const float* aPtr = inputBuffer; 00055 unsigned int number = 0; 00056 float returnValue = 0; 00057 00058 for(;number < num_points; number++){ 00059 returnValue += (*aPtr++); 00060 } 00061 *result = returnValue; 00062 } 00063 #endif /* LV_HAVE_GENERIC */ 00064 00065 00066 00067 00068 #endif /* INCLUDED_volk_32f_accumulator_s32f_a_H */