1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
#ifndef INCLUDED_VOLK_8sc_DEINTERLEAVE_32F_ALIGNED16_H
#define INCLUDED_VOLK_8sc_DEINTERLEAVE_32F_ALIGNED16_H
#include <inttypes.h>
#include <stdio.h>
#if LV_HAVE_SSE4_1
#include <smmintrin.h>
/*!
\brief Deinterleaves the complex 8 bit vector into I & Q floating point vector data
\param complexVector The complex input vector
\param iBuffer The I buffer output data
\param qBuffer The Q buffer output data
\param scalar The scaling value being multiplied against each data point
\param num_points The number of complex data values to be deinterleaved
*/
static inline void volk_8sc_deinterleave_32f_aligned16_sse4_1(float* iBuffer, float* qBuffer, const lv_8sc_t* complexVector, const float scalar, unsigned int num_points){
float* iBufferPtr = iBuffer;
float* qBufferPtr = qBuffer;
unsigned int number = 0;
const unsigned int eighthPoints = num_points / 8;
__m128 iFloatValue, qFloatValue;
const float iScalar= 1.0 / scalar;
__m128 invScalar = _mm_set_ps1(iScalar);
__m128i complexVal, iIntVal, qIntVal, iComplexVal, qComplexVal;
int8_t* complexVectorPtr = (int8_t*)complexVector;
__m128i iMoveMask = _mm_set_epi8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 14, 12, 10, 8, 6, 4, 2, 0);
__m128i qMoveMask = _mm_set_epi8(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 15, 13, 11, 9, 7, 5, 3, 1);
for(;number < eighthPoints; number++){
complexVal = _mm_load_si128((__m128i*)complexVectorPtr); complexVectorPtr += 16;
iComplexVal = _mm_shuffle_epi8(complexVal, iMoveMask);
qComplexVal = _mm_shuffle_epi8(complexVal, qMoveMask);
iIntVal = _mm_cvtepi8_epi32(iComplexVal);
iFloatValue = _mm_cvtepi32_ps(iIntVal);
iFloatValue = _mm_mul_ps(iFloatValue, invScalar);
_mm_store_ps(iBufferPtr, iFloatValue);
iBufferPtr += 4;
iComplexVal = _mm_srli_si128(iComplexVal, 4);
iIntVal = _mm_cvtepi8_epi32(iComplexVal);
iFloatValue = _mm_cvtepi32_ps(iIntVal);
iFloatValue = _mm_mul_ps(iFloatValue, invScalar);
_mm_store_ps(iBufferPtr, iFloatValue);
iBufferPtr += 4;
qIntVal = _mm_cvtepi8_epi32(qComplexVal);
qFloatValue = _mm_cvtepi32_ps(qIntVal);
qFloatValue = _mm_mul_ps(qFloatValue, invScalar);
_mm_store_ps(qBufferPtr, qFloatValue);
qBufferPtr += 4;
qComplexVal = _mm_srli_si128(qComplexVal, 4);
qIntVal = _mm_cvtepi8_epi32(qComplexVal);
qFloatValue = _mm_cvtepi32_ps(qIntVal);
qFloatValue = _mm_mul_ps(qFloatValue, invScalar);
_mm_store_ps(qBufferPtr, qFloatValue);
qBufferPtr += 4;
}
number = eighthPoints * 8;
for(; number < num_points; number++){
*iBufferPtr++ = (float)(*complexVectorPtr++) * iScalar;
*qBufferPtr++ = (float)(*complexVectorPtr++) * iScalar;
}
}
#endif /* LV_HAVE_SSE4_1 */
#if LV_HAVE_SSE
#include <xmmintrin.h>
/*!
\brief Deinterleaves the complex 8 bit vector into I & Q floating point vector data
\param complexVector The complex input vector
\param iBuffer The I buffer output data
\param qBuffer The Q buffer output data
\param scalar The scaling value being multiplied against each data point
\param num_points The number of complex data values to be deinterleaved
*/
static inline void volk_8sc_deinterleave_32f_aligned16_sse(float* iBuffer, float* qBuffer, const lv_8sc_t* complexVector, const float scalar, unsigned int num_points){
float* iBufferPtr = iBuffer;
float* qBufferPtr = qBuffer;
unsigned int number = 0;
const unsigned int quarterPoints = num_points / 4;
__m128 cplxValue1, cplxValue2, iValue, qValue;
__m128 invScalar = _mm_set_ps1(1.0/scalar);
int8_t* complexVectorPtr = (int8_t*)complexVector;
float floatBuffer[8] __attribute__((aligned(128)));
for(;number < quarterPoints; number++){
floatBuffer[0] = (float)(complexVectorPtr[0]);
floatBuffer[1] = (float)(complexVectorPtr[1]);
floatBuffer[2] = (float)(complexVectorPtr[2]);
floatBuffer[3] = (float)(complexVectorPtr[3]);
floatBuffer[4] = (float)(complexVectorPtr[4]);
floatBuffer[5] = (float)(complexVectorPtr[5]);
floatBuffer[6] = (float)(complexVectorPtr[6]);
floatBuffer[7] = (float)(complexVectorPtr[7]);
cplxValue1 = _mm_load_ps(&floatBuffer[0]);
cplxValue2 = _mm_load_ps(&floatBuffer[4]);
complexVectorPtr += 8;
cplxValue1 = _mm_mul_ps(cplxValue1, invScalar);
cplxValue2 = _mm_mul_ps(cplxValue2, invScalar);
// Arrange in i1i2i3i4 format
iValue = _mm_shuffle_ps(cplxValue1, cplxValue2, _MM_SHUFFLE(2,0,2,0));
qValue = _mm_shuffle_ps(cplxValue1, cplxValue2, _MM_SHUFFLE(3,1,3,1));
_mm_store_ps(iBufferPtr, iValue);
_mm_store_ps(qBufferPtr, qValue);
iBufferPtr += 4;
qBufferPtr += 4;
}
number = quarterPoints * 4;
complexVectorPtr = (int8_t*)&complexVector[number];
for(; number < num_points; number++){
*iBufferPtr++ = (float)(*complexVectorPtr++) / scalar;
*qBufferPtr++ = (float)(*complexVectorPtr++) / scalar;
}
}
#endif /* LV_HAVE_SSE */
#if LV_HAVE_GENERIC
/*!
\brief Deinterleaves the complex 8 bit vector into I & Q floating point vector data
\param complexVector The complex input vector
\param iBuffer The I buffer output data
\param qBuffer The Q buffer output data
\param scalar The scaling value being multiplied against each data point
\param num_points The number of complex data values to be deinterleaved
*/
static inline void volk_8sc_deinterleave_32f_aligned16_generic(float* iBuffer, float* qBuffer, const lv_8sc_t* complexVector, const float scalar, unsigned int num_points){
const int8_t* complexVectorPtr = (const int8_t*)complexVector;
float* iBufferPtr = iBuffer;
float* qBufferPtr = qBuffer;
unsigned int number;
const float invScalar = 1.0 / scalar;
for(number = 0; number < num_points; number++){
*iBufferPtr++ = (float)(*complexVectorPtr++)*invScalar;
*qBufferPtr++ = (float)(*complexVectorPtr++)*invScalar;
}
}
#endif /* LV_HAVE_GENERIC */
#endif /* INCLUDED_VOLK_8sc_DEINTERLEAVE_32F_ALIGNED16_H */
|