1 /******************************************************************************
3 * Copyright (c) 2020 Intel.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 *******************************************************************************/
21 #include <immintrin.h>
23 // This configuration file sets global constants and macros which are
24 // of general use throughout the project.
26 // All current IA processors of interest align their cache lines on
27 // this boundary. If the cache alignment for future processors changes
28 // then the most restrictive alignment should be set.
29 constexpr unsigned k_cacheByteAlignment = 64;
31 // Force the data to which this macro is applied to be aligned on a cache line.
34 // CACHE_ALIGNED float data[64];
35 #define CACHE_ALIGNED alignas(k_cacheByteAlignment)
37 // Hint to the compiler that the data to which this macro is applied
38 // can be assumed to be aligned to a cache line. This allows the
39 // compiler to generate improved code by using aligned reads and
41 #define ASSUME_CACHE_ALIGNED(data)
42 // __assume_aligned(data, k_cacheByteAlignment);
44 /// Intel compiler frequently complains about templates not being declared in an external
45 /// header. Templates are used throughout this project's source files to define local type-specific
46 /// versions of functions. Defining every one of these in a header is unnecessary, so the warnings
47 /// about this are turned off globally.
48 #pragma warning(disable:1418)
49 #pragma warning(disable:1419)
52 namespace BlockFloatCompander
54 /// Compute 32 RB at a time
55 static constexpr int k_numBitsIQ = 16;
56 static constexpr int k_numBitsIQPair = 2 * k_numBitsIQ;
57 static constexpr int k_maxNumBlocks = 16;
58 static constexpr int k_maxNumElements = 128;
59 static constexpr int k_numSampsExpanded = k_maxNumBlocks * k_maxNumElements;
60 static constexpr int k_numSampsCompressed = (k_numSampsExpanded * 2) + k_maxNumBlocks;
64 /// Pointer to compressed data buffer
65 CACHE_ALIGNED uint8_t dataCompressedDataOut[k_numSampsCompressed];
66 CACHE_ALIGNED uint8_t *dataCompressed;
67 /// Size of mantissa including sign bit
70 /// Number of BFP blocks in message
73 /// Number of data elements per compression block (only required for reference function)
79 /// Pointer to expanded data buffer
80 CACHE_ALIGNED int16_t dataExpandedIn[k_numSampsExpanded];
81 CACHE_ALIGNED int16_t *dataExpanded;
83 /// Size of mantissa including sign bit
86 /// Number of BFP blocks in message
89 /// Number of data elements per compression block (only required for reference function)
93 /// Reference compression and expansion functions
94 void BFPCompressRef(const ExpandedData& dataIn, CompressedData* dataOut);
95 void BFPExpandRef(const CompressedData& dataIn, ExpandedData* dataOut);
97 /// User-Plane specific compression and expansion functions 9b Matissa 16RB ONLY
98 void BFPCompressUserPlaneAvx512_9b16RB(const ExpandedData& dataIn, CompressedData* dataOut);
99 void BFPExpandUserPlaneAvx512_9b16RB(const CompressedData& dataIn, ExpandedData* dataOut);
101 /// User-Plane specific compression and expansion functions
102 void BFPCompressUserPlaneAvx512(const ExpandedData& dataIn, CompressedData* dataOut);
103 void BFPExpandUserPlaneAvx512(const CompressedData& dataIn, ExpandedData* dataOut);
105 /// Control-Plane specific compression and expansion functions for 8 antennas
106 void BFPCompressCtrlPlane8Avx512(const ExpandedData& dataIn, CompressedData* dataOut);
107 void BFPExpandCtrlPlane8Avx512(const CompressedData& dataIn, ExpandedData* dataOut);
109 /// Control-Plane specific compression and expansion functions for 16 antennas
110 void BFPCompressCtrlPlane16Avx512(const ExpandedData& dataIn, CompressedData* dataOut);
111 void BFPExpandCtrlPlane16Avx512(const CompressedData& dataIn, ExpandedData* dataOut);
113 /// Control-Plane specific compression and expansion functions for 32 antennas
114 void BFPCompressCtrlPlane32Avx512(const ExpandedData& dataIn, CompressedData* dataOut);
115 void BFPExpandCtrlPlane32Avx512(const CompressedData& dataIn, ExpandedData* dataOut);
117 /// Control-Plane specific compression and expansion functions for 64 antennas
118 void BFPCompressCtrlPlane64Avx512(const ExpandedData& dataIn, CompressedData* dataOut);
119 void BFPExpandCtrlPlane64Avx512(const CompressedData& dataIn, ExpandedData* dataOut);
122 /// User-Plane specific compression and expansion functions
123 void BFPCompressUserPlaneAvxSnc(const ExpandedData& dataIn, CompressedData* dataOut);
124 void BFPExpandUserPlaneAvxSnc(const CompressedData& dataIn, ExpandedData* dataOut);
126 /// Control-Plane specific compression and expansion functions for 8 antennas
127 void BFPCompressCtrlPlane8AvxSnc(const ExpandedData& dataIn, CompressedData* dataOut);
128 void BFPExpandCtrlPlane8AvxSnc(const CompressedData& dataIn, ExpandedData* dataOut);
130 /// Control-Plane specific compression and expansion functions for 16 antennas
131 void BFPCompressCtrlPlane16AvxSnc(const ExpandedData& dataIn, CompressedData* dataOut);
132 void BFPExpandCtrlPlane16AvxSnc(const CompressedData& dataIn, ExpandedData* dataOut);
134 /// Control-Plane specific compression and expansion functions for 32 antennas
135 void BFPCompressCtrlPlane32AvxSnc(const ExpandedData& dataIn, CompressedData* dataOut);
136 void BFPExpandCtrlPlane32AvxSnc(const CompressedData& dataIn, ExpandedData* dataOut);
138 /// Control-Plane specific compression and expansion functions for 64 antennas
139 void BFPCompressCtrlPlane64AvxSnc(const ExpandedData& dataIn, CompressedData* dataOut);
140 void BFPExpandCtrlPlane64AvxSnc(const CompressedData& dataIn, ExpandedData* dataOut);