GNU Radio 3.4.0 C++ API
|
00001 #ifndef INCLUDED_volk_32f_s32f_convert_32i_u_H 00002 #define INCLUDED_volk_32f_s32f_convert_32i_u_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 \note Input buffer does NOT need to be properly aligned 00016 */ 00017 static inline void volk_32f_s32f_convert_32i_u_sse2(int32_t* outputVector, const float* inputVector, const float scalar, unsigned int num_points){ 00018 unsigned int number = 0; 00019 00020 const unsigned int quarterPoints = num_points / 4; 00021 00022 const float* inputVectorPtr = (const float*)inputVector; 00023 int32_t* outputVectorPtr = outputVector; 00024 __m128 vScalar = _mm_set_ps1(scalar); 00025 __m128 inputVal1; 00026 __m128i intInputVal1; 00027 00028 for(;number < quarterPoints; number++){ 00029 inputVal1 = _mm_loadu_ps(inputVectorPtr); inputVectorPtr += 4; 00030 00031 intInputVal1 = _mm_cvtps_epi32(_mm_mul_ps(inputVal1, vScalar)); 00032 00033 _mm_storeu_si128((__m128i*)outputVectorPtr, intInputVal1); 00034 outputVectorPtr += 4; 00035 } 00036 00037 number = quarterPoints * 4; 00038 for(; number < num_points; number++){ 00039 outputVector[number] = (int32_t)(inputVector[number] * scalar); 00040 } 00041 } 00042 #endif /* LV_HAVE_SSE2 */ 00043 00044 #if LV_HAVE_SSE 00045 #include <xmmintrin.h> 00046 /*! 00047 \brief Multiplies each point in the input buffer by the scalar value, then converts the result into a 32 bit integer value 00048 \param inputVector The floating point input data buffer 00049 \param outputVector The 32 bit output data buffer 00050 \param scalar The value multiplied against each point in the input buffer 00051 \param num_points The number of data values to be converted 00052 \note Input buffer does NOT need to be properly aligned 00053 */ 00054 static inline void volk_32f_s32f_convert_32i_u_sse(int32_t* outputVector, const float* inputVector, const float scalar, unsigned int num_points){ 00055 unsigned int number = 0; 00056 00057 const unsigned int quarterPoints = num_points / 4; 00058 00059 const float* inputVectorPtr = (const float*)inputVector; 00060 int32_t* outputVectorPtr = outputVector; 00061 __m128 vScalar = _mm_set_ps1(scalar); 00062 __m128 ret; 00063 00064 float outputFloatBuffer[4] __attribute__((aligned(128))); 00065 00066 for(;number < quarterPoints; number++){ 00067 ret = _mm_loadu_ps(inputVectorPtr); 00068 inputVectorPtr += 4; 00069 00070 ret = _mm_mul_ps(ret, vScalar); 00071 00072 _mm_store_ps(outputFloatBuffer, ret); 00073 *outputVectorPtr++ = (int32_t)(outputFloatBuffer[0]); 00074 *outputVectorPtr++ = (int32_t)(outputFloatBuffer[1]); 00075 *outputVectorPtr++ = (int32_t)(outputFloatBuffer[2]); 00076 *outputVectorPtr++ = (int32_t)(outputFloatBuffer[3]); 00077 } 00078 00079 number = quarterPoints * 4; 00080 for(; number < num_points; number++){ 00081 outputVector[number] = (int32_t)(inputVector[number] * scalar); 00082 } 00083 } 00084 #endif /* LV_HAVE_SSE */ 00085 00086 #ifdef LV_HAVE_GENERIC 00087 /*! 00088 \brief Multiplies each point in the input buffer by the scalar value, then converts the result into a 32 bit integer value 00089 \param inputVector The floating point input data buffer 00090 \param outputVector The 32 bit output data buffer 00091 \param scalar The value multiplied against each point in the input buffer 00092 \param num_points The number of data values to be converted 00093 \note Input buffer does NOT need to be properly aligned 00094 */ 00095 static inline void volk_32f_s32f_convert_32i_u_generic(int32_t* outputVector, const float* inputVector, const float scalar, unsigned int num_points){ 00096 int32_t* outputVectorPtr = outputVector; 00097 const float* inputVectorPtr = inputVector; 00098 unsigned int number = 0; 00099 00100 for(number = 0; number < num_points; number++){ 00101 *outputVectorPtr++ = ((int32_t)(*inputVectorPtr++ * scalar)); 00102 } 00103 } 00104 #endif /* LV_HAVE_GENERIC */ 00105 00106 00107 00108 00109 #endif /* INCLUDED_volk_32f_s32f_convert_32i_u_H */