From 119be5d45b533bb9243a04df889bf0d89753d8b6 Mon Sep 17 00:00:00 2001 From: Sy Date: Thu, 4 Jun 2020 02:52:35 +0200 Subject: [PATCH] Re-implementation of memcpy--> more faster | llr2cnProcBuf, cn2bnProcbuf, bn2cnProcBuf are optimized --- .../PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h | 185 +++++++++--------- 1 file changed, 94 insertions(+), 91 deletions(-) diff --git a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h index 2163172a39..8ebadd33f6 100644 --- a/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h +++ b/openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_mPass.h @@ -1,3 +1,4 @@ + /* * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more * contributor license agreements. See the NOTICE file distributed with @@ -21,13 +22,8 @@ /*!\file nrLDPC_mPass.h * \brief Defines the functions for message passing - * \author Sebastian Wagner (TCL Communications) Email: - * \date 30-09-2019 - * \version 2.0 - * \note - * \warning - */ - + * +*/ #ifndef __NR_LDPC_MPASS__H__ #define __NR_LDPC_MPASS__H__ @@ -35,7 +31,7 @@ #include "nrLDPCdecoder_defs.h" #include /** - \brief Circular memcpy + \brief Circular memcpy1 |<- rem->|<- circular shift ->| (src) str2 = |--------xxxxxxxxxxxxxxxxxxxxx| \_______________ @@ -46,17 +42,27 @@ \param Z Lifting size \param cshift Circular shift */ -static inline void *nrLDPC_inv_circ_memcpy(int8_t *str1, const int8_t *str2, uint16_t Z, uint16_t cshift) +//more faster memcpy by using "rep movsb", which on modern processors is highly optimized + +void *memcpy1(void *dst, const void *src, size_t n) +{ + void *ret = dst; + asm volatile("rep movsb" : "+D" (dst) : "c"(n), "S"(src) : "cc", "memory"); + return ret; +} + + +static inline void *nrLDPC_inv_circ_memcpy1(int8_t *str1, const int8_t *str2, uint16_t Z, uint16_t cshift) { uint16_t rem = Z - cshift; - memcpy(str1+cshift, str2 , rem); - memcpy(str1 , str2+rem, cshift); + memcpy1(str1+cshift, str2 , rem); + memcpy1(str1 , str2+rem, cshift); return(str1); } /** - \brief Inverse circular memcpy + \brief Inverse circular memcpy1 |<- circular shift ->|<- rem->| (src) str2 = |xxxxxxxxxxxxxxxxxxxx\--------| \ @@ -66,11 +72,11 @@ static inline void *nrLDPC_inv_circ_memcpy(int8_t *str1, const int8_t *str2, uin \param Z Lifting size \param cshift Circular shift */ -static inline void *nrLDPC_circ_memcpy(int8_t *str1, const int8_t *str2, uint16_t Z, uint16_t cshift) +static inline void *nrLDPC_circ_memcpy1(int8_t *str1, const int8_t *str2, uint16_t Z, uint16_t cshift) { uint16_t rem = Z - cshift; - memcpy(str1 , str2+cshift, rem); - memcpy(str1+rem , str2 , cshift); + memcpy1(str1 , str2+cshift, rem); + memcpy1(str1+rem , str2 , cshift); return(str1); } @@ -114,14 +120,14 @@ static inline void nrLDPC_llr2llrProcBuf(t_nrLDPC_lut* p_lut, int8_t* llr, t_nrL // Copy LLRs connected to 1 CN if (numBn2CnG1 > 0) { - memcpy(&llrProcBuf[0], &llr[colG1], numBn2CnG1*Z); + memcpy1(&llrProcBuf[0], &llr[colG1], numBn2CnG1*Z); } // First 2 columns might be set to zero directly if it's true they always belong to the groups with highest number of connected CNs... for (i=0; i 0) { - memcpy(&llrOut[colG1], llrRes, numBn2CnG1*Z); + memcpy1(&llrOut[colG1], llrRes, numBn2CnG1*Z); } for (i=0; i