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 *******************************************************************************/
20 #include "xran_fh_o_du.h"
21 #include "xran_mod_compression.h"
30 const std::string module_name = "mod_compression";
32 extern int _may_i_use_cpu_feature(unsigned __int64);
34 int16_t loc_ModCompIn[273*12*14*2*16*2];
35 int8_t loc_ModCompOut[273*12*14*2*16];
37 class Mod_CompressionPerf : public KernelTests
40 struct xranlib_5gnr_mod_compression_request mod_com_req;
41 struct xranlib_5gnr_mod_compression_response mod_com_rsp;
43 void SetUp() override {
44 init_test("mod_compression_performace");
45 // Create random number generator
46 std::random_device rd;
47 std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
48 std::uniform_int_distribution<int16_t> randInt16(-32768, 32767);
49 std::uniform_int_distribution<int> randExpShift(0, 4);
50 std::memset(&loc_ModCompOut[0], 0, 273*12);
52 std::memset(&mod_com_req, 0, sizeof(struct xranlib_5gnr_mod_compression_request));
53 std::memset(&mod_com_rsp, 0, sizeof(struct xranlib_5gnr_mod_compression_response));
54 mod_com_req.unit = get_input_parameter<int16_t>("unit");
55 mod_com_req.modulation = get_input_parameter<xran_modulation_order>("modulation");
56 mod_com_req.num_symbols = get_input_parameter<int32_t>("num_symbols");
58 for (int m = 0; m < 2*mod_com_req.num_symbols; ++m) {
59 loc_ModCompIn[m] = int16_t(randInt16(gen));
62 mod_com_req.data_in = (int16_t *)loc_ModCompIn;
63 mod_com_rsp.data_out = (int8_t *)(loc_ModCompOut);
66 /* It's called after an execution of the each test case.*/
67 void TearDown() override {
72 TEST_P(Mod_CompressionPerf, AVX512_Mod_Comp)
74 performance("AVX512", module_name, xranlib_5gnr_mod_compression_avx512, &mod_com_req, &mod_com_rsp);
78 TEST_P(Mod_CompressionPerf, AVXSNC_Mod_Comp)
80 if(_may_i_use_cpu_feature(_FEATURE_AVX512IFMA52))
81 performance("AVXSNC", module_name, xranlib_5gnr_mod_compression_snc, &mod_com_req, &mod_com_rsp);
84 INSTANTIATE_TEST_CASE_P(UnitTest, Mod_CompressionPerf,
85 testing::ValuesIn(get_sequence(Mod_CompressionPerf::get_number_of_cases("mod_compression_performace"))));