a2ee478b4d7708ed3db54fffb5c059a65e090d58
[o-du/phy.git] / fhi_lib / lib / api / xran_compression.hpp
1 /******************************************************************************
2 *
3 *   Copyright (c) 2019 Intel.
4 *
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
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 *
17 *******************************************************************************/
18
19 #pragma once
20 #include <stdint.h>
21
22 // This configuration file sets global constants and macros which are
23 // of general use throughout the project.
24
25 // All current IA processors of interest align their cache lines on
26 // this boundary. If the cache alignment for future processors changes
27 // then the most restrictive alignment should be set.
28 constexpr unsigned k_cacheByteAlignment = 64;
29
30 // Force the data to which this macro is applied to be aligned on a cache line.
31 // For example:
32 //
33 // CACHE_ALIGNED float data[64];
34 #define CACHE_ALIGNED alignas(k_cacheByteAlignment)
35
36 // Hint to the compiler that the data to which this macro is applied
37 // can be assumed to be aligned to a cache line. This allows the
38 // compiler to generate improved code by using aligned reads and
39 // writes.
40 #define ASSUME_CACHE_ALIGNED(data) __assume_aligned(data, k_cacheByteAlignment);
41
42 /// Intel compiler frequently complains about templates not being declared in an external
43 /// header. Templates are used throughout this project's source files to define local type-specific
44 /// versions of functions. Defining every one of these in a header is unnecessary, so the warnings
45 /// about this are turned off globally.
46 #pragma warning(disable:1418)
47 #pragma warning(disable:1419)
48
49
50 namespace BlockFloatCompander
51 {
52   /// Compute 32 RB at a time
53   static constexpr int k_numBitsIQ = 16;
54   static constexpr int k_numRB = 16;
55   static constexpr int k_numRE = 12;
56   static constexpr int k_numREReal = k_numRE * 2;
57   static constexpr int k_numSampsExpanded = k_numRB * k_numREReal;
58   static constexpr int k_numSampsCompressed = k_numSampsExpanded + k_numRB;
59   static constexpr int k_iqWidth = 8;
60
61
62   struct CompressedData
63   {
64     /// Compressed data
65     CACHE_ALIGNED int8_t dataCompressed[k_numSampsCompressed];
66   };
67
68   struct ExpandedData
69   {
70     /// Expanded data or input data to compressor
71     CACHE_ALIGNED int16_t dataExpanded[k_numSampsExpanded];
72   };
73
74   void BlockFloatCompress_AVX512(const ExpandedData& dataIn, CompressedData* dataOut);
75
76   void BlockFloatExpand_AVX512(const CompressedData& dataIn, ExpandedData* dataOut);
77
78   void BlockFloatCompress_Basic(const ExpandedData& dataIn, CompressedData* dataOut);
79
80   void BlockFloatExpand_Basic(const CompressedData& dataIn, ExpandedData* dataOut);
81
82 }