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