mmserv

Minimum Mean Square Error detection on RISC-V Vector Extention
git clone https://git.ea.contact/mmserv
Log | Files | Refs | README

commit 7f4c0961c08d7f56af3bd4ce1db4cefd94a126da
parent 5a93ce69136ae0ed7f45dc0a97e2a48105688b02
Author: Egor Achkasov <eaachkasov@edu.hse.ru>
Date:   Fri, 20 Dec 2024 00:18:55 +0100

Optimize extern variable complex cast

Diffstat:
Mmain.c | 48++++++++++--------------------------------------
Mscript/gen_data.py | 8++++----
2 files changed, 14 insertions(+), 42 deletions(-)

diff --git a/main.c b/main.c @@ -1,47 +1,19 @@ #include "include/mmserv.h" +#include "../common/util.h" #include "printf.h" -extern data_t x_raw[NUM_TX_ANT][NUM_SC][2]; /* Transmitted signal */ -extern data_t H_raw[NUM_RX_ANT][NUM_TX_ANT][NUM_SC][2]; /* Channel */ -extern data_t R_raw[NUM_TX_ANT][NUM_TX_ANT][NUM_SC][2]; /* Noise covariance matrix */ -extern data_t y_raw[NUM_RX_ANT][NUM_SC][2]; /* Received signal */ +/* Transmitted signal */ +extern complex x[NUM_TX_ANT][NUM_SC]; +/* Channel */ +extern complex H[NUM_RX_ANT][NUM_TX_ANT][NUM_SC]; +/* Noise covariance matrix */ +extern complex R[NUM_TX_ANT][NUM_TX_ANT][NUM_SC]; +/* Received signal */ +extern complex y[NUM_RX_ANT][NUM_SC]; int main() { - uint32_t i, j, k; - - /* Cast the data into complex data structures */ - complex x[NUM_TX_ANT][NUM_SC]; - complex H[NUM_RX_ANT][NUM_TX_ANT][NUM_SC]; - complex y[NUM_RX_ANT][NUM_SC]; - complex R[NUM_TX_ANT][NUM_TX_ANT][NUM_SC]; - for (i = 0; i < NUM_TX_ANT; ++i) - for (j = 0; j < NUM_SC; ++j){ - x[i][j].re = x_raw[i][j][0]; - x[i][j].im = x_raw[i][j][1]; - } - for (i = 0; i < NUM_RX_ANT; ++i) - for (j = 0; j < NUM_TX_ANT; ++j) - for (k = 0; k < NUM_SC; ++k){ - H[i][j][k].re = H_raw[i][j][k][0]; - H[i][j][k].im = H_raw[i][j][k][1]; - } - for (i = 0; i < NUM_RX_ANT; ++i) - for (j = 0; j < NUM_SC; ++j){ - y[i][j].re = y_raw[i][j][0]; - y[i][j].im = y_raw[i][j][1]; - } - for (i = 0; i < NUM_TX_ANT; ++i) - for (j = 0; j < NUM_TX_ANT; ++j) - for (k = 0; k < NUM_SC; ++k){ - R[i][j][k].re = R_raw[i][j][k][0]; - R[i][j][k].im = R_raw[i][j][k][1]; - } - - /* Calculate the MMSE approximation */ complex x_MMSE[NUM_TX_ANT][NUM_SC]; mmse(H, y, R, x_MMSE); - - /* Print MSE */ - printf("%f\n", mse(x, x_MMSE)); + printf("MSE: %f\n", mse(x, x_MMSE)); } diff --git a/script/gen_data.py b/script/gen_data.py @@ -58,10 +58,10 @@ class Section: sections = [ - Section("x_raw", "data/x.txt", "3", 32, x.size * 2), - Section("H_raw", "data/H.txt", "3", 32, H.size * 2), - Section("R_raw", "data/R.txt", "3", 32, R.size * 2), - Section("y_raw", "data/y.txt", "3", 32, y.size * 2), + Section("x", "data/x.txt", "3", 32, x.size * 2), + Section("H", "data/H.txt", "3", 32, H.size * 2), + Section("R", "data/R.txt", "3", 32, R.size * 2), + Section("y", "data/y.txt", "3", 32, y.size * 2), ] # Create "data" directory if it does not exist