Change loop order to maximize cache hit

It is better to write to memory that are grouped together to reduce
probability of cache miss. This simple change improved the function's
execution speed by 70%.

Removed the unnecessary memset for the buffer.
This commit is contained in:
Sakthivel Velumani
2024-09-03 09:18:26 +02:00
committed by francescomani
parent 9c8bdd6db5
commit 2b7e0a0519
3 changed files with 6 additions and 7 deletions
+3 -3
View File
@@ -318,10 +318,10 @@ void nr_layer_mapping(int nbCodes,
}
}
void nr_ue_layer_mapping(const c16_t *mod_symbs, const int n_layers, const int n_symbs, int sz, c16_t tx_layers[][sz])
void nr_ue_layer_mapping(const c16_t *mod_symbs, const int n_layers, const int n_symbs, c16_t tx_layers[][n_symbs])
{
for (int i=0; i<n_symbs/n_layers; i++) {
for (int l=0; l<n_layers; l++) {
for (int l = 0; l < n_layers; l++) {
for (int i = 0; i < n_symbs; i++) {
tx_layers[l][i] = c16mulRealShift(mod_symbs[n_layers * i + l], AMP, 15);
}
}
+1 -1
View File
@@ -69,7 +69,7 @@ void nr_layer_mapping(int nbCodes,
@param[in] n_symbs, number of modulated symbols
@param[out] tx_layers, modulated symbols for each layer
*/
void nr_ue_layer_mapping(const c16_t *mod_symbs, const int n_layers, const int n_symbs, int sz, c16_t tx_layers[][sz]);
void nr_ue_layer_mapping(const c16_t *mod_symbs, const int n_layers, const int n_symbs, c16_t tx_layers[][n_symbs]);
/*!
\brief This function implements the OFDM front end processor on reception (FEP)
\param frame_parms Pointer to frame parameters
+2 -3
View File
@@ -248,11 +248,10 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
/////////////////////////ULSCH layer mapping/////////////////////////
///////////
const int sz = available_bits / mod_order;
const int sz = available_bits / mod_order / Nl;
c16_t tx_layers[Nl][sz];
memset(tx_layers, 0, sizeof(tx_layers));
nr_ue_layer_mapping(d_mod, Nl, available_bits / mod_order, sz, tx_layers);
nr_ue_layer_mapping(d_mod, Nl, sz, tx_layers);
///////////
////////////////////////////////////////////////////////////////////////