1 /******************************************************************************
3 * Copyright (c) 2019 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 *******************************************************************************/
20 #include "xran_fh_o_du.h"
21 #include "xran_compression.h"
22 #include "xran_compression.hpp"
31 const std::string module_name = "bfp";
34 int checkData(T* inVec1, T* inVec2, int numVals)
37 for (int n = 0; n < numVals; ++n)
39 checkSum += std::abs(inVec1[n] - inVec2[n]);
43 //std::cout << "Test Passed\n";
48 //std::cout << "Test Failed\n";
52 template int checkData(int8_t*, int8_t*, int);
53 template int checkData(int16_t*, int16_t*, int);
55 int checkDataApprox(int16_t *inVec1, int16_t *inVec2, int numVals)
58 for (int n = 0; n < numVals; ++n)
60 if (std::abs(inVec1[n] & 0xFF00) - std::abs(inVec2[n] & 0xFF00)){;
61 printf("%d %d\n", inVec1[n] & 0xFF00, inVec2[n] & 0xFF00);
67 //std::cout << "Test Passed\n";
72 //std::cout << "Test Failed\n";
78 class BfpCheck : public KernelTests
81 void SetUp() override {
82 init_test("bfp_functional");
85 /* It's called after an execution of the each test case.*/
86 void TearDown() override {
90 class BfpPerf : public KernelTests
93 void SetUp() override {
94 init_test("bfp_performace");
97 /* It's called after an execution of the each test case.*/
98 void TearDown() override {
101 CACHE_ALIGNED int16_t loc_dataExpandedIn[288*BlockFloatCompander::k_numREReal];
102 CACHE_ALIGNED int16_t loc_dataExpandedRes[288*BlockFloatCompander::k_numREReal];
103 CACHE_ALIGNED uint8_t loc_dataCompressedDataOut[2*288*BlockFloatCompander::k_numREReal];
105 class BfpPerfEx : public KernelTests
108 struct xranlib_decompress_request bfp_decom_req;
109 struct xranlib_decompress_response bfp_decom_rsp;
110 struct xranlib_compress_request bfp_com_req;
111 struct xranlib_compress_response bfp_com_rsp;
113 void SetUp() override {
114 init_test("bfp_performace_ex");
117 int16_t compMethod = XRAN_COMPMETHOD_BLKFLOAT;
118 int16_t iqWidth = get_input_parameter<int16_t>("iqWidth");
119 int16_t numRBs = get_input_parameter<int16_t>("nRBsize");
120 // Create random number generator
121 std::random_device rd;
122 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
123 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
124 std::uniform_int_distribution<int> randExpShift(0, 4);
126 BlockFloatCompander::ExpandedData expandedData;
127 expandedData.dataExpanded = &loc_dataExpandedIn[0];
128 BlockFloatCompander::ExpandedData expandedDataRes;
129 expandedDataRes.dataExpanded = &loc_dataExpandedRes[0];
131 //printf("iqWidth %d numRBs %d\n", iqWidth, numRBs);
133 for (int m = 0; m < 18*BlockFloatCompander::k_numRB; ++m) {
134 auto shiftVal = randExpShift(gen);
135 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n) {
136 expandedData.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
140 BlockFloatCompander::CompressedData compressedData;
141 compressedData.dataCompressed = &loc_dataCompressedDataOut[0];
143 std::memset(&loc_dataCompressedDataOut[0], 0, 288*BlockFloatCompander::k_numREReal);
144 std::memset(&loc_dataExpandedRes[0], 0, 288*BlockFloatCompander::k_numREReal);
146 std::memset(&bfp_com_req, 0, sizeof(struct xranlib_compress_request));
147 std::memset(&bfp_com_rsp, 0, sizeof(struct xranlib_compress_response));
148 std::memset(&bfp_decom_req, 0, sizeof(struct xranlib_decompress_request));
149 std::memset(&bfp_decom_rsp, 0, sizeof(struct xranlib_decompress_response));
151 bfp_com_req.data_in = (int16_t *)expandedData.dataExpanded;
152 bfp_com_req.numRBs = numRBs;
153 bfp_com_req.len = numRBs*12*2*2;
154 bfp_com_req.compMethod = compMethod;
155 bfp_com_req.iqWidth = iqWidth;
157 bfp_com_rsp.data_out = (int8_t *)(compressedData.dataCompressed);
160 bfp_decom_req.data_in = (int8_t *)(compressedData.dataCompressed);
161 bfp_decom_req.numRBs = numRBs;
162 bfp_decom_req.len = ((3 * iqWidth) + 1) * numRBs;
163 bfp_decom_req.compMethod = compMethod;
164 bfp_decom_req.iqWidth = iqWidth;
166 bfp_decom_rsp.data_out = (int16_t *)expandedDataRes.dataExpanded;
167 bfp_decom_rsp.len = 0;
170 /* It's called after an execution of the each test case.*/
171 void TearDown() override {
176 TEST_P(BfpCheck, AVX512_12bit)
180 // Create random number generator
181 std::random_device rd;
182 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
183 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
184 std::uniform_int_distribution<int> randExpShift(0, 4);
186 // Generate random test data for compression kernel
187 BlockFloatCompander::ExpandedData expandedDataInput;
188 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
189 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
191 auto shiftVal = randExpShift(gen);
192 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
194 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
198 BlockFloatCompander::CompressedData compressedDataRef;
199 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
200 BlockFloatCompander::ExpandedData expandedDataRef;
201 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
202 BlockFloatCompander::CompressedData compressedDataKern;
203 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
204 BlockFloatCompander::ExpandedData expandedDataKern;
205 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
207 //std::cout << "Verifying AVX512 12b iqWidth Kernel\n";
208 expandedDataInput.iqWidth = 12;
209 // Generate reference
210 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
211 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
212 // Generate kernel output
213 BlockFloatCompander::BlockFloatCompress_12b_AVX512(expandedDataInput, &compressedDataKern);
214 BlockFloatCompander::BlockFloatExpand_12b_AVX512(compressedDataRef, &expandedDataKern);
216 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
217 //std::cout << "Compression: ";
218 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
219 //std::cout << "Expansion: ";
220 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
222 ASSERT_EQ(0, resSum);
225 TEST_P(BfpCheck, AVX512_10bit)
229 // Create random number generator
230 std::random_device rd;
231 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
232 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
233 std::uniform_int_distribution<int> randExpShift(0, 4);
235 // Generate random test data for compression kernel
236 BlockFloatCompander::ExpandedData expandedDataInput;
237 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
238 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
240 auto shiftVal = randExpShift(gen);
241 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
243 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
247 BlockFloatCompander::CompressedData compressedDataRef;
248 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
249 BlockFloatCompander::ExpandedData expandedDataRef;
250 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
251 BlockFloatCompander::CompressedData compressedDataKern;
252 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
253 BlockFloatCompander::ExpandedData expandedDataKern;
254 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
256 //std::cout << "Verifying AVX512 10b iqWidth Kernel\n";
257 expandedDataInput.iqWidth = 10;
258 // Generate reference
259 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
260 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
261 // Generate kernel output
262 BlockFloatCompander::BlockFloatCompress_10b_AVX512(expandedDataInput, &compressedDataKern);
263 BlockFloatCompander::BlockFloatExpand_10b_AVX512(compressedDataRef, &expandedDataKern);
265 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
266 //std::cout << "Compression: ";
267 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
268 //std::cout << "Expansion: ";
269 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
271 ASSERT_EQ(0, resSum);
273 // performance("AVX512", module_name, BlockFloatCompander::BlockFloatCompress_10b_AVX512, expandedDataInput, &compressedDataKern);
276 TEST_P(BfpCheck, AVX512_9bit)
280 // Create random number generator
281 std::random_device rd;
282 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
283 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
284 std::uniform_int_distribution<int> randExpShift(0, 4);
286 // Generate random test data for compression kernel
287 BlockFloatCompander::ExpandedData expandedDataInput;
288 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
289 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
291 auto shiftVal = randExpShift(gen);
292 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
294 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
298 BlockFloatCompander::CompressedData compressedDataRef;
299 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
300 BlockFloatCompander::ExpandedData expandedDataRef;
301 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
302 BlockFloatCompander::CompressedData compressedDataKern;
303 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
304 BlockFloatCompander::ExpandedData expandedDataKern;
305 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
307 //std::cout << "Verifying AVX512 9b iqWidth Kernel\n";
308 expandedDataInput.iqWidth = 9;
309 // Generate reference
310 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
311 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
312 // Generate kernel output
313 BlockFloatCompander::BlockFloatCompress_9b_AVX512(expandedDataInput, &compressedDataKern);
314 BlockFloatCompander::BlockFloatExpand_9b_AVX512(compressedDataRef, &expandedDataKern);
316 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
317 //std::cout << "Compression: ";
318 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
319 //std::cout << "Expansion: ";
320 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
322 ASSERT_EQ(0, resSum);
326 TEST_P(BfpCheck, AVX512_8bit)
330 // Create random number generator
331 std::random_device rd;
332 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
333 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
334 std::uniform_int_distribution<int> randExpShift(0, 4);
336 // Generate random test data for compression kernel
337 BlockFloatCompander::ExpandedData expandedDataInput;
338 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
339 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
341 auto shiftVal = randExpShift(gen);
342 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
344 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
348 BlockFloatCompander::CompressedData compressedDataRef;
349 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
350 BlockFloatCompander::ExpandedData expandedDataRef;
351 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
352 BlockFloatCompander::CompressedData compressedDataKern;
353 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
354 BlockFloatCompander::ExpandedData expandedDataKern;
355 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
357 //std::cout << "Verifying AVX512 8bit Kernel\n";
358 expandedDataInput.iqWidth = 8;
359 // Generate reference
360 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
361 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
362 // Generate kernel output
363 BlockFloatCompander::BlockFloatCompress_8b_AVX512(expandedDataInput, &compressedDataKern);
364 BlockFloatCompander::BlockFloatExpand_8b_AVX512(compressedDataRef, &expandedDataKern);
366 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
367 //std::cout << "Compression: ";
368 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
369 //std::cout << "Expansion: ";
370 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
372 ASSERT_EQ(0, resSum);
375 TEST_P(BfpPerf, AVX512_8bit_compression)
379 // Create random number generator
380 std::random_device rd;
381 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
382 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
383 std::uniform_int_distribution<int> randExpShift(0, 4);
385 // Generate random test data for compression kernel
386 BlockFloatCompander::ExpandedData expandedDataInput;
387 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
388 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
390 auto shiftVal = randExpShift(gen);
391 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
393 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
397 BlockFloatCompander::CompressedData compressedDataRef;
398 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
399 BlockFloatCompander::ExpandedData expandedDataRef;
400 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
401 BlockFloatCompander::CompressedData compressedDataKern;
402 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
403 BlockFloatCompander::ExpandedData expandedDataKern;
404 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
406 //std::cout << "Verifying AVX512 8bit Kernel\n";
407 expandedDataInput.iqWidth = 8;
408 // Generate reference
409 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
410 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
411 // Generate kernel output
412 BlockFloatCompander::BlockFloatCompress_8b_AVX512(expandedDataInput, &compressedDataKern);
413 BlockFloatCompander::BlockFloatExpand_8b_AVX512(compressedDataRef, &expandedDataKern);
415 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
416 //std::cout << "Compression: ";
417 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
418 //std::cout << "Expansion: ";
419 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
421 ASSERT_EQ(0, resSum);
423 performance("AVX512", module_name, BlockFloatCompander::BlockFloatCompress_8b_AVX512, expandedDataInput, &compressedDataKern);
426 TEST_P(BfpPerf, AVX512_8bit_decompression)
430 // Create random number generator
431 std::random_device rd;
432 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
433 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
434 std::uniform_int_distribution<int> randExpShift(0, 4);
436 // Generate random test data for compression kernel
437 BlockFloatCompander::ExpandedData expandedDataInput;
438 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
439 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
441 auto shiftVal = randExpShift(gen);
442 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
444 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
448 BlockFloatCompander::CompressedData compressedDataRef;
449 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
450 BlockFloatCompander::ExpandedData expandedDataRef;
451 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
452 BlockFloatCompander::CompressedData compressedDataKern;
453 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
454 BlockFloatCompander::ExpandedData expandedDataKern;
455 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
457 //std::cout << "Verifying AVX512 8bit Kernel\n";
458 expandedDataInput.iqWidth = 8;
459 // Generate reference
460 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
461 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
462 // Generate kernel output
463 BlockFloatCompander::BlockFloatCompress_8b_AVX512(expandedDataInput, &compressedDataKern);
464 BlockFloatCompander::BlockFloatExpand_8b_AVX512(compressedDataRef, &expandedDataKern);
466 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
467 //std::cout << "Compression: ";
468 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
469 //std::cout << "Expansion: ";
470 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
472 ASSERT_EQ(0, resSum);
474 performance("AVX512", module_name, BlockFloatCompander::BlockFloatExpand_8b_AVX512, compressedDataRef, &expandedDataKern);
479 TEST_P(BfpPerf, AVX512_9bit_compression)
483 // Create random number generator
484 std::random_device rd;
485 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
486 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
487 std::uniform_int_distribution<int> randExpShift(0, 4);
489 // Generate random test data for compression kernel
490 BlockFloatCompander::ExpandedData expandedDataInput;
491 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
492 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
494 auto shiftVal = randExpShift(gen);
495 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
497 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
501 BlockFloatCompander::CompressedData compressedDataRef;
502 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
503 BlockFloatCompander::ExpandedData expandedDataRef;
504 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
505 BlockFloatCompander::CompressedData compressedDataKern;
506 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
507 BlockFloatCompander::ExpandedData expandedDataKern;
508 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
510 //std::cout << "Verifying AVX512 8bit Kernel\n";
511 expandedDataInput.iqWidth = 9;
512 // Generate reference
513 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
514 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
515 // Generate kernel output
516 BlockFloatCompander::BlockFloatCompress_9b_AVX512(expandedDataInput, &compressedDataKern);
517 BlockFloatCompander::BlockFloatExpand_9b_AVX512(compressedDataRef, &expandedDataKern);
519 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
520 //std::cout << "Compression: ";
521 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
522 //std::cout << "Expansion: ";
523 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
525 ASSERT_EQ(0, resSum);
527 performance("AVX512", module_name, BlockFloatCompander::BlockFloatCompress_9b_AVX512, expandedDataInput, &compressedDataKern);
531 TEST_P(BfpPerf, AVX512_9bit_decompression)
535 // Create random number generator
536 std::random_device rd;
537 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
538 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
539 std::uniform_int_distribution<int> randExpShift(0, 4);
541 // Generate random test data for compression kernel
542 BlockFloatCompander::ExpandedData expandedDataInput;
543 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
544 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
546 auto shiftVal = randExpShift(gen);
547 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
549 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
553 BlockFloatCompander::CompressedData compressedDataRef;
554 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
555 BlockFloatCompander::ExpandedData expandedDataRef;
556 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
557 BlockFloatCompander::CompressedData compressedDataKern;
558 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
559 BlockFloatCompander::ExpandedData expandedDataKern;
560 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
562 //std::cout << "Verifying AVX512 8bit Kernel\n";
563 expandedDataInput.iqWidth = 9;
564 // Generate reference
565 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
566 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
567 // Generate kernel output
568 BlockFloatCompander::BlockFloatCompress_9b_AVX512(expandedDataInput, &compressedDataKern);
569 BlockFloatCompander::BlockFloatExpand_9b_AVX512(compressedDataRef, &expandedDataKern);
571 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
572 //std::cout << "Compression: ";
573 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
574 //std::cout << "Expansion: ";
575 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
577 ASSERT_EQ(0, resSum);
579 performance("AVX512", module_name, BlockFloatCompander::BlockFloatExpand_9b_AVX512, compressedDataRef, &expandedDataKern);
583 TEST_P(BfpPerf, AVX512_10bit_compression)
587 // Create random number generator
588 std::random_device rd;
589 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
590 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
591 std::uniform_int_distribution<int> randExpShift(0, 4);
593 // Generate random test data for compression kernel
594 BlockFloatCompander::ExpandedData expandedDataInput;
595 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
596 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
598 auto shiftVal = randExpShift(gen);
599 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
601 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
605 BlockFloatCompander::CompressedData compressedDataRef;
606 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
607 BlockFloatCompander::ExpandedData expandedDataRef;
608 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
609 BlockFloatCompander::CompressedData compressedDataKern;
610 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
611 BlockFloatCompander::ExpandedData expandedDataKern;
612 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
614 //std::cout << "Verifying AVX512 8bit Kernel\n";
615 expandedDataInput.iqWidth = 10;
616 // Generate reference
617 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
618 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
619 // Generate kernel output
620 BlockFloatCompander::BlockFloatCompress_10b_AVX512(expandedDataInput, &compressedDataKern);
621 BlockFloatCompander::BlockFloatExpand_10b_AVX512(compressedDataRef, &expandedDataKern);
623 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
624 //std::cout << "Compression: ";
625 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
626 //std::cout << "Expansion: ";
627 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
629 ASSERT_EQ(0, resSum);
631 performance("AVX512", module_name, BlockFloatCompander::BlockFloatCompress_10b_AVX512, expandedDataInput, &compressedDataKern);
634 TEST_P(BfpPerf, AVX512_10bit_decompression)
638 // Create random number generator
639 std::random_device rd;
640 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
641 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
642 std::uniform_int_distribution<int> randExpShift(0, 4);
644 // Generate random test data for compression kernel
645 BlockFloatCompander::ExpandedData expandedDataInput;
646 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
647 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
649 auto shiftVal = randExpShift(gen);
650 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
652 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
656 BlockFloatCompander::CompressedData compressedDataRef;
657 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
658 BlockFloatCompander::ExpandedData expandedDataRef;
659 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
660 BlockFloatCompander::CompressedData compressedDataKern;
661 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
662 BlockFloatCompander::ExpandedData expandedDataKern;
663 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
665 //std::cout << "Verifying AVX512 8bit Kernel\n";
666 expandedDataInput.iqWidth = 10;
667 // Generate reference
668 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
669 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
670 // Generate kernel output
671 BlockFloatCompander::BlockFloatCompress_10b_AVX512(expandedDataInput, &compressedDataKern);
672 BlockFloatCompander::BlockFloatExpand_10b_AVX512(compressedDataRef, &expandedDataKern);
674 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
675 //std::cout << "Compression: ";
676 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
677 //std::cout << "Expansion: ";
678 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
680 ASSERT_EQ(0, resSum);
682 performance("AVX512", module_name, BlockFloatCompander::BlockFloatExpand_10b_AVX512, compressedDataRef, &expandedDataKern);
685 TEST_P(BfpPerf, AVX512_12bit_compression)
689 // Create random number generator
690 std::random_device rd;
691 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
692 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
693 std::uniform_int_distribution<int> randExpShift(0, 4);
695 // Generate random test data for compression kernel
696 BlockFloatCompander::ExpandedData expandedDataInput;
697 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
698 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
700 auto shiftVal = randExpShift(gen);
701 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
703 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
707 BlockFloatCompander::CompressedData compressedDataRef;
708 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
709 BlockFloatCompander::ExpandedData expandedDataRef;
710 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
711 BlockFloatCompander::CompressedData compressedDataKern;
712 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
713 BlockFloatCompander::ExpandedData expandedDataKern;
714 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
716 //std::cout << "Verifying AVX512 8bit Kernel\n";
717 expandedDataInput.iqWidth = 12;
718 // Generate reference
719 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
720 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
721 // Generate kernel output
722 BlockFloatCompander::BlockFloatCompress_12b_AVX512(expandedDataInput, &compressedDataKern);
723 BlockFloatCompander::BlockFloatExpand_12b_AVX512(compressedDataRef, &expandedDataKern);
725 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
726 //std::cout << "Compression: ";
727 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
728 //std::cout << "Expansion: ";
729 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
731 ASSERT_EQ(0, resSum);
733 performance("AVX512", module_name, BlockFloatCompander::BlockFloatCompress_12b_AVX512, expandedDataInput, &compressedDataKern);
737 TEST_P(BfpPerf, AVX512_12bit_decompression)
741 // Create random number generator
742 std::random_device rd;
743 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
744 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
745 std::uniform_int_distribution<int> randExpShift(0, 4);
747 // Generate random test data for compression kernel
748 BlockFloatCompander::ExpandedData expandedDataInput;
749 expandedDataInput.dataExpanded = &expandedDataInput.dataExpandedIn[0];
750 for (int m = 0; m < BlockFloatCompander::k_numRB; ++m)
752 auto shiftVal = randExpShift(gen);
753 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n)
755 expandedDataInput.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
759 BlockFloatCompander::CompressedData compressedDataRef;
760 compressedDataRef.dataCompressed = &compressedDataRef.dataCompressedDataOut[0];
761 BlockFloatCompander::ExpandedData expandedDataRef;
762 expandedDataRef.dataExpanded = &expandedDataRef.dataExpandedIn[0];
763 BlockFloatCompander::CompressedData compressedDataKern;
764 compressedDataKern.dataCompressed = &compressedDataKern.dataCompressedDataOut[0];
765 BlockFloatCompander::ExpandedData expandedDataKern;
766 expandedDataKern.dataExpanded = &expandedDataKern.dataExpandedIn[0];
768 //std::cout << "Verifying AVX512 8bit Kernel\n";
769 expandedDataInput.iqWidth = 12;
770 // Generate reference
771 BlockFloatCompander::BlockFloatCompress_Basic(expandedDataInput, &compressedDataRef);
772 BlockFloatCompander::BlockFloatExpand_Basic(compressedDataRef, &expandedDataRef);
773 // Generate kernel output
774 BlockFloatCompander::BlockFloatCompress_12b_AVX512(expandedDataInput, &compressedDataKern);
775 BlockFloatCompander::BlockFloatExpand_12b_AVX512(compressedDataRef, &expandedDataKern);
777 auto totNumBytes = ((3 * compressedDataRef.iqWidth) + 1) * BlockFloatCompander::k_numRB;
778 //std::cout << "Compression: ";
779 resSum += checkData(compressedDataRef.dataCompressed, compressedDataKern.dataCompressed, totNumBytes);
780 //std::cout << "Expansion: ";
781 resSum += checkData(expandedDataRef.dataExpanded, expandedDataKern.dataExpanded, BlockFloatCompander::k_numSampsExpanded);
783 ASSERT_EQ(0, resSum);
785 performance("AVX512", module_name, BlockFloatCompander::BlockFloatExpand_12b_AVX512, compressedDataRef, &expandedDataKern);
788 TEST_P(BfpCheck, AVX512_sweep_xranlib)
793 int16_t compMethod = XRAN_COMPMETHOD_BLKFLOAT;
794 int16_t iqWidth[] = {8, 9, 10, 12};
796 int16_t numRBs[] = {16, 18, 32, 36, 48, 70, 113, 273};
797 struct xranlib_decompress_request bfp_decom_req;
798 struct xranlib_decompress_response bfp_decom_rsp;
800 struct xranlib_compress_request bfp_com_req;
801 struct xranlib_compress_response bfp_com_rsp;
803 // Create random number generator
804 std::random_device rd;
805 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
806 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
807 std::uniform_int_distribution<int> randExpShift(0, 4);
809 BlockFloatCompander::ExpandedData expandedData;
810 expandedData.dataExpanded = &loc_dataExpandedIn[0];
811 BlockFloatCompander::ExpandedData expandedDataRes;
812 expandedDataRes.dataExpanded = &loc_dataExpandedRes[0];
813 for (int iq_w_id = 0; iq_w_id < sizeof(iqWidth)/sizeof(iqWidth[0]); iq_w_id ++){
814 for (int tc = 0; tc < sizeof(numRBs)/sizeof(numRBs[0]); tc ++){
816 //printf("[%d]numRBs %d [%d] iqWidth %d\n",tc, numRBs[tc], iq_w_id, iqWidth[iq_w_id]);
817 // Generate random test data for compression kernel
819 for (int m = 0; m < 18*BlockFloatCompander::k_numRB; ++m) {
820 auto shiftVal = randExpShift(gen);
821 for (int n = 0; n < BlockFloatCompander::k_numREReal; ++n) {
822 expandedData.dataExpanded[m*BlockFloatCompander::k_numREReal+n] = int16_t(randInt16(gen) >> shiftVal);
826 BlockFloatCompander::CompressedData compressedData;
827 compressedData.dataCompressed = &loc_dataCompressedDataOut[0];
829 std::memset(&loc_dataCompressedDataOut[0], 0, 288*BlockFloatCompander::k_numREReal);
830 std::memset(&loc_dataExpandedRes[0], 0, 288*BlockFloatCompander::k_numREReal);
832 std::memset(&bfp_com_req, 0, sizeof(struct xranlib_compress_request));
833 std::memset(&bfp_com_rsp, 0, sizeof(struct xranlib_compress_response));
834 std::memset(&bfp_decom_req, 0, sizeof(struct xranlib_decompress_request));
835 std::memset(&bfp_decom_rsp, 0, sizeof(struct xranlib_decompress_response));
837 bfp_com_req.data_in = (int16_t *)expandedData.dataExpanded;
838 bfp_com_req.numRBs = numRBs[tc];
839 bfp_com_req.len = numRBs[tc]*12*2*2;
840 bfp_com_req.compMethod = compMethod;
841 bfp_com_req.iqWidth = iqWidth[iq_w_id];
843 bfp_com_rsp.data_out = (int8_t *)(compressedData.dataCompressed);
846 xranlib_compress_avx512(&bfp_com_req, &bfp_com_rsp);
848 bfp_decom_req.data_in = (int8_t *)(compressedData.dataCompressed);
849 bfp_decom_req.numRBs = numRBs[tc];
850 bfp_decom_req.len = bfp_com_rsp.len;
851 bfp_decom_req.compMethod = compMethod;
852 bfp_decom_req.iqWidth = iqWidth[iq_w_id];
854 bfp_decom_rsp.data_out = (int16_t *)expandedDataRes.dataExpanded;
855 bfp_decom_rsp.len = 0;
857 xranlib_decompress_avx512(&bfp_decom_req, &bfp_decom_rsp);
859 resSum += checkDataApprox(expandedData.dataExpanded, expandedDataRes.dataExpanded, numRBs[tc]*BlockFloatCompander::k_numREReal);
861 ASSERT_EQ(numRBs[tc]*12*2*2, bfp_decom_rsp.len);
862 ASSERT_EQ(0, resSum);
867 TEST_P(BfpPerfEx, AVX512_Comp)
869 performance("AVX512", module_name, xranlib_compress_avx512, &bfp_com_req, &bfp_com_rsp);
872 TEST_P(BfpPerfEx, AVX512_DeComp)
874 performance("AVX512", module_name, xranlib_decompress_avx512, &bfp_decom_req, &bfp_decom_rsp);
877 INSTANTIATE_TEST_CASE_P(UnitTest, BfpCheck,
878 testing::ValuesIn(get_sequence(BfpCheck::get_number_of_cases("bfp_functional"))));
880 INSTANTIATE_TEST_CASE_P(UnitTest, BfpPerf,
881 testing::ValuesIn(get_sequence(BfpPerf::get_number_of_cases("bfp_performace"))));
884 INSTANTIATE_TEST_CASE_P(UnitTest, BfpPerfEx,
885 testing::ValuesIn(get_sequence(BfpPerf::get_number_of_cases("bfp_performace_ex"))));