Update to odulow per maintenance bronze
[o-du/phy.git] / fhi_lib / test / test_xran / compander_functional.cc
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 #include "common.hpp"
20 #include "xran_fh_o_du.h"
21 #include "xran_compression.h"
22 #include "xran_compression.hpp"
23
24 #include <stdint.h>
25 #include <random>
26 #include <algorithm>
27 #include <iterator>
28 #include <iostream>
29 #include <cstring>
30
31 const std::string module_name = "bfp";
32
33 template <typename T>
34 int checkData(T* inVec1, T* inVec2, int numVals)
35 {
36   int checkSum = 0;
37   for (int n = 0; n < numVals; ++n)
38   {
39     checkSum += std::abs(inVec1[n] - inVec2[n]);
40   }
41   if (checkSum == 0)
42   {
43     //std::cout << "Test Passed\n";
44     return 0;
45   }
46   else
47   {
48     //std::cout << "Test Failed\n";
49     return 1;
50   }
51 }
52 template int checkData(int8_t*, int8_t*, int);
53 template int checkData(int16_t*, int16_t*, int);
54
55 int checkDataApprox(int16_t *inVec1, int16_t *inVec2, int numVals)
56 {
57   int checkSum = 0;
58   for (int n = 0; n < numVals; ++n)
59   {
60     if (std::abs(inVec1[n] & 0xFF00)   - std::abs(inVec2[n] & 0xFF00)){;
61         printf("[%d]: %d %d\n",n, inVec1[n] & 0xFF00, inVec2[n] & 0xFF00);
62         checkSum += 1;
63     }
64   }
65   if (checkSum == 0)
66   {
67     //std::cout << "Test Passed\n";
68     return 0;
69   }
70   else
71   {
72     //std::cout << "Test Failed\n";
73     return 1;
74   }
75 }
76
77
78 class BfpCheck : public KernelTests
79 {
80 protected:
81     void SetUp() override {
82         init_test("bfp_functional");
83     }
84
85     /* It's called after an execution of the each test case.*/
86     void TearDown() override {
87     }
88 };
89
90 CACHE_ALIGNED int16_t loc_dataExpandedIn[288*128];
91 CACHE_ALIGNED int16_t loc_dataExpandedRes[288*128];
92 CACHE_ALIGNED uint8_t loc_dataCompressedDataOut[2*288*128];
93
94 class BfpPerfEx : public KernelTests
95 {
96 protected:
97     struct xranlib_decompress_request  bfp_decom_req;
98     struct xranlib_decompress_response bfp_decom_rsp;
99     struct xranlib_compress_request  bfp_com_req;
100     struct xranlib_compress_response bfp_com_rsp;
101
102     void SetUp() override {
103         init_test("bfp_performace_ex");
104         int32_t resSum  = 0;
105         int16_t len = 0;
106         int16_t compMethod = XRAN_COMPMETHOD_BLKFLOAT;
107         int16_t iqWidth    = get_input_parameter<int16_t>("iqWidth");
108         int16_t numRBs = get_input_parameter<int16_t>("nRBsize");
109         // Create random number generator
110         std::random_device rd;
111         std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
112         std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
113         std::uniform_int_distribution<int> randExpShift(0, 4);
114
115         BlockFloatCompander::ExpandedData expandedData;
116         expandedData.dataExpanded = &loc_dataExpandedIn[0];
117         BlockFloatCompander::ExpandedData expandedDataRes;
118         expandedDataRes.dataExpanded = &loc_dataExpandedRes[0];
119
120         //printf("iqWidth %d numRBs %d\n", iqWidth, numRBs);
121
122         for (int m = 0; m < 18*BlockFloatCompander::k_maxNumBlocks; ++m) {
123             auto shiftVal = randExpShift(gen);
124             for (int n = 0; n < 24; ++n) {
125                 expandedData.dataExpanded[m*24+n] = int16_t(randInt16(gen) >> shiftVal);
126             }
127         }
128
129         BlockFloatCompander::CompressedData compressedData;
130         compressedData.dataCompressed = &loc_dataCompressedDataOut[0];
131
132         std::memset(&loc_dataCompressedDataOut[0], 0, 288*24);
133         std::memset(&loc_dataExpandedRes[0], 0, 288*24);
134
135         std::memset(&bfp_com_req, 0, sizeof(struct xranlib_compress_request));
136         std::memset(&bfp_com_rsp, 0, sizeof(struct xranlib_compress_response));
137         std::memset(&bfp_decom_req, 0, sizeof(struct xranlib_decompress_request));
138         std::memset(&bfp_decom_rsp, 0, sizeof(struct xranlib_decompress_response));
139
140         bfp_com_req.data_in    = (int16_t *)expandedData.dataExpanded;
141         bfp_com_req.numRBs     = numRBs;
142         bfp_com_req.len        = numRBs*12*2*2;
143         bfp_com_req.compMethod = compMethod;
144         bfp_com_req.iqWidth    = iqWidth;
145
146         bfp_com_rsp.data_out   = (int8_t *)(compressedData.dataCompressed);
147         bfp_com_rsp.len        = 0;
148
149         bfp_decom_req.data_in    = (int8_t *)(compressedData.dataCompressed);
150         bfp_decom_req.numRBs     = numRBs;
151         bfp_decom_req.len        = ((3 * iqWidth) + 1) * numRBs;
152         bfp_decom_req.compMethod = compMethod;
153         bfp_decom_req.iqWidth    = iqWidth;
154
155         bfp_decom_rsp.data_out   = (int16_t *)expandedDataRes.dataExpanded;
156         bfp_decom_rsp.len        = 0;
157     }
158
159     /* It's called after an execution of the each test case.*/
160     void TearDown() override {
161
162     }
163 };
164
165
166 class BfpPerfCp : public KernelTests
167 {
168 protected:
169     struct xranlib_decompress_request  bfp_decom_req;
170     struct xranlib_decompress_response bfp_decom_rsp;
171     struct xranlib_compress_request  bfp_com_req;
172     struct xranlib_compress_response bfp_com_rsp;
173
174     void SetUp() override {
175         init_test("bfp_performace_cp");
176         int32_t resSum  = 0;
177         int16_t len = 0;
178         int16_t compMethod = XRAN_COMPMETHOD_BLKFLOAT;
179         int16_t iqWidth    = get_input_parameter<int16_t>("iqWidth");
180         int16_t AntElm     = get_input_parameter<int16_t>("AntElm");
181         int16_t numDataElements = 0;
182         int16_t numRBs = 1;
183         // Create random number generator
184         std::random_device rd;
185         std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
186         std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
187         std::uniform_int_distribution<int> randExpShift(0, 4);
188
189         BlockFloatCompander::ExpandedData expandedData;
190         expandedData.dataExpanded = &loc_dataExpandedIn[0];
191         BlockFloatCompander::ExpandedData expandedDataRes;
192         expandedDataRes.dataExpanded = &loc_dataExpandedRes[0];
193
194         //printf("iqWidth %d numRBs %d\n", iqWidth, numRBs);
195         numDataElements = 2*AntElm;
196
197         // Generate input data
198         for (int m = 0; m < numRBs; ++m)
199         {
200           auto shiftVal = randExpShift(gen);
201           for (int n = 0; n < numDataElements; ++n)
202           {
203             expandedData.dataExpanded[m * numDataElements + n] = int16_t(randInt16(gen) >> shiftVal);
204           }
205         }
206
207         BlockFloatCompander::CompressedData compressedData;
208         compressedData.dataCompressed = &loc_dataCompressedDataOut[0];
209
210         std::memset(&loc_dataCompressedDataOut[0], 0, 288*128);
211         std::memset(&loc_dataExpandedRes[0], 0, 288*128);
212
213         std::memset(&bfp_com_req, 0, sizeof(struct xranlib_compress_request));
214         std::memset(&bfp_com_rsp, 0, sizeof(struct xranlib_compress_response));
215         std::memset(&bfp_decom_req, 0, sizeof(struct xranlib_decompress_request));
216         std::memset(&bfp_decom_rsp, 0, sizeof(struct xranlib_decompress_response));
217
218         bfp_com_req.data_in    = (int16_t *)expandedData.dataExpanded;
219         bfp_com_req.numRBs     = numRBs;
220         bfp_com_req.numDataElements = numDataElements;
221         bfp_com_req.len        = AntElm*4;
222         bfp_com_req.compMethod = compMethod;
223         bfp_com_req.iqWidth    = iqWidth;
224
225         bfp_com_rsp.data_out   = (int8_t *)(compressedData.dataCompressed);
226         bfp_com_rsp.len        = 0;
227
228         bfp_decom_req.data_in    = (int8_t *)(compressedData.dataCompressed);
229         bfp_decom_req.numRBs     = numRBs;
230         bfp_decom_req.numDataElements = numDataElements;
231         bfp_decom_req.len        = (((numDataElements  * iqWidth) >> 3) + 1) * numRBs;
232         bfp_decom_req.compMethod = compMethod;
233         bfp_decom_req.iqWidth    = iqWidth;
234
235         bfp_decom_rsp.data_out   = (int16_t *)expandedDataRes.dataExpanded;
236         bfp_decom_rsp.len        = 0;
237     }
238
239     /* It's called after an execution of the each test case.*/
240     void TearDown() override {
241
242     }
243 };
244
245 struct ErrorData
246 {
247   int checkSum;
248   float errorAccum;
249   int errorCount;
250 };
251
252 template <typename T>
253 void compareData(T* inVecRef, T* inVecTest, ErrorData& err, int numVals)
254 {
255   for (int n = 0; n < numVals; ++n)
256   {
257     auto valDiff = std::abs(inVecRef[n] - inVecTest[n]);
258     err.checkSum += valDiff;
259     if (inVecRef[n] != 0)
260     {
261       err.errorAccum += (float)valDiff / std::abs((float)inVecRef[n]);
262       err.errorCount++;
263     }
264   }
265 }
266 template void compareData(int8_t*, int8_t*, ErrorData&, int);
267 template void compareData(int16_t*, int16_t*, ErrorData&, int);
268
269 int checkPass(ErrorData& err, int testType)
270 {
271   if (testType == 0)
272   {
273     if (err.checkSum == 0)
274     {
275       /*std::cout << "PASS "; */
276       return 0;
277     }
278     else
279     {
280       std::cout << "FAIL ";
281       return 1;
282     }
283   }
284   else
285   {
286     //std::cout << err.errorAccum / err.errorCount;
287     if (err.errorAccum / err.errorCount < 0.1)
288     {
289       /*std::cout << " PASS ";*/
290       return 0;
291     }
292     else
293     {
294       std::cout << " FAIL ";
295       return 1;
296     }
297   }
298 }
299
300 int runTest(const int iqWidth, const int numRB, const int numDataElements, const int totNumBlocks)
301 {
302   BlockFloatCompander::ExpandedData expandedDataInput;
303   BlockFloatCompander::CompressedData compressedDataRef;
304   BlockFloatCompander::CompressedData compressedDataKern;
305   BlockFloatCompander::ExpandedData expandedDataRef;
306   BlockFloatCompander::ExpandedData expandedDataKern;
307
308   ErrorData errRef = ErrorData();
309   ErrorData errComp = ErrorData();
310   ErrorData errExp = ErrorData();
311
312   // Create random number generator
313   std::random_device rd;
314   std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
315   std::uniform_int_distribution<int16_t> randInt16(-32767, 32767);
316   std::uniform_int_distribution<int> randExpShift(0, 4);
317
318   expandedDataInput.dataExpanded    = &expandedDataInput.dataExpandedIn[0];
319   compressedDataRef.dataCompressed  = &compressedDataRef.dataCompressedDataOut[0];
320   compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
321   expandedDataRef.dataExpanded      = &expandedDataRef.dataExpandedIn[0];
322   expandedDataKern.dataExpanded     = &expandedDataKern.dataExpandedIn[0];
323
324   expandedDataInput.iqWidth = iqWidth;
325   expandedDataInput.numBlocks = numRB;
326   expandedDataInput.numDataElements = numDataElements;
327   int totExpValsPerCall = numRB * numDataElements;
328   int totCompValsPerCall = (((numDataElements * iqWidth) >> 3) + 1) * numRB;
329
330   // Run kernel verif loop
331   for (int blk = 0; blk < totNumBlocks; ++blk)
332   {
333     // Generate input data
334     for (int m = 0; m < numRB; ++m)
335     {
336       auto shiftVal = randExpShift(gen);
337       for (int n = 0; n < numDataElements; ++n)
338       {
339         expandedDataInput.dataExpanded[m * numDataElements + n] = int16_t(randInt16(gen) >> shiftVal);
340       }
341     }
342     // Generate reference
343     BlockFloatCompander::BFPCompressRef(expandedDataInput, &compressedDataRef);
344     BlockFloatCompander::BFPExpandRef(compressedDataRef, &expandedDataRef);
345     // Generate kernel output
346     switch (numDataElements)
347     {
348     case 16:
349       BlockFloatCompander::BFPCompressCtrlPlane8Avx512(expandedDataInput, &compressedDataKern);
350       BlockFloatCompander::BFPExpandCtrlPlane8Avx512(compressedDataRef, &expandedDataKern);
351       break;
352     case 24:
353       BlockFloatCompander::BFPCompressUserPlaneAvx512(expandedDataInput, &compressedDataKern);
354       BlockFloatCompander::BFPExpandUserPlaneAvx512(compressedDataRef, &expandedDataKern);
355       break;
356     case 32:
357       BlockFloatCompander::BFPCompressCtrlPlane16Avx512(expandedDataInput, &compressedDataKern);
358       BlockFloatCompander::BFPExpandCtrlPlane16Avx512(compressedDataRef, &expandedDataKern);
359       break;
360     case 64:
361       BlockFloatCompander::BFPCompressCtrlPlane32Avx512(expandedDataInput, &compressedDataKern);
362       BlockFloatCompander::BFPExpandCtrlPlane32Avx512(compressedDataRef, &expandedDataKern);
363       break;
364     case 128:
365       BlockFloatCompander::BFPCompressCtrlPlane64Avx512(expandedDataInput, &compressedDataKern);
366       BlockFloatCompander::BFPExpandCtrlPlane64Avx512(compressedDataRef, &expandedDataKern);
367       break;
368     }
369     // Check data
370     compareData(expandedDataInput.dataExpanded, expandedDataRef.dataExpanded, errRef, totExpValsPerCall);
371     compareData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, errComp, totCompValsPerCall);
372     compareData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, errRef, totExpValsPerCall);
373   }
374   // Verify Reference
375   int resSum = 0;
376   /*std::cout << "Valid Reference: ";*/
377   resSum += checkPass(errRef, 1);
378   // Verify Kernel
379   /*std::cout << "Compression: ";*/
380   resSum += checkPass(errComp, 0);
381   /*std::cout << "Expansion: ";*/
382   resSum += checkPass(errExp, 0);
383   /*std::cout << "\n";*/
384
385   return resSum;
386 }
387
388 TEST_P(BfpCheck, AVX512_bfp_main)
389 {
390   int resSum = 0;
391   int iqWidth[4] = { 8, 9, 10, 12 };
392   int numRB[3] = { 1, 4, 16 };
393   int numDataElementsUPlane = 24;
394   int numDataElementsCPlane8 = 16;
395   int numDataElementsCPlane16 = 32;
396   int numDataElementsCPlane32 = 64;
397   int numDataElementsCPlane64 = 128;
398   int totNumBlocks = 100;
399
400   for (int iqw = 0; iqw < 4; ++iqw)
401   {
402     for (int nrb = 0; nrb < 3; ++nrb)
403     {
404       //std::cout << "\n";
405
406       // USER PLANE TESTS
407       //std::cout << "U-Plane: Testing iqWidth = " << iqWidth[iqw] << ", numRB = " << numRB[nrb] << ", numElements = " << numDataElementsUPlane << ": ";
408       resSum += runTest(iqWidth[iqw], numRB[nrb], numDataElementsUPlane, totNumBlocks);
409
410       // CONTROL PLANE TESTS : 8 Antennas
411       //std::cout << "C-Plane: Testing iqWidth = " << iqWidth[iqw] << ", numRB = " << numRB[nrb] << ", numElements = " << numDataElementsCPlane8 << ": ";
412       resSum += runTest(iqWidth[iqw], numRB[nrb], numDataElementsCPlane8, totNumBlocks);
413
414       // CONTROL PLANE TESTS : 16 Antennas
415       //std::cout << "C-Plane: Testing iqWidth = " << iqWidth[iqw] << ", numRB = " << numRB[nrb] << ", numElements = " << numDataElementsCPlane16 << ": ";
416       resSum += runTest(iqWidth[iqw], numRB[nrb], numDataElementsCPlane16, totNumBlocks);
417
418       // CONTROL PLANE TESTS : 32 Antennas
419       //std::cout << "C-Plane: Testing iqWidth = " << iqWidth[iqw] << ", numRB = " << numRB[nrb] << ", numElements = " << numDataElementsCPlane32 << ": ";
420       resSum += runTest(iqWidth[iqw], numRB[nrb], numDataElementsCPlane32, totNumBlocks);
421
422       // CONTROL PLANE TESTS : 64 Antennas
423       //std::cout << "C-Plane: Testing iqWidth = " << iqWidth[iqw] << ", numRB = " << numRB[nrb] << ", numElements = " << numDataElementsCPlane64 << ": ";
424       resSum += runTest(iqWidth[iqw], numRB[nrb], numDataElementsCPlane64, totNumBlocks);
425     }
426   }
427
428   ASSERT_EQ(0, resSum);
429 }
430
431 TEST_P(BfpCheck, AVX512_sweep_xranlib)
432 {
433     int32_t resSum  = 0;
434     int16_t len = 0;
435
436     int16_t compMethod = XRAN_COMPMETHOD_BLKFLOAT;
437     int16_t iqWidth[]    = {8, 9, 10, 12};
438
439     int16_t numRBs[] = {16, 18, 32, 36, 48, 70, 113, 273};
440     struct xranlib_decompress_request  bfp_decom_req;
441     struct xranlib_decompress_response bfp_decom_rsp;
442
443     struct xranlib_compress_request  bfp_com_req;
444     struct xranlib_compress_response bfp_com_rsp;
445
446     int numDataElements = 24;
447
448     // Create random number generator
449     std::random_device rd;
450     std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
451     std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
452     std::uniform_int_distribution<int> randExpShift(0, 4);
453
454     BlockFloatCompander::ExpandedData expandedData;
455     expandedData.dataExpanded = &loc_dataExpandedIn[0];
456     BlockFloatCompander::ExpandedData expandedDataRes;
457     expandedDataRes.dataExpanded = &loc_dataExpandedRes[0];
458     for (int iq_w_id = 0; iq_w_id < sizeof(iqWidth)/sizeof(iqWidth[0]); iq_w_id ++){
459         for (int tc = 0; tc < sizeof(numRBs)/sizeof(numRBs[0]); tc ++){
460
461             //printf("[%d]numRBs %d [%d] iqWidth %d\n",tc, numRBs[tc], iq_w_id, iqWidth[iq_w_id]);
462             // Generate random test data for compression kernel
463
464             for (int m = 0; m < 18*BlockFloatCompander::k_maxNumBlocks; ++m) {
465                 auto shiftVal = randExpShift(gen);
466                 for (int n = 0; n < numDataElements; ++n) {
467                     expandedData.dataExpanded[m*numDataElements+n] = int16_t(randInt16(gen) >> shiftVal);
468                 }
469             }
470
471             BlockFloatCompander::CompressedData compressedData;
472             compressedData.dataCompressed = &loc_dataCompressedDataOut[0];
473
474             std::memset(&loc_dataCompressedDataOut[0], 0, 288*numDataElements);
475             std::memset(&loc_dataExpandedRes[0], 0, 288*numDataElements);
476
477             std::memset(&bfp_com_req, 0, sizeof(struct xranlib_compress_request));
478             std::memset(&bfp_com_rsp, 0, sizeof(struct xranlib_compress_response));
479             std::memset(&bfp_decom_req, 0, sizeof(struct xranlib_decompress_request));
480             std::memset(&bfp_decom_rsp, 0, sizeof(struct xranlib_decompress_response));
481
482             bfp_com_req.data_in    = (int16_t *)expandedData.dataExpanded;
483             bfp_com_req.numRBs     = numRBs[tc];
484             bfp_com_req.numDataElements = 24;
485             bfp_com_req.len        = numRBs[tc]*12*2*2;
486             bfp_com_req.compMethod = compMethod;
487             bfp_com_req.iqWidth    = iqWidth[iq_w_id];
488
489             bfp_com_rsp.data_out   = (int8_t *)(compressedData.dataCompressed);
490             bfp_com_rsp.len        = 0;
491
492             xranlib_compress_avx512(&bfp_com_req, &bfp_com_rsp);
493
494             bfp_decom_req.data_in    = (int8_t *)(compressedData.dataCompressed);
495             bfp_decom_req.numRBs     = numRBs[tc];
496             bfp_decom_req.len        = bfp_com_rsp.len;
497             bfp_decom_req.numDataElements = 24;
498             bfp_decom_req.compMethod = compMethod;
499             bfp_decom_req.iqWidth    = iqWidth[iq_w_id];
500
501             bfp_decom_rsp.data_out   = (int16_t *)expandedDataRes.dataExpanded;
502             bfp_decom_rsp.len        = 0;
503
504             xranlib_decompress_avx512(&bfp_decom_req, &bfp_decom_rsp);
505
506             resSum += checkDataApprox(expandedData.dataExpanded, expandedDataRes.dataExpanded, numRBs[tc]*numDataElements);
507
508             ASSERT_EQ(numRBs[tc]*12*2*2, bfp_decom_rsp.len);
509             ASSERT_EQ(0, resSum);
510          }
511     }
512 }
513
514 TEST_P(BfpCheck, AVX512_cp_sweep_xranlib)
515 {
516     int32_t resSum  = 0;
517     int16_t len = 0;
518
519     int16_t compMethod = XRAN_COMPMETHOD_BLKFLOAT;
520     int16_t iqWidth[]    = {8, 9, 10, 12};
521     int16_t numRB = 1;
522     int16_t antElm[] = {8, 16, 32, 64};
523
524     struct xranlib_decompress_request  bfp_decom_req;
525     struct xranlib_decompress_response bfp_decom_rsp;
526
527     struct xranlib_compress_request  bfp_com_req;
528     struct xranlib_compress_response bfp_com_rsp;
529     int32_t numDataElements;
530
531     // Create random number generator
532     std::random_device rd;
533     std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
534     std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
535     std::uniform_int_distribution<int> randExpShift(0, 4);
536
537     BlockFloatCompander::ExpandedData expandedData;
538     expandedData.dataExpanded = &loc_dataExpandedIn[0];
539     BlockFloatCompander::ExpandedData expandedDataRes;
540     expandedDataRes.dataExpanded = &loc_dataExpandedRes[0];
541
542     for (int iq_w_id = 0; iq_w_id < sizeof(iqWidth)/sizeof(iqWidth[0]); iq_w_id ++){
543         for (int tc = 0; tc < sizeof(antElm)/sizeof(antElm[0]); tc ++){
544
545             numDataElements = 2*antElm[tc];
546
547             // Generate input data
548             for (int m = 0; m < numRB; ++m)
549             {
550               auto shiftVal = randExpShift(gen);
551               for (int n = 0; n < numDataElements; ++n)
552               {
553                 expandedData.dataExpanded[m * numDataElements + n] = int16_t(randInt16(gen) >> shiftVal);
554               }
555             }
556
557             BlockFloatCompander::CompressedData compressedData;
558             compressedData.dataCompressed = &loc_dataCompressedDataOut[0];
559
560             std::memset(&loc_dataCompressedDataOut[0], 0, 288*numDataElements);
561             std::memset(&loc_dataExpandedRes[0], 0, 288*numDataElements);
562
563             std::memset(&bfp_com_req, 0, sizeof(struct xranlib_compress_request));
564             std::memset(&bfp_com_rsp, 0, sizeof(struct xranlib_compress_response));
565             std::memset(&bfp_decom_req, 0, sizeof(struct xranlib_decompress_request));
566             std::memset(&bfp_decom_rsp, 0, sizeof(struct xranlib_decompress_response));
567
568             bfp_com_req.data_in    = (int16_t *)expandedData.dataExpanded;
569             bfp_com_req.numRBs     = numRB;
570             bfp_com_req.numDataElements = numDataElements;
571             bfp_com_req.len        = antElm[tc]*4;
572             bfp_com_req.compMethod = compMethod;
573             bfp_com_req.iqWidth    = iqWidth[iq_w_id];
574
575             bfp_com_rsp.data_out   = (int8_t *)(compressedData.dataCompressed);
576             bfp_com_rsp.len        = 0;
577
578             xranlib_compress_avx512_bfw(&bfp_com_req, &bfp_com_rsp);
579
580             bfp_decom_req.data_in         = (int8_t *)(compressedData.dataCompressed);
581             bfp_decom_req.numRBs          = numRB;
582             bfp_decom_req.numDataElements = numDataElements;
583             bfp_decom_req.len             = bfp_com_rsp.len;
584             bfp_decom_req.compMethod      = compMethod;
585             bfp_decom_req.iqWidth         = iqWidth[iq_w_id];
586
587             bfp_decom_rsp.data_out   = (int16_t *)expandedDataRes.dataExpanded;
588             bfp_decom_rsp.len        = 0;
589
590             xranlib_decompress_avx512_bfw(&bfp_decom_req, &bfp_decom_rsp);
591
592             resSum += checkDataApprox(expandedData.dataExpanded, expandedDataRes.dataExpanded, numRB*numDataElements);
593
594             ASSERT_EQ(antElm[tc]*4, bfp_decom_rsp.len);
595             ASSERT_EQ(0, resSum);
596          }
597     }
598 }
599
600 TEST_P(BfpPerfEx, AVX512_Comp)
601 {
602      performance("AVX512", module_name, xranlib_compress_avx512, &bfp_com_req, &bfp_com_rsp);
603 }
604
605 TEST_P(BfpPerfEx, AVX512_DeComp)
606 {
607      performance("AVX512", module_name, xranlib_decompress_avx512, &bfp_decom_req, &bfp_decom_rsp);
608 }
609
610 TEST_P(BfpPerfCp, AVX512_CpComp)
611 {
612      performance("AVX512", module_name, xranlib_compress_avx512_bfw, &bfp_com_req, &bfp_com_rsp);
613 }
614
615 TEST_P(BfpPerfCp, AVX512_CpDeComp)
616 {
617      performance("AVX512", module_name, xranlib_decompress_avx512_bfw, &bfp_decom_req, &bfp_decom_rsp);
618 }
619
620 INSTANTIATE_TEST_CASE_P(UnitTest, BfpCheck,
621                         testing::ValuesIn(get_sequence(BfpCheck::get_number_of_cases("bfp_functional"))));
622
623 INSTANTIATE_TEST_CASE_P(UnitTest, BfpPerfEx,
624                         testing::ValuesIn(get_sequence(BfpPerfEx::get_number_of_cases("bfp_performace_ex"))));
625
626 INSTANTIATE_TEST_CASE_P(UnitTest, BfpPerfCp,
627                         testing::ValuesIn(get_sequence(BfpPerfCp::get_number_of_cases("bfp_performace_cp"))));
628