From 6532db123349401df3552034e5161485fd1c1665 Mon Sep 17 00:00:00 2001 From: Hongzhi Wang Date: Sat, 7 Aug 2021 15:07:35 +0200 Subject: [PATCH] moving device init functions out from decoding --- .../nrLDPC_decoder/nrLDPC_decoder_offload.c | 75 ++++--------------- openair1/PHY/CODING/nrLDPC_defs.h | 2 +- openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c | 6 +- openair1/SIMULATION/NR_PHY/ulsim.c | 17 +++++ 4 files changed, 36 insertions(+), 64 deletions(-) diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c index c0fe83ec19..880ca4780e 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder_offload.c @@ -57,7 +57,6 @@ #include #include "nrLDPC_offload.h" -uint8_t count_initdev =0; #include #include @@ -580,13 +579,10 @@ populate_active_devices(void) static int device_setup(void) { -if (count_initdev ==0) { -count_initdev++; if (populate_active_devices() == 0) { printf("No suitable devices found!\n"); return TEST_SKIPPED; } -} return TEST_SUCCESS; } @@ -1445,8 +1441,6 @@ pmd_lcore_ldpc_dec(void *arg, t_nrLDPCoffload_params *p_offloadParams, int8_t* p bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id]; - //&op_params->q_bufs[socket_id][queue_id].inputs -//printf("bufs len %d\n",bufs->input.data->data_len); while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT) rte_pause(); @@ -1492,19 +1486,12 @@ pmd_lcore_ldpc_dec(void *arg, t_nrLDPCoffload_params *p_offloadParams, int8_t* p if (unlikely(num_ops - enq < num_to_enq)) num_to_enq = num_ops - enq; - //printf("pmd lcore ldpc dec data %x\n", *ops_enq[enq]->ldpc_dec.input.addr); - enq += rte_bbdev_enqueue_ldpc_dec_ops(tp->dev_id, queue_id, &ops_enq[enq], num_to_enq); deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id, queue_id, &ops_deq[deq], enq - deq); -/* ops_td = &ops_deq[enq]->ldpc_dec; - hard_output = &ops_td->hard_output; - struct rte_mbuf *m = hard_output->data; - printf("deq nb segs %d\n", m->nb_segs); -*/ } /* dequeue the remaining */ @@ -1782,9 +1769,8 @@ get_init_device(void) return test_params.init_device; } -int count_init = 0; - -int32_t nrLDPC_decod_offload(t_nrLDPC_dec_params* p_decParams, uint8_t C, uint8_t rv, uint16_t F, uint32_t E, uint8_t Qm, int8_t* p_llr, int8_t* p_out) +int32_t nrLDPC_decod_offload(t_nrLDPC_dec_params* p_decParams, uint8_t C, uint8_t rv, uint16_t F, + uint32_t E, uint8_t Qm, int8_t* p_llr, int8_t* p_out, uint8_t mode) { t_nrLDPCoffload_params offloadParams; t_nrLDPCoffload_params* p_offloadParams = &offloadParams; @@ -1792,55 +1778,24 @@ int32_t nrLDPC_decod_offload(t_nrLDPC_dec_params* p_decParams, uint8_t C, uint8_ uint32_t numIter = 0; int ret; -int argc_re=4; -char *argv_re[15]; -argv_re[0] = "/home/wang/dpdk2005/dpdk-20.05/build/app/testbbdev"; -argv_re[1] = "--"; //./build/app/testbbdev"; -//argv_re[2] = "-c"; -//argv_re[3] = "throughput"; -argv_re[2] = "-v"; -argv_re[3] = "../../../targets/ARCH/test-bbdev/test_vectors/ldpc_dec_v8480.data"; -if (count_init == 0) { - -printf("argcre %d argvre %s %s %s %s\n", argc_re, argv_re[0], argv_re[1], argv_re[2], argv_re[3]); -count_init++; - ret = rte_eal_init(argc_re, argv_re); -} -argc_re = 3; -argv_re[0] = "--"; -argv_re[1] = "-v"; -argv_re[2] = "../../../targets/ARCH/test-bbdev/test_vectors/ldpc_dec_v8480.data"; - - - memset(&test_vector_dec, 0, sizeof(struct test_bbdev_vector)); - -struct rte_bbdev_op_ldpc_dec *ldpc_dec = &test_vector_dec.ldpc_dec; -test_vector.op_type = RTE_BBDEV_OP_LDPC_DEC; //vector->op_type; -test_vector.expected_status = 0; - - ldpc_dec->cb_params.e = E; -ldpc_dec->iter_count = 3; - ldpc_dec->basegraph = p_decParams->BG; - ldpc_dec->z_c = p_decParams->Z; - ldpc_dec->q_m = Qm; - ldpc_dec->n_filler = F; - ldpc_dec->n_cb = (p_decParams->BG==1)?(66*p_decParams->Z):(50*p_decParams->Z); - ldpc_dec->iter_max = 8; - ldpc_dec->rv_index = rv; - ldpc_dec->op_flags = RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE; - ldpc_dec->code_block_mode = (C>1)?1:0; -ldpc_dec->tb_params.ea = E; -ldpc_dec->tb_params.eb = E; -ldpc_dec->tb_params.r = 0; - + int argc_re=2; + char *argv_re[2]; + argv_re[0] = "/home/wang/dpdk2005/dpdk-20.05/build/app/testbbdev"; + argv_re[1] = "--"; test_params.num_ops=1; test_params.burst_sz=1; test_params.num_lcores=1; test_params.num_tests = 1; - device_setup(); - ut_setup(); + if (mode==0){ + printf("offload mode %d\n", mode); + ret = rte_eal_init(argc_re, argv_re); + + device_setup(); + ut_setup(); + } + else{ p_offloadParams->E = E; p_offloadParams->n_cb = (p_decParams->BG==1)?(66*p_decParams->Z):(50*p_decParams->Z); @@ -1850,7 +1805,7 @@ ldpc_dec->tb_params.r = 0; p_offloadParams->F = F; p_offloadParams->Qm = Qm; ldpc_decod_ut(p_llr, p_offloadParams, p_out); - + } //ut_teardown(); return numIter; diff --git a/openair1/PHY/CODING/nrLDPC_defs.h b/openair1/PHY/CODING/nrLDPC_defs.h index f793e92b62..4207779638 100644 --- a/openair1/PHY/CODING/nrLDPC_defs.h +++ b/openair1/PHY/CODING/nrLDPC_defs.h @@ -74,7 +74,7 @@ typedef int(*nrLDPC_encoderfunc_t)(unsigned char **,unsigned char **,int,int,sho typedef int32_t(*nrLDPC_decoderfunc_t)(t_nrLDPC_dec_params* , int8_t*, int8_t* , t_nrLDPC_procBuf* , t_nrLDPC_time_stats* ); //typedef int32_t(*nrLDPC_decoffloadfunc_t)(t_nrLDPC_dec_params* , int8_t*, int8_t* , t_nrLDPC_procBuf* , t_nrLDPC_time_stats* ); -typedef int32_t(*nrLDPC_decoffloadfunc_t)(t_nrLDPC_dec_params* , uint8_t , uint8_t, uint16_t, uint32_t, uint8_t, int8_t*, int8_t* ); +typedef int32_t(*nrLDPC_decoffloadfunc_t)(t_nrLDPC_dec_params* , uint8_t , uint8_t, uint16_t, uint32_t, uint8_t, int8_t*, int8_t* ,uint8_t ); typedef int32_t(*nrLDPC_dectopfunc_t)(void); #endif diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c index a8be5d379c..95e89b364f 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c @@ -610,7 +610,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, E, Qm, (int8_t*)&pl_ol128[0], - llrProcBuf); + llrProcBuf, 1); for (int m=0; m < Kr>>3; m ++) { harq_process->c[r][m]= (uint8_t) llrProcBuf[m]; @@ -627,12 +627,12 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, #endif no_iteration_ldpc = ulsch->max_ldpc_iterations + 1; } - for (int k=0;k<8;k++) + /*for (int k=0;k<8;k++) { printf("output decoder [%d] = 0x%02x \n", k, harq_process->c[r][k]); printf("llrprocbuf [%d] = %x adr %p\n", k, llrProcBuf[k], llrProcBuf+k); } - + */ memcpy(harq_process->b+offset, harq_process->c[r], diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index cfefd4e612..79f39d10f9 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -260,6 +260,7 @@ channel_desc_t *UE2gNB[NUMBER_OF_UE_MAX][NUMBER_OF_gNB_MAX]; int main(int argc, char **argv) { + char c; int i; double SNR, snr0 = -2.0, snr1 = 2.0; @@ -642,6 +643,22 @@ int main(int argc, char **argv) load_nrLDPClib_offload(); + t_nrLDPC_dec_params decParams; + t_nrLDPC_dec_params* p_decParams = &decParams; + int8_t l_ol [68*384]; + __m128i *pl_ol128 = (__m128i*)&l_ol; + int8_t llrProcBuf[22*384]; + + nrLDPC_decoder_offload(p_decParams, + 1, + 0, + 0, + 0, + 2, + (int8_t*)&pl_ol128[0], + llrProcBuf, 0); + + if (snr1set == 0) snr1 = snr0 + 10; double sampling_frequency;