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