From fb9e848d5bae8e19798e2d21b6ed01f1b9a9a4d2 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Mon, 18 Aug 2025 15:41:33 +0200 Subject: [PATCH] NR UE: don't allocate unnecessary data buffers When writing dummy data or reading to trash, we don't need to allocate data buffers for each antenna. We can allocate just for one antenna and use this buffer for each antenna. --- executables/nr-ue.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 2a7ed2ab0f..0d1ae421f0 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -627,10 +627,10 @@ void dummyWrite(PHY_VARS_NR_UE *UE, openair0_timestamp_t timestamp, int writeBlo void *dummy_tx[fp->nb_antennas_tx]; // 2 because the function we call use pairs of int16_t implicitly as complex numbers - int16_t dummy_tx_data[fp->nb_antennas_tx][2 * writeBlockSize]; + int16_t dummy_tx_data[2 * writeBlockSize]; memset(dummy_tx_data, 0, sizeof(dummy_tx_data)); for (int i = 0; i < fp->nb_antennas_tx; i++) - dummy_tx[i]=dummy_tx_data[i]; + dummy_tx[i] = dummy_tx_data; int tmp = nrue_ru_write(UE, timestamp, dummy_tx, writeBlockSize, fp->nb_antennas_tx, 4); AssertFatal(writeBlockSize == tmp, ""); @@ -648,9 +648,11 @@ void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp_t *timestamp, int duration } void *rxp[NB_ANTENNAS_RX]; - if (toTrash) - for (int i = 0; i < fp->nb_antennas_rx; i++) - rxp[i] = malloc16(get_samples_per_slot(0, fp) * 4); + if (toTrash) { + rxp[0] = malloc16(get_samples_per_slot(0, fp) * 4); + for (int i = 1; i < fp->nb_antennas_rx; i++) + rxp[i] = rxp[0]; + } for (int x = 0; x < num_frames * NR_NUMBER_OF_SUBFRAMES_PER_FRAME; x++) { // two frames for initial sync for (int slot = 0; slot < fp->slots_per_subframe; slot++) { @@ -674,8 +676,7 @@ void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp_t *timestamp, int duration } if (toTrash) - for (int i = 0; i < fp->nb_antennas_rx; i++) - free(rxp[i]); + free(rxp[0]); } static void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp_t *timestamp, int duration_rx_to_tx, openair0_timestamp_t rx_offset)