Commit 98a9469f authored by nikaeinn's avatar nikaeinn

* add oaisim performance profiler OPP (enabled with option q )

* fix the bug for IP connectivity when more than 1 UE is connected (test with iperf: ok)
* set target ul/dl mcs in the eNB scheduler to hardwire the desired MCS (option t for UL and m for DL)
* add the code related to abstraction from http://svn.eurecom.fr/openairsvn/openair4G/tags/asilomar2013
* cleanup the code
* pre-ci passed for all except for eMBMS



git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5093 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 70920ffd
......@@ -373,7 +373,7 @@ run in segments with final trace back after last segment.
@param traceback flag to indicate that traceback should be performed*/
void phy_viterbi_dot11_sse2(int8_t *y,uint8_t *decoded_bytes,uint16_t n);
/*!\fn void phy_viterbi_lte_sse2(s8 *y, u8 *decoded_bytes, u16 n)
/*!\fn void phy_viterbi_lte_sse2(int8_t *y, uint8_t *decoded_bytes, uint16_t n)
\brief This routine performs a SIMD optmized Viterbi decoder for the LTE 64-state tail-biting convolutional code.
@param y Pointer to soft input (coded on 8-bits but should be limited to 4-bit precision to avoid overflow)
@param decoded_bytes Pointer to decoded output
......
......@@ -582,7 +582,16 @@ void phy_config_dedicated_ue(u8 Mod_id,u8 CH_index,
PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id];
phy_vars_ue->total_TBS[CH_index]=0;
phy_vars_ue->total_TBS_last[CH_index]=0;
phy_vars_ue->bitrate[CH_index]=0;
phy_vars_ue->total_received_bits[CH_index]=0;
phy_vars_ue->dlsch_errors[CH_index]=0;
phy_vars_ue->dlsch_errors_last[CH_index]=0;
phy_vars_ue->dlsch_received[CH_index]=0;
phy_vars_ue->dlsch_received_last[CH_index]=0;
phy_vars_ue->dlsch_fer[CH_index]=0;
if (physicalConfigDedicated) {
......
......@@ -154,10 +154,11 @@ phy_adjust_gain (PHY_VARS_UE *phy_vars_ue, u8 eNB_id) {
#endif
#ifdef DEBUG_PHY
if ((phy_vars_ue->frame%100==0) || (phy_vars_ue->frame < 10))
/* if ((phy_vars_ue->frame%100==0) || (phy_vars_ue->frame < 10))
msg("[PHY][ADJUST_GAIN] frame %d, rx_power = %d, rx_power_fil = %d, rx_power_fil_dB = %d, coef=%d, ncoef=%d, rx_total_gain_dB = %d (%d,%d,%d)\n",
phy_vars_ue->frame,rx_power,rx_power_fil,rx_power_fil_dB,coef,ncoef,phy_vars_ue->rx_total_gain_dB,
TARGET_RX_POWER,MAX_RF_GAIN,MIN_RF_GAIN);
*/
#endif //DEBUG_PHY
}
......
......@@ -45,6 +45,7 @@
#include "PHY/defs.h"
#include "PHY/extern.h"
#include "SCHED/defs.h"
#include "SIMULATION/TOOLS/defs.h" // for taus
#include <emmintrin.h>
#include <xmmintrin.h>
#ifdef __SSE3__
......@@ -2062,9 +2063,10 @@ u8 generate_dci_top(u8 num_ue_spec_dci,
y[1] = &yseq1[0];
// reset all bits to <NIL>, here we set <NIL> elements as 2
memset(e, 2, DCI_BITS_MAX);
//memset(e, 2, DCI_BITS_MAX);
// here we interpred NIL as a random QPSK sequence. That makes power estimation easier.
//for (i=0;i<DCI_BITS_MAX;i++) e[i]=taus()&1;
for (i=0;i<DCI_BITS_MAX;i++)
e[i]=taus()&1;
e_ptr = e;
// generate DCIs in order of decreasing aggregation level, then common/ue spec
......
......@@ -2636,7 +2636,7 @@ uint16_t quantize_wideband_pmi(PHY_MEASUREMENTS *meas,uint8_t eNB_id) {
}
*/
uint8_t sinr2cqi(int sinr,uint8_t trans_mode) {
uint8_t sinr2cqi(double sinr,uint8_t trans_mode) {
// int flag_LA=0;
if(flag_LA==0){
......@@ -2751,7 +2751,9 @@ void fill_CQI(void *o,UCI_format_t uci_format,PHY_MEASUREMENTS *meas,uint8_t eNB
if(flag_LA==1)
sinr_tmp = sinr_eff;
else
sinr_tmp = meas->wideband_cqi_avg[eNB_id];
sinr_tmp = (double) meas->wideband_cqi_avg[eNB_id];
LOG_I(PHY,"Filling CQI %f for eNB %d\n",sinr_tmp,eNB_id);
switch (uci_format) {
case wideband_cqi_rank1_2A:
......
......@@ -45,6 +45,7 @@
#include "PHY/CODING/lte_interleaver_inline.h"
#include "PHY/LTE_TRANSPORT/defs.h"
#include "defs.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
//#define DEBUG_DLSCH_CODING
//#define DEBUG_DLSCH_FREE 1
......@@ -74,11 +75,12 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) {
msg("Freeing dlsch process %d (%p)\n",i,dlsch->harq_processes[i]);
#endif
if (dlsch->harq_processes[i]->b) {
free16(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES);
free16(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES);
dlsch->harq_processes[i]->b = NULL;
#ifdef DEBUG_DLSCH_FREE
msg("Freeing dlsch process %d b (%p)\n",i,dlsch->harq_processes[i]->b);
#endif
}
}
if (dlsch->harq_processes[i]->c) {
#ifdef DEBUG_DLSCH_FREE
msg("Freeing dlsch process %d c (%p)\n",i,dlsch->harq_processes[i]->c);
......@@ -88,14 +90,18 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) {
#ifdef DEBUG_DLSCH_FREE
msg("Freeing dlsch process %d c[%d] (%p)\n",i,r,dlsch->harq_processes[i]->c[r]);
#endif
if (dlsch->harq_processes[i]->c[r])
if (dlsch->harq_processes[i]->c[r]) {
free16(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+768);
dlsch->harq_processes[i]->c[r] = NULL;
}
}
}
free16(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t));
dlsch->harq_processes[i] = NULL;
}
}
free16(dlsch,sizeof(LTE_eNB_DLSCH_t));
dlsch = NULL;
}
}
......@@ -137,7 +143,10 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,unsigne
bzero(dlsch->harq_processes[i],sizeof(LTE_DL_eNB_HARQ_t));
// dlsch->harq_processes[i]->first_tx=1;
dlsch->harq_processes[i]->b = (unsigned char*)malloc16(MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
if (!dlsch->harq_processes[i]->b) {
if (dlsch->harq_processes[i]->b) {
bzero(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES/bw_scaling);
}
else {
msg("Can't get b\n");
exit_flag=1;
}
......@@ -145,7 +154,10 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,unsigne
for (r=0;r<MAX_NUM_DLSCH_SEGMENTS/bw_scaling;r++) {
// account for filler in first segment and CRCs for multiple segment case
dlsch->harq_processes[i]->c[r] = (unsigned char*)malloc16(((r==0)?8:0) + 3+ 768);
if (!dlsch->harq_processes[i]->c[r]) {
if (dlsch->harq_processes[i]->c[r]) {
bzero(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+ 768);
}
else {
msg("Can't get c\n");
exit_flag=2;
}
......@@ -169,7 +181,8 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,unsigne
return(dlsch);
}
}
msg("new_eNB_dlsch exit flag %d, size of %zd\n", exit_flag, sizeof(LTE_eNB_DLSCH_t));
LOG_D(PHY, "new_eNB_dlsch exit flag %d, size of %ld\n",
exit_flag, sizeof(LTE_eNB_DLSCH_t));
free_eNB_dlsch(dlsch);
return(NULL);
......@@ -224,6 +237,8 @@ int dlsch_encoding(unsigned char *a,
unsigned int Kr=0,Kr_bytes,r,r_offset=0;
unsigned short m=dlsch->harq_processes[harq_pid]->mcs;
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN);
A = dlsch->harq_processes[harq_pid]->TBS; //6228
// printf("Encoder: A: %d\n",A);
mod_order = get_Qm(dlsch->harq_processes[harq_pid]->mcs);
......@@ -355,6 +370,8 @@ int dlsch_encoding(unsigned char *a,
write_output("enc_output.m","enc",dlsch->e,r_offset,1,4);
#endif
}
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT);
return(0);
}
......
......@@ -495,34 +495,14 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue,
}
}
}
//printf("sinr_eff1 = %f\n",sinr_eff);
LOG_D(OCM,"sinr_eff (lin, unweighted) = %f\n",sinr_eff);
sinr_eff = -beta2_dlsch[TM][mcs]*log((sinr_eff)/(12*rb_count));
LOG_D(OCM,"sinr_eff (lin, weighted) = %f\n",sinr_eff);
sinr_eff = 10 * log10(sinr_eff);
LOG_I(OCM,"sinr_eff2 = %f\n",sinr_eff);
// table lookup
sinr_eff *= 10;
sinr_eff = floor(sinr_eff);
// if ((int)sinr_eff%2) {
// sinr_eff += 1;
// }
sinr_eff /= 10;
msg("Imran sinr_eff after rounding = %f\n",sinr_eff);
for (index = 0; index < table_length[mcs]; index++) {
if(index == 0) {
if (sinr_eff < sinr_bler_map[mcs][0][index]) {
bler = 1;
break;
}
else if(sinr_eff > sinr_bler_map[mcs][0][table_length[mcs]]){
bler = 0;
break;
}
}
if (sinr_eff == sinr_bler_map[mcs][0][index]) {
bler = sinr_bler_map[mcs][1][index];
}
}
LOG_D(OCM,"sinr_eff (dB) = %f\n",sinr_eff);
bler = interp(sinr_eff,&sinr_bler_map[mcs][0][0],&sinr_bler_map[mcs][1][0],table_length[mcs]);
#ifdef USER_MODE // need to be adapted for the emulation in the kernel space
if (uniformrandom() < bler) {
LOG_I(OCM,"abstraction_decoding failed (mcs=%d, sinr_eff=%f, bler=%f)\n",mcs,sinr_eff,bler);
......@@ -591,56 +571,34 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue,
}
}
// averaging of accumulated MI
I = I/(12*rb_count);
//Now I->SINR_effective Mapping
if(mcs<10)
{
sinr_eff = (p_qpsk[0]*pow(I,7) + p_qpsk[1]*pow(I,6) + p_qpsk[2]*pow(I,5) + p_qpsk[3]*pow(I,4) + p_qpsk[4]*pow(I,3) + p_qpsk[5]*pow(I,2) + p_qpsk[6]*I + p_qpsk[7]);
}
else if(mcs>9 && mcs<17)
{
sinr_eff = (p_qam16[0]*pow(I,7) + p_qam16[1]*pow(I,6) + p_qam16[2]*pow(I,5) + p_qam16[3]*pow(I,4) + p_qam16[4]*pow(I,3) + p_qam16[5]*pow(I,2) + p_qam16[6]*I + p_qam16[7]);
}
else if(mcs>16 && mcs<23)
{
sinr_eff = (p_qam64[0]*pow(I,7) + p_qam64[1]*pow(I,6) + p_qam64[2]*pow(I,5) + p_qam64[3]*pow(I,4) + p_qam64[4]*pow(I,3) + p_qam64[5]*pow(I,2) + p_qam64[6]*I + p_qam64[7]);
}
sinr_eff = sinr_eff + 10*log10(beta2_dlsch_MI[TM][mcs]);
msg("SINR_Eff = %e\n",sinr_eff);
sinr_eff *= 10;
sinr_eff = floor(sinr_eff);
// if ((int)sinr_eff%2) {
// sinr_eff += 1;
// }
sinr_eff /= 10;
msg("sinr_eff after rounding = %f\n",sinr_eff);
for (index = 0; index < table_length[mcs]; index++) {
if(index == 0) {
if (sinr_eff < sinr_bler_map[mcs][0][index]) {
bler = 1;
break;
}
else if(sinr_eff > sinr_bler_map[mcs][0][table_length[mcs]]){
bler = 0;
break;
}
I = I/(12*rb_count);
//Now I->SINR_effective Mapping
if(mcs<10)
{
sinr_eff = (p_qpsk[0]*pow(I,7) + p_qpsk[1]*pow(I,6) + p_qpsk[2]*pow(I,5) + p_qpsk[3]*pow(I,4) + p_qpsk[4]*pow(I,3) + p_qpsk[5]*pow(I,2) + p_qpsk[6]*I + p_qpsk[7]);
}
if (sinr_eff == sinr_bler_map[mcs][0][index]) {
bler = sinr_bler_map[mcs][1][index];
else if(mcs>9 && mcs<17)
{
sinr_eff = (p_qam16[0]*pow(I,7) + p_qam16[1]*pow(I,6) + p_qam16[2]*pow(I,5) + p_qam16[3]*pow(I,4) + p_qam16[4]*pow(I,3) + p_qam16[5]*pow(I,2) + p_qam16[6]*I + p_qam16[7]);
}
}
else if(mcs>16 && mcs<23)
{
sinr_eff = (p_qam64[0]*pow(I,7) + p_qam64[1]*pow(I,6) + p_qam64[2]*pow(I,5) + p_qam64[3]*pow(I,4) + p_qam64[4]*pow(I,3) + p_qam64[5]*pow(I,2) + p_qam64[6]*I + p_qam64[7]);
}
//sinr_eff = sinr_eff + 10*log10(beta2_dlsch_MI[TM][mcs]);
LOG_D(OCM,"SINR_Eff = %e\n",sinr_eff);
bler = interp(sinr_eff,&sinr_bler_map[mcs][0][0],&sinr_bler_map[mcs][1][0],table_length[mcs]);
#ifdef USER_MODE // need to be adapted for the emulation in the kernel space
if (uniformrandom() < bler) {
msg("abstraction_decoding failed (mcs=%d, sinr_eff=%f, bler=%f)\n",mcs,sinr_eff,bler);
if (uniformrandom() < bler) {
LOG_I(OCM,"abstraction_decoding failed (mcs=%d, sinr_eff=%f, bler=%f)\n",mcs,sinr_eff,bler);
return(0);
}
else {
msg("abstraction_decoding successful (mcs=%d, sinr_eff=%f, bler=%f)\n",mcs,sinr_eff,bler);
LOG_I(OCM,"abstraction_decoding successful (mcs=%d, sinr_eff=%f, bler=%f)\n",mcs,sinr_eff,bler);
return(1);
}
#endif
......@@ -660,7 +618,7 @@ uint32_t dlsch_decoding_emul(PHY_VARS_UE *phy_vars_ue,
u16 i;
#endif
// may not be necessaru for PMCH??
// may not be necessary for PMCH??
for (eNB_id2=0;eNB_id2<NB_eNB_INST;eNB_id2++) {
if (PHY_vars_eNB_g[eNB_id2]->lte_frame_parms.Nid_cell == phy_vars_ue->lte_frame_parms.Nid_cell)
break;
......
......@@ -50,6 +50,10 @@
#include "extern.h"
#include "PHY/extern.h"
#ifdef PHY_ABSTRACTION
#include "SIMULATION/TOOLS/defs.h"
#endif
#ifndef __SSE3__
extern __m128i zero;
#define _mm_abs_epi16(xmmx) _mm_xor_si128((xmmx),_mm_cmpgt_epi16(zero,(xmmx)))
......@@ -900,21 +904,34 @@ u16 rx_pbch(LTE_UE_COMMON *lte_ue_common_vars,
}
#ifdef PHY_ABSTRACTION
u16 rx_pbch_emul(PHY_VARS_UE *phy_vars_ue,
u8 eNB_id,
u8 pbch_phase) {
u8 pbch_error=0;
LOG_D(PHY,"EMUL UE rx_pbch_emul: eNB_id %d, pbch_phase %d\n",eNB_id,pbch_phase);
double bler=0.0, x=0.0;
double sinr=0.0;
u16 nb_rb = phy_vars_ue->lte_frame_parms.N_RB_DL;
s16 f;
// compute effective sinr
// TODO: adapt this to varible bandwidth
for (f=(nb_rb*6-3*12);f<(nb_rb*6+3*12);f++) {
if (f!=0) //skip DC
sinr += pow(10, 0.1*(phy_vars_ue->sinr_dB[f]));
}
sinr = 10*log10(sinr/(6*12));
bler = pbch_bler(sinr);
LOG_D(PHY,"EMUL UE rx_pbch_emul: eNB_id %d, pbch_phase %d, sinr %f dB, bler %f \n",
eNB_id,
pbch_phase,
sinr,
bler);
if (pbch_phase == (phy_vars_ue->frame % 4)) {
// abtract pbch error here
// pbch_error = pbch_abstraction();
if (pbch_error == 0) {
if (uniformrandom() >= bler) {
memcpy(phy_vars_ue->lte_ue_pbch_vars[eNB_id]->decoded_output,PHY_vars_eNB_g[eNB_id]->pbch_pdu,PBCH_PDU_SIZE);
return(PHY_vars_eNB_g[eNB_id]->lte_frame_parms.nb_antennas_tx_eNB);
}
......@@ -924,3 +941,4 @@ u16 rx_pbch_emul(PHY_VARS_UE *phy_vars_ue,
else
return(-1);
}
#endif
......@@ -827,6 +827,8 @@ void rx_prach(PHY_VARS_eNB *phy_vars_eNB,u8 subframe,u16 *preamble_energy_list,
NCS = NCS_restricted[Ncs_config];
}
start_meas(&phy_vars_eNB->rx_prach);
n_ra_prb = n_ra_prboffset;
prach_root_sequence_map = (prach_fmt < 4) ? prach_root_sequence_map0_3 : prach_root_sequence_map4;
......@@ -1133,6 +1135,8 @@ void rx_prach(PHY_VARS_eNB *phy_vars_eNB,u8 subframe,u16 *preamble_energy_list,
#endif
// exit(-1);
}// preamble_index
stop_meas(&phy_vars_eNB->rx_prach);
}
void init_prach_tables(int N_ZC) {
......
......@@ -119,6 +119,7 @@ int dump_ue_stats(PHY_VARS_UE *phy_vars_ue, char* buffer, int length, runmode_t
len += sprintf(&buffer[len], "[UE PROC] RX total power eNB%d: %d dB, avg: %d dB\n",eNB,phy_vars_ue->PHY_measurements.rx_power_tot_dB[eNB],phy_vars_ue->PHY_measurements.rx_power_avg_dB[eNB]);
len += sprintf(&buffer[len], "[UE PROC] RX total power lin: %d, avg: %d, RX total noise lin: %d, avg: %d\n",phy_vars_ue->PHY_measurements.rx_power_tot[eNB], phy_vars_ue->PHY_measurements.rx_power_avg[eNB], phy_vars_ue->PHY_measurements.n0_power_tot, phy_vars_ue->PHY_measurements.n0_power_avg);
len += sprintf(&buffer[len], "[UE PROC] effective SINR %.2f dB\n",phy_vars_ue->sinr_eff);
len += sprintf(&buffer[len], "[UE PROC] Wideband CQI eNB %d: %d dB, avg: %d dB\n",eNB,phy_vars_ue->PHY_measurements.wideband_cqi_tot[eNB],phy_vars_ue->PHY_measurements.wideband_cqi_avg[eNB]);
len += sprintf(&buffer[len], "[UE PROC] Subband CQI eNB%d (Ant 0): [%d %d %d %d %d %d %d] dB\n",
......@@ -195,6 +196,7 @@ int dump_ue_stats(PHY_VARS_UE *phy_vars_ue, char* buffer, int length, runmode_t
RRC_status = mac_get_rrc_status(phy_vars_ue->Mod_id,0,0);
len += sprintf(&buffer[len],"[UE PROC] RRC status = %d\n",RRC_status);
#endif
len += sprintf(&buffer[len],"[UE PROC] RSRP[0] %d, RSSI %d, RSRQ[0] %d\n",phy_vars_ue->PHY_measurements.rsrp[0], phy_vars_ue->PHY_measurements.rssi, phy_vars_ue->PHY_measurements.rsrq[0]);
len += sprintf(&buffer[len], "[UE PROC] Transmission Mode %d (mode1_flag %d)\n",phy_vars_ue->transmission_mode[eNB],phy_vars_ue->lte_frame_parms.mode1_flag);
if (phy_vars_ue->transmission_mode[eNB] == 6)
......@@ -252,8 +254,7 @@ int dump_ue_stats(PHY_VARS_UE *phy_vars_ue, char* buffer, int length, runmode_t
}
len += sprintf(&buffer[len],"EOF\n");
/* SR: for trailing '\0' */
len ++;
len += sprintf(&buffer[len],"\0");
return len;
} // is_clusterhead
......@@ -479,8 +480,7 @@ int dump_eNB_stats(PHY_VARS_eNB *phy_vars_eNB, char* buffer, int length) {
len += sprintf(&buffer[len],"\n");
}
len += sprintf(&buffer[len],"EOF\n");
/* SR: for trailing '\0' */
len++;
len += sprintf(&buffer[len],"\0");
return len;
}
......@@ -247,12 +247,14 @@ u32 ulsch_encoding(u8 *a,
// fill CQI/PMI information
if (ulsch->O>0) {
/* //not correctly done
if (flag_LA==1)
sinr_eff = sinr_eff_cqi_calc(phy_vars_ue, 0); //eNB_id is missing here
else
sinr_eff = 0;
*/
rnti = phy_vars_ue->lte_ue_pdcch_vars[eNB_id]->crnti;
fill_CQI(ulsch->o,ulsch->uci_format,meas,0,rnti, tmode,sinr_eff);
fill_CQI(ulsch->o,ulsch->uci_format,meas,0,rnti, tmode,phy_vars_ue->sinr_eff);
LOG_D(PHY,"UE CQI\n");
print_CQI(ulsch->o,ulsch->uci_format,0);
......
......@@ -1607,6 +1607,7 @@ void dump_ulsch(PHY_VARS_eNB *PHY_vars_eNB,uint8_t subframe, uint8_t UE_id) {
uint32_t nsymb = (PHY_vars_eNB->lte_frame_parms.Ncp == 0) ? 14 : 12;
uint8_t harq_pid = subframe2harq_pid(&PHY_vars_eNB->lte_frame_parms,PHY_vars_eNB->frame,subframe);
printf("Dumping ULSCH in subframe %d with harq_pid %d, for NB_rb %d, mcs %d, Qm %d, N_symb %d\n", subframe,harq_pid,PHY_vars_eNB->ulsch_eNB[UE_id]->harq_processes[harq_pid]->nb_rb,PHY_vars_eNB->ulsch_eNB[UE_id]->harq_processes[harq_pid]->mcs,get_Qm_ul(PHY_vars_eNB->ulsch_eNB[UE_id]->harq_processes[harq_pid]->mcs),PHY_vars_eNB->ulsch_eNB[UE_id]->Nsymb_pusch);
#ifndef OAI_EMU
write_output("/tmp/ulsch_d.m","ulsch_dseq",&PHY_vars_eNB->ulsch_eNB[UE_id]->harq_processes[harq_pid]->d[0][96],
PHY_vars_eNB->ulsch_eNB[UE_id]->harq_processes[harq_pid]->Kplus*3,1,0);
write_output("/tmp/rxsig0.m","rxs0", &PHY_vars_eNB->lte_eNB_common_vars.rxdata[0][0][0],PHY_vars_eNB->lte_frame_parms.samples_per_tti*10,1,1);
......@@ -1639,6 +1640,7 @@ void dump_ulsch(PHY_VARS_eNB *PHY_vars_eNB,uint8_t subframe, uint8_t UE_id) {
write_output("/tmp/ulsch_rxF_llr.m","ulsch_llr",PHY_vars_eNB->lte_eNB_pusch_vars[UE_id]->llr,PHY_vars_eNB->ulsch_eNB[UE_id]->harq_processes[harq_pid]->nb_rb*12*get_Qm_ul(PHY_vars_eNB->ulsch_eNB[UE_id]->harq_processes[harq_pid]->mcs)*PHY_vars_eNB->ulsch_eNB[UE_id]->Nsymb_pusch,1,0);
write_output("/tmp/ulsch_ch_mag.m","ulsch_ch_mag",&PHY_vars_eNB->lte_eNB_pusch_vars[UE_id]->ul_ch_mag[0][0][0],PHY_vars_eNB->lte_frame_parms.N_RB_UL*12*nsymb,1,1);
// write_output("ulsch_ch_mag1.m","ulsch_ch_mag1",&PHY_vars_eNB->lte_eNB_pusch_vars[UE_id]->ul_ch_mag[0][1][0],PHY_vars_eNB->lte_frame_parms.N_RB_UL*12*nsymb,1,1);
#endif
#endif
#endif
}
......@@ -80,5 +80,7 @@ PHY_OBJS += $(TOP_DIR)/PHY/TOOLS/sqrt.o
ifdef SMBV
PHY_OBJS += $(TOP_DIR)/PHY/TOOLS/smbv.o
endif
PHY_OBJS += $(TOP_DIR)/PHY/TOOLS/time_meas.o
PHY_OBJS += $(TOP_DIR)/PHY/TOOLS/lut.o
#PHY_OBJS += $(TOP_DIR)/SIMULATION/TOOLS/rangen_double.o
......@@ -569,7 +569,7 @@ s16 dB_fixed_times10(u32 x) {
dB_power = dB_table_times10[(x&255)-1];
}
if (dB_power > 900)
return(0);
return(900);
return dB_power;
}
......@@ -593,7 +593,7 @@ s8 dB_fixed(u32 x) {
dB_power = dB_table[(x&255)-1];
}
if (dB_power > 90)
return(0);
return(90);
return dB_power;
}
......
......@@ -588,4 +588,6 @@ void idft2048(int16_t *x,int16_t *y,int scale);
/** @} */
double interp(double x, double *xs, double *ys, int count);
#endif //__PHY_TOOLS_DEFS__H__
......@@ -10,8 +10,7 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d
int i;
printf("Writing %d elements of type %d to %s\n",length,format,fname);
printf("Writing %d elements of type %d to %s\n",length,format,fname);
printf("Writing %d elements of type %d to %s\n",length,format,fname);
if (format == 10 || format ==11 || format == 12 )
......
double interp(double x, double *xs, double *ys, int count)
{
int i;
double dx, dy;
if (x < xs[0]) {
return 1.0; /* return minimum element */
}
if (x > xs[count-1]) {
return 0.0; /* return maximum */
}
/* find i, such that xs[i] <= x < xs[i+1] */
for (i = 0; i < count-1; i++) {
if (xs[i+1] > x) {
break;
}
}
/* interpolate */
dx = xs[i+1] - xs[i];
dy = ys[i+1] - ys[i];
return ys[i] + (x - xs[i]) * dy / dx;
}
#include <stdio.h>
#include "time_meas.h"
// global var for openair performance profiler
int opp_enabled = 0;
void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_time, time_stats_t * sf_exec_time){
if (opp_enabled) {
static int first_time = 0;
static double cpu_freq_GHz = 0.0;
if (cpu_freq_GHz == 0.0)
cpu_freq_GHz = get_cpu_freq_GHz();
if (first_time == 0) {
first_time=1;
fprintf(stderr, "%25s %25s %25s %20s %15s %6f\n","Name","Total","Average/Frame","Trials","CPU_F_GHz", cpu_freq_GHz);
}
if (ts->trials>0) {
//printf("%20s: total: %10.3f ms, average: %10.3f us (%10d trials)\n", name, ts->diff/cpu_freq_GHz/1000000.0, ts->diff/ts->trials/cpu_freq_GHz/1000.0, ts->trials);
fprintf(stderr, "%25s: %15.3f ms (%5.2f%); %15.3f us (%5.2f%); %15d;\n",
name,
(ts->diff/cpu_freq_GHz/1000000.0),
((ts->diff/cpu_freq_GHz/1000000.0)/(total_exec_time->diff/cpu_freq_GHz/1000000.0))*100, // percentage
(ts->diff/ts->trials/cpu_freq_GHz/1000.0),
((ts->diff/ts->trials/cpu_freq_GHz/1000.0)/(sf_exec_time->diff/sf_exec_time->trials/cpu_freq_GHz/1000.0))*100, // percentage
ts->trials);
}
}
}
#ifdef OMP
#include <omp.h>
#endif
#include <unistd.h>
// global var to enable openair performance profiler
extern int opp_enabled;
typedef struct {
......@@ -13,6 +16,8 @@ typedef struct {
static inline void start_meas(time_stats_t *ts) __attribute__((always_inline));
static inline void stop_meas(time_stats_t *ts) __attribute__((always_inline));
void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_time, time_stats_t * sf_exec_time);
#if defined(__i386__)
static inline unsigned long long rdtsc_oai(void) __attribute__((always_inline));
static inline unsigned long long rdtsc_oai(void) {
......@@ -31,38 +36,62 @@ static inline unsigned long long rdtsc_oai() {
static inline void start_meas(time_stats_t *ts) {
#ifdef OMP
int tid;
if (opp_enabled) {
tid = omp_get_thread_num();
if (tid==0)
#ifdef OMP
int tid;
tid = omp_get_thread_num();
if (tid==0)
#endif
{
ts->trials++;
ts->in = rdtsc_oai();
}
{
ts->trials++;
ts->in = rdtsc_oai();
}
}
}
static inline void stop_meas(time_stats_t *ts) {
long long out = rdtsc_oai();
if (opp_enabled) {
long long out = rdtsc_oai();
#ifdef OMP
int tid;
tid = omp_get_thread_num();
if (tid==0)
int tid;
tid = omp_get_thread_num();
if (tid==0)
#endif
{
ts->diff += (out-ts->in);
if ((out-ts->in) > ts->max)
ts->max = out-ts->in;
}
{
ts->diff += (out-ts->in);
if ((out-ts->in) > ts->max)
ts->max = out-ts->in;
}
}
}
static inline void reset_meas(time_stats_t *ts) {
ts->trials=0;
ts->diff=0;
ts->max=0;
if (opp_enabled){
ts->trials=0;
ts->diff=0;
ts->max=0;
}
}
/*static inline double get_mean_meas_us(time_stats_t *ts, double cpu_freq_GHz) {
return (double) ts->diff/ts->trials/cpu_freq_GHz/1000.0;
}*/
static inline double get_cpu_freq_GHz(void) {
time_stats_t ts;
reset_meas(&ts);
start_meas(&ts);
sleep(1);
stop_meas(&ts);
return (double)ts.diff/1000000000;
}
......@@ -301,10 +301,16 @@ typedef struct {
unsigned int total_dlsch_bitrate;
unsigned int total_transmitted_bits;
unsigned int total_system_throughput;
time_stats_t phy_proc;
time_stats_t phy_proc_tx;
time_stats_t phy_proc_rx;