GNU Radio 3.4.0 C++ API
volk_32f_s32f_convert_32i_a16.h
Go to the documentation of this file.
00001 #ifndef INCLUDED_volk_32f_s32f_convert_32i_a16_H
00002 #define INCLUDED_volk_32f_s32f_convert_32i_a16_H
00003 
00004 #include <inttypes.h>
00005 #include <stdio.h>
00006 
00007 #if LV_HAVE_SSE2
00008 #include <emmintrin.h>
00009   /*!
00010     \brief Multiplies each point in the input buffer by the scalar value, then converts the result into a 32 bit integer value
00011     \param inputVector The floating point input data buffer
00012     \param outputVector The 32 bit output data buffer
00013     \param scalar The value multiplied against each point in the input buffer
00014     \param num_points The number of data values to be converted
00015   */
00016 static inline void volk_32f_s32f_convert_32i_a16_sse2(int32_t* outputVector, const float* inputVector, const float scalar, unsigned int num_points){
00017   unsigned int number = 0;
00018 
00019   const unsigned int quarterPoints = num_points / 4;
00020     
00021   const float* inputVectorPtr = (const float*)inputVector;
00022   int32_t* outputVectorPtr = outputVector;
00023   __m128 vScalar = _mm_set_ps1(scalar);
00024   __m128 inputVal1;
00025   __m128i intInputVal1;
00026 
00027   for(;number < quarterPoints; number++){
00028     inputVal1 = _mm_load_ps(inputVectorPtr); inputVectorPtr += 4;
00029 
00030     intInputVal1 = _mm_cvtps_epi32(_mm_mul_ps(inputVal1, vScalar));
00031 
00032     _mm_store_si128((__m128i*)outputVectorPtr, intInputVal1);
00033     outputVectorPtr += 4;
00034   }
00035 
00036   number = quarterPoints * 4;    
00037   for(; number < num_points; number++){
00038     outputVector[number] = (int32_t)(inputVector[number] * scalar);
00039   }
00040 }
00041 #endif /* LV_HAVE_SSE2 */
00042 
00043 #if LV_HAVE_SSE
00044 #include <xmmintrin.h>
00045   /*!
00046     \brief Multiplies each point in the input buffer by the scalar value, then converts the result into a 32 bit integer value
00047     \param inputVector The floating point input data buffer
00048     \param outputVector The 32 bit output data buffer
00049     \param scalar The value multiplied against each point in the input buffer
00050     \param num_points The number of data values to be converted
00051   */
00052 static inline void volk_32f_s32f_convert_32i_a16_sse(int32_t* outputVector, const float* inputVector, const float scalar, unsigned int num_points){
00053   unsigned int number = 0;
00054 
00055   const unsigned int quarterPoints = num_points / 4;
00056     
00057   const float* inputVectorPtr = (const float*)inputVector;
00058   int32_t* outputVectorPtr = outputVector;
00059   __m128 vScalar = _mm_set_ps1(scalar);
00060   __m128 ret;
00061 
00062   float outputFloatBuffer[4] __attribute__((aligned(128)));
00063 
00064   for(;number < quarterPoints; number++){
00065     ret = _mm_load_ps(inputVectorPtr);
00066     inputVectorPtr += 4;
00067 
00068     ret = _mm_mul_ps(ret, vScalar);
00069 
00070     _mm_store_ps(outputFloatBuffer, ret);
00071     *outputVectorPtr++ = (int32_t)(outputFloatBuffer[0]);
00072     *outputVectorPtr++ = (int32_t)(outputFloatBuffer[1]);
00073     *outputVectorPtr++ = (int32_t)(outputFloatBuffer[2]);
00074     *outputVectorPtr++ = (int32_t)(outputFloatBuffer[3]);
00075   }
00076 
00077   number = quarterPoints * 4;    
00078   for(; number < num_points; number++){
00079     outputVector[number] = (int32_t)(inputVector[number] * scalar);
00080   }
00081 }
00082 #endif /* LV_HAVE_SSE */
00083 
00084 #ifdef LV_HAVE_GENERIC
00085   /*!
00086     \brief Multiplies each point in the input buffer by the scalar value, then converts the result into a 32 bit integer value
00087     \param inputVector The floating point input data buffer
00088     \param outputVector The 32 bit output data buffer
00089     \param scalar The value multiplied against each point in the input buffer
00090     \param num_points The number of data values to be converted
00091   */
00092 static inline void volk_32f_s32f_convert_32i_a16_generic(int32_t* outputVector, const float* inputVector, const float scalar, unsigned int num_points){
00093   int32_t* outputVectorPtr = outputVector;
00094   const float* inputVectorPtr = inputVector;
00095   unsigned int number = 0;
00096 
00097   for(number = 0; number < num_points; number++){
00098     *outputVectorPtr++ = ((int32_t)(*inputVectorPtr++  * scalar));
00099   }
00100 }
00101 #endif /* LV_HAVE_GENERIC */
00102 
00103 
00104 
00105 
00106 #endif /* INCLUDED_volk_32f_s32f_convert_32i_a16_H */