GNU Radio 3.6.4.2 C++ API
|
00001 #ifndef INCLUDED_volk_16i_s32f_convert_32f_u_H 00002 #define INCLUDED_volk_16i_s32f_convert_32f_u_H 00003 00004 #include <inttypes.h> 00005 #include <stdio.h> 00006 00007 #ifdef LV_HAVE_SSE4_1 00008 #include <smmintrin.h> 00009 00010 /*! 00011 \brief Converts the input 16 bit integer data into floating point data, and divides the each floating point output data point by the scalar value 00012 \param inputVector The 16 bit input data buffer 00013 \param outputVector The floating point output data buffer 00014 \param scalar The value divided against each point in the output buffer 00015 \param num_points The number of data values to be converted 00016 \note Output buffer does NOT need to be properly aligned 00017 */ 00018 static inline void volk_16i_s32f_convert_32f_u_sse4_1(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){ 00019 unsigned int number = 0; 00020 const unsigned int eighthPoints = num_points / 8; 00021 00022 float* outputVectorPtr = outputVector; 00023 __m128 invScalar = _mm_set_ps1(1.0/scalar); 00024 int16_t* inputPtr = (int16_t*)inputVector; 00025 __m128i inputVal; 00026 __m128i inputVal2; 00027 __m128 ret; 00028 00029 for(;number < eighthPoints; number++){ 00030 00031 // Load the 8 values 00032 inputVal = _mm_loadu_si128((__m128i*)inputPtr); 00033 00034 // Shift the input data to the right by 64 bits ( 8 bytes ) 00035 inputVal2 = _mm_srli_si128(inputVal, 8); 00036 00037 // Convert the lower 4 values into 32 bit words 00038 inputVal = _mm_cvtepi16_epi32(inputVal); 00039 inputVal2 = _mm_cvtepi16_epi32(inputVal2); 00040 00041 ret = _mm_cvtepi32_ps(inputVal); 00042 ret = _mm_mul_ps(ret, invScalar); 00043 _mm_storeu_ps(outputVectorPtr, ret); 00044 outputVectorPtr += 4; 00045 00046 ret = _mm_cvtepi32_ps(inputVal2); 00047 ret = _mm_mul_ps(ret, invScalar); 00048 _mm_storeu_ps(outputVectorPtr, ret); 00049 00050 outputVectorPtr += 4; 00051 00052 inputPtr += 8; 00053 } 00054 00055 number = eighthPoints * 8; 00056 for(; number < num_points; number++){ 00057 outputVector[number] =((float)(inputVector[number])) / scalar; 00058 } 00059 } 00060 #endif /* LV_HAVE_SSE4_1 */ 00061 00062 #ifdef LV_HAVE_SSE 00063 #include <xmmintrin.h> 00064 00065 /*! 00066 \brief Converts the input 16 bit integer data into floating point data, and divides the each floating point output data point by the scalar value 00067 \param inputVector The 16 bit input data buffer 00068 \param outputVector The floating point output data buffer 00069 \param scalar The value divided against each point in the output buffer 00070 \param num_points The number of data values to be converted 00071 \note Output buffer does NOT need to be properly aligned 00072 */ 00073 static inline void volk_16i_s32f_convert_32f_u_sse(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){ 00074 unsigned int number = 0; 00075 const unsigned int quarterPoints = num_points / 4; 00076 00077 float* outputVectorPtr = outputVector; 00078 __m128 invScalar = _mm_set_ps1(1.0/scalar); 00079 int16_t* inputPtr = (int16_t*)inputVector; 00080 __m128 ret; 00081 00082 for(;number < quarterPoints; number++){ 00083 ret = _mm_set_ps((float)(inputPtr[3]), (float)(inputPtr[2]), (float)(inputPtr[1]), (float)(inputPtr[0])); 00084 00085 ret = _mm_mul_ps(ret, invScalar); 00086 _mm_storeu_ps(outputVectorPtr, ret); 00087 00088 inputPtr += 4; 00089 outputVectorPtr += 4; 00090 } 00091 00092 number = quarterPoints * 4; 00093 for(; number < num_points; number++){ 00094 outputVector[number] = (float)(inputVector[number]) / scalar; 00095 } 00096 } 00097 #endif /* LV_HAVE_SSE */ 00098 00099 #ifdef LV_HAVE_GENERIC 00100 /*! 00101 \brief Converts the input 16 bit integer data into floating point data, and divides the each floating point output data point by the scalar value 00102 \param inputVector The 16 bit input data buffer 00103 \param outputVector The floating point output data buffer 00104 \param scalar The value divided against each point in the output buffer 00105 \param num_points The number of data values to be converted 00106 \note Output buffer does NOT need to be properly aligned 00107 */ 00108 static inline void volk_16i_s32f_convert_32f_generic(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){ 00109 float* outputVectorPtr = outputVector; 00110 const int16_t* inputVectorPtr = inputVector; 00111 unsigned int number = 0; 00112 00113 for(number = 0; number < num_points; number++){ 00114 *outputVectorPtr++ = ((float)(*inputVectorPtr++)) / scalar; 00115 } 00116 } 00117 #endif /* LV_HAVE_GENERIC */ 00118 00119 00120 00121 00122 #endif /* INCLUDED_volk_16i_s32f_convert_32f_u_H */ 00123 #ifndef INCLUDED_volk_16i_s32f_convert_32f_a_H 00124 #define INCLUDED_volk_16i_s32f_convert_32f_a_H 00125 00126 #include <inttypes.h> 00127 #include <stdio.h> 00128 00129 #ifdef LV_HAVE_SSE4_1 00130 #include <smmintrin.h> 00131 00132 /*! 00133 \brief Converts the input 16 bit integer data into floating point data, and divides the each floating point output data point by the scalar value 00134 \param inputVector The 16 bit input data buffer 00135 \param outputVector The floating point output data buffer 00136 \param scalar The value divided against each point in the output buffer 00137 \param num_points The number of data values to be converted 00138 */ 00139 static inline void volk_16i_s32f_convert_32f_a_sse4_1(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){ 00140 unsigned int number = 0; 00141 const unsigned int eighthPoints = num_points / 8; 00142 00143 float* outputVectorPtr = outputVector; 00144 __m128 invScalar = _mm_set_ps1(1.0/scalar); 00145 int16_t* inputPtr = (int16_t*)inputVector; 00146 __m128i inputVal; 00147 __m128i inputVal2; 00148 __m128 ret; 00149 00150 for(;number < eighthPoints; number++){ 00151 00152 // Load the 8 values 00153 inputVal = _mm_loadu_si128((__m128i*)inputPtr); 00154 00155 // Shift the input data to the right by 64 bits ( 8 bytes ) 00156 inputVal2 = _mm_srli_si128(inputVal, 8); 00157 00158 // Convert the lower 4 values into 32 bit words 00159 inputVal = _mm_cvtepi16_epi32(inputVal); 00160 inputVal2 = _mm_cvtepi16_epi32(inputVal2); 00161 00162 ret = _mm_cvtepi32_ps(inputVal); 00163 ret = _mm_mul_ps(ret, invScalar); 00164 _mm_storeu_ps(outputVectorPtr, ret); 00165 outputVectorPtr += 4; 00166 00167 ret = _mm_cvtepi32_ps(inputVal2); 00168 ret = _mm_mul_ps(ret, invScalar); 00169 _mm_storeu_ps(outputVectorPtr, ret); 00170 00171 outputVectorPtr += 4; 00172 00173 inputPtr += 8; 00174 } 00175 00176 number = eighthPoints * 8; 00177 for(; number < num_points; number++){ 00178 outputVector[number] =((float)(inputVector[number])) / scalar; 00179 } 00180 } 00181 #endif /* LV_HAVE_SSE4_1 */ 00182 00183 #ifdef LV_HAVE_SSE 00184 #include <xmmintrin.h> 00185 00186 /*! 00187 \brief Converts the input 16 bit integer data into floating point data, and divides the each floating point output data point by the scalar value 00188 \param inputVector The 16 bit input data buffer 00189 \param outputVector The floating point output data buffer 00190 \param scalar The value divided against each point in the output buffer 00191 \param num_points The number of data values to be converted 00192 */ 00193 static inline void volk_16i_s32f_convert_32f_a_sse(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){ 00194 unsigned int number = 0; 00195 const unsigned int quarterPoints = num_points / 4; 00196 00197 float* outputVectorPtr = outputVector; 00198 __m128 invScalar = _mm_set_ps1(1.0/scalar); 00199 int16_t* inputPtr = (int16_t*)inputVector; 00200 __m128 ret; 00201 00202 for(;number < quarterPoints; number++){ 00203 ret = _mm_set_ps((float)(inputPtr[3]), (float)(inputPtr[2]), (float)(inputPtr[1]), (float)(inputPtr[0])); 00204 00205 ret = _mm_mul_ps(ret, invScalar); 00206 _mm_storeu_ps(outputVectorPtr, ret); 00207 00208 inputPtr += 4; 00209 outputVectorPtr += 4; 00210 } 00211 00212 number = quarterPoints * 4; 00213 for(; number < num_points; number++){ 00214 outputVector[number] = (float)(inputVector[number]) / scalar; 00215 } 00216 } 00217 #endif /* LV_HAVE_SSE */ 00218 00219 #ifdef LV_HAVE_GENERIC 00220 /*! 00221 \brief Converts the input 16 bit integer data into floating point data, and divides the each floating point output data point by the scalar value 00222 \param inputVector The 16 bit input data buffer 00223 \param outputVector The floating point output data buffer 00224 \param scalar The value divided against each point in the output buffer 00225 \param num_points The number of data values to be converted 00226 */ 00227 static inline void volk_16i_s32f_convert_32f_a_generic(float* outputVector, const int16_t* inputVector, const float scalar, unsigned int num_points){ 00228 float* outputVectorPtr = outputVector; 00229 const int16_t* inputVectorPtr = inputVector; 00230 unsigned int number = 0; 00231 00232 for(number = 0; number < num_points; number++){ 00233 *outputVectorPtr++ = ((float)(*inputVectorPtr++)) / scalar; 00234 } 00235 } 00236 #endif /* LV_HAVE_GENERIC */ 00237 00238 00239 00240 00241 #endif /* INCLUDED_volk_16i_s32f_convert_32f_a_H */