Commit 3bd7cd2d authored by laurent's avatar laurent

initial

parent 91dd7ed4
......@@ -1825,6 +1825,7 @@ add_definitions(-DASN1_MINIMUM_VERSION=924)
# lte-softmodem is both eNB and UE implementation
###################################################
include_directories (${OPENAIR_TARGETS}/tcri)
add_executable(lte-softmodem
${rrc_h}
${s1ap_h}
......@@ -1849,6 +1850,7 @@ add_executable(lte-softmodem
${T_SOURCE}
${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES}
${OPENAIR_TARGETS}/tcri/thread-pool.c
)
target_link_libraries (lte-softmodem
......@@ -2323,3 +2325,10 @@ ADD_CUSTOM_TARGET(oarf
DEPENDS ${OCT_FILES}
)
add_executable(test_tcri
${OPENAIR_TARGETS}/tcri/thread-pool.c
${CONFIG_SOURCES}
${SHLIB_LOADER_SOURCES}
)
target_compile_definitions(test_tcri PRIVATE TESTMAIN)
target_link_libraries(test_tcri pthread PHY UTIL ${ITTI_LIB} LFDS config rt dl)
......@@ -463,7 +463,21 @@ int32_t rate_matching_lte(uint32_t N_coded,
uint8_t *inPtr,
uint32_t off);
typedef uint8_t (turboDecoder)(int16_t *y,
uint8_t *,
uint16_t,
uint16_t,
uint16_t,
uint8_t,
uint8_t,
uint8_t,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *);
/*!
\brief This routine performs max-logmap detection for the 3GPP turbo code (with termination). It is optimized for SIMD processing and 16-bit
LLR arithmetic, and requires SSE2,SSSE3 and SSE4.1 (gcc >=4.3 and appropriate CPU)
......@@ -477,21 +491,7 @@ LLR arithmetic, and requires SSE2,SSSE3 and SSE4.1 (gcc >=4.3 and appropriate CP
@param F Number of filler bits at start of packet
@returns number of iterations used (this is 1+max if incorrect crc or if crc_len=0)
*/
uint8_t phy_threegpplte_turbo_decoder16(int16_t *y,
uint8_t *decoded_bytes,
uint16_t n,
uint16_t interleaver_f1,
uint16_t interleaver_f2,
uint8_t max_iterations,
uint8_t crc_type,
uint8_t F,
time_stats_t *init_stats,
time_stats_t *alpha_stats,
time_stats_t *beta_stats,
time_stats_t *gamma_stats,
time_stats_t *ext_stats,
time_stats_t *intl1_stats,
time_stats_t *intl2_stats);
turboDecoder phy_threegpplte_turbo_decoder16;
uint8_t phy_threegpplte_turbo_decoder16avx2(int16_t *y,
int16_t *y2,
......@@ -524,21 +524,7 @@ LLR arithmetic, and requires SSE2,SSSE3 and SSE4.1 (gcc >=4.3 and appropriate CP
@param F Number of filler bits at start of packet
@returns number of iterations used (this is 1+max if incorrect crc or if crc_len=0)
*/
uint8_t phy_threegpplte_turbo_decoder8(int16_t *y,
uint8_t *decoded_bytes,
uint16_t n,
uint16_t interleaver_f1,
uint16_t interleaver_f2,
uint8_t max_iterations,
uint8_t crc_type,
uint8_t F,
time_stats_t *init_stats,
time_stats_t *alpha_stats,
time_stats_t *beta_stats,
time_stats_t *gamma_stats,
time_stats_t *ext_stats,
time_stats_t *intl1_stats,
time_stats_t *intl2_stats);
turboDecoder phy_threegpplte_turbo_decoder8;
uint8_t phy_threegpplte_turbo_decoder_scalar(int16_t *y,
uint8_t *decoded_bytes,
......
......@@ -155,7 +155,7 @@ typedef struct {
/// Concatenated "e"-sequences (for definition see 36-212 V8.6 2009-03, p.17-18)
uint8_t e[MAX_NUM_CHANNEL_BITS] __attribute__((aligned(32)));
/// Turbo-code outputs (36-212 V8.6 2009-03, p.12
uint8_t *d[MAX_NUM_DLSCH_SEGMENTS];//[(96+3+(3*6144))];
//uint8_t *d[MAX_NUM_DLSCH_SEGMENTS];//[(96+3+(3*6144))];
/// Sub-block interleaver outputs (36-212 V8.6 2009-03, p.16-17)
uint8_t w[MAX_NUM_DLSCH_SEGMENTS][3*6144];
/// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
......@@ -461,7 +461,7 @@ typedef struct {
/// Pointer to the payload
uint8_t *b;
/// Pointers to transport block segments
uint8_t *c[MAX_NUM_ULSCH_SEGMENTS];
//uint8_t *c[MAX_NUM_ULSCH_SEGMENTS];
/// RTC values for each segment (for definition see 36-212 V8.6 2009-03, p.15)
uint32_t RTC[MAX_NUM_ULSCH_SEGMENTS];
/// Current Number of Symbols
......@@ -477,9 +477,12 @@ typedef struct {
/// soft bits for each received segment ("w"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
int16_t w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)];
/// soft bits for each received segment ("d"-sequence)(for definition see 36-212 V8.6 2009-03, p.15)
int16_t *d[MAX_NUM_ULSCH_SEGMENTS];
//int16_t *d[MAX_NUM_ULSCH_SEGMENTS];
/// Number of code segments (for definition see 36-212 V8.6 2009-03, p.9)
uint32_t C;
uint32_t processedSegments;
uint32_t processedBadSegment;
/// Number of "small" code segments (for definition see 36-212 V8.6 2009-03, p.10)
uint32_t Cminus;
/// Number of "large" code segments (for definition see 36-212 V8.6 2009-03, p.10)
......
This diff is collapsed.
......@@ -34,7 +34,7 @@
#include "PHY/defs.h"
#include <math.h>
#include "nfapi_interface.h"
#include <thread-pool.h>
// Functions below implement 36-211 and 36-212
/** @addtogroup _PHY_TRANSPORT_
......@@ -122,6 +122,16 @@ int32_t dlsch_encoding(PHY_VARS_eNB *eNB,
time_stats_t *te_stats,
time_stats_t *i_stats);
int32_t dlsch_encoding2(PHY_VARS_eNB *eNB,
uint8_t *a,
uint8_t num_pdcch_symbols,
LTE_eNB_DLSCH_t *dlsch,
int frame,
uint8_t subframe,
time_stats_t *rm_stats,
time_stats_t *te_stats,
time_stats_t *i_stats);
int32_t dlsch_encoding_SIC(PHY_VARS_UE *ue,
uint8_t *a,
uint8_t num_pdcch_symbols,
......@@ -1884,12 +1894,8 @@ int32_t ulsch_encoding_emul(uint8_t *ulsch_buffer,
@param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used
@returns 0 on success
*/
unsigned int ulsch_decoding(PHY_VARS_eNB *phy_vars_eNB,
eNB_rxtx_proc_t *proc,
uint8_t UE_id,
uint8_t control_only_flag,
uint8_t Nbundled,
uint8_t llr8_flag);
ulsch_decoding_t ulsch_decoding;
/*!
\brief Decoding of ULSCH data component from 36-212. This one spawns 1 worker thread in parallel,half of the segments in each thread.
......@@ -1912,10 +1918,7 @@ int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,
@param llr8_flag If 1, indicate that the 8-bit turbo decoder should be used
@returns 0 on success
*/
int ulsch_decoding_data(PHY_VARS_eNB *eNB,
int UE_id,
int harq_pid,
int llr8_flag);
ulsch_decoding_data_t ulsch_decoding_data;
uint32_t ulsch_decoding_emul(PHY_VARS_eNB *phy_vars_eNB,
eNB_rxtx_proc_t *proc,
......
This diff is collapsed.
......@@ -1361,8 +1361,6 @@ void rx_ulsch_emul(PHY_VARS_eNB *eNB,
eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS,eNB->ulsch[UE_id]->harq_processes[harq_pid]->Qm,
eNB->ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_pusch);
//#ifndef OAI_EMU
write_output("/tmp/ulsch_d.m","ulsch_dseq",&eNB->ulsch[UE_id]->harq_processes[harq_pid]->d[0][96],
eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kplus*3,1,0);
if (eNB->common_vars.rxdata) write_output("/tmp/rxsig0.m","rxs0", &eNB->common_vars.rxdata[0][0],eNB->frame_parms.samples_per_tti*10,1,1);
if (eNB->frame_parms.nb_antennas_rx>1)
......
......@@ -56,6 +56,7 @@
#include <math.h>
#include "common_lib.h"
#include "msc.h"
#include <thread-pool.h>
#include "openair2/PHY_INTERFACE/IF_Module.h"
......@@ -196,8 +197,9 @@ enum transmission_access_mode {
POSTPONED_ACCESS,
CANCELED_ACCESS,
UNKNOWN_ACCESS,
SCHEDULED_ACCESS,
CBA_ACCESS};
SCHEDULED_ACCESS,
CBA_ACCESS
};
typedef enum {
eNodeB_3GPP=0, // classical eNodeB function
......@@ -430,6 +432,7 @@ typedef struct eNB_proc_t_s {
uint8_t CC_id;
/// thread index
int thread_index;
tpool_t threadPool;
/// timestamp received from HW
openair0_timestamp timestamp_rx;
/// timestamp to send to "slave rru"
......@@ -927,6 +930,20 @@ typedef struct {
int prach_I0;
} PHY_MEASUREMENTS_eNB;
typedef request_t *(ulsch_decoding_t)(struct PHY_VARS_eNB_s *phy_vars_eNB,
eNB_rxtx_proc_t *proc,
uint8_t UE_id,
uint8_t control_only_flag,
uint8_t Nbundled,
uint8_t llr8_flag,
int frame,
int subframe);
typedef request_t *(ulsch_decoding_data_t)(struct PHY_VARS_eNB_s *eNB,
int UE_id,
int harq_pid,
int llr8_flag,
int frame,
int subframe);
/// Top-level PHY Data Structure for eNB
typedef struct PHY_VARS_eNB_s {
......@@ -944,7 +961,8 @@ typedef struct PHY_VARS_eNB_s {
/// Ethernet parameters for fronthaul interface
eth_params_t eth_params;
int rx_total_gain_dB;
int (*td)(struct PHY_VARS_eNB_s *eNB,int UE_id,int harq_pid,int llr8_flag);
//int (*td)(struct PHY_VARS_eNB_s *eNB,int UE_id,int harq_pid,int llr8_flag);
ulsch_decoding_data_t *td;
int (*te)(struct PHY_VARS_eNB_s *,uint8_t *,uint8_t,LTE_eNB_DLSCH_t *,int,uint8_t,time_stats_t *,time_stats_t *,time_stats_t *);
int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB);
uint8_t local_flag;
......@@ -1615,6 +1633,55 @@ static inline int release_thread(pthread_mutex_t *mutex,int *instance_cnt,char *
return(0);
}
// OpenAir .h files are very very badly intricated, so we redeclare a type
// A major issue to fix in whole OAI: total crap (reprototype in .c, loops of includes, ...)
typedef uint8_t (turboDecoder)(int16_t *y,
uint8_t *,
uint16_t,
uint16_t,
uint16_t,
uint8_t,
uint8_t,
uint8_t,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *,
time_stats_t *);
typedef struct TurboDecode_s {
turboDecoder *function;
int16_t soft_bits[3*8*6144+12+96] __attribute__((aligned(32)));
uint8_t decoded_bytes[3+768] __attribute__((aligned(32)));
int UEid;
int harq_pid;
int frame;
int subframe;
int iind;
int Fbits;
int Kr;
LTE_UL_eNB_HARQ_t *ulsch_harq;
PHY_VARS_eNB *eNB;
int nbSegments;
int segment_r;
int offset;
int maxIterations;
int decodeIterations;
} turboDecode_t;
#define TURBO_SIMD_SOFTBITS 96+12+3+3*6144
typedef struct turboEncode_s {
uint8_t * input;
uint8_t output[TURBO_SIMD_SOFTBITS];
int Kr_bytes;
int filler;
int iind;
int r;
int harq_pid;
LTE_eNB_DLSCH_t *dlsch;
} turboEncode_t;
#include "PHY/INIT/defs.h"
#include "PHY/LTE_REFSIG/defs.h"
......
This diff is collapsed.
......@@ -101,6 +101,7 @@ unsigned short config_frames[4] = {2,9,11,13};
#endif
#include "lte-softmodem.h"
#include <thread-pool.h>
#ifdef XFORMS
// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0)
// at eNB 0, an UL scope for every UE
......@@ -133,6 +134,7 @@ volatile int start_UE = 0;
volatile int oai_exit = 0;
static clock_source_t clock_source = internal;
static char threadpool[1024]="";
static int wait_for_sync = 0;
static char UE_flag=0;
......@@ -1311,8 +1313,14 @@ int main( int argc, char **argv )
number_of_cards = 1;
printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst);
if (RC.nb_L1_inst > 0) {
printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", single_thread_flag,wait_for_sync);
LOG_W(PHY, "Initializing eNB threads, single thread flag= %d, clock_source=%d\n", single_thread_flag, clock_source);
init_eNB(single_thread_flag,wait_for_sync);
if ( strlen(threadpool) > 0 ) {
LOG_W(PHY, "Creating turbo codec thread pool on cores: %s\n",threadpool);
init_tpool(threadpool, &RC.eNB[0][0]->proc.threadPool);
}
else
init_tpool("n", &RC.eNB[0][0]->proc.threadPool);
// for (inst=0;inst<RC.nb_L1_inst;inst++)
// for (CC_id=0;CC_id<RC.nb_L1_CC[inst];CC_id++) phy_init_lte_eNB(RC.eNB[inst][CC_id],0,0);
}
......
......@@ -138,6 +138,7 @@ extern int16_t dlsch_demod_shift;
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define CMDLINE_PARAMS_DESC { \
{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)}, \
{"turbo-thread-pool", NULL, 0, strptr:(char **)&threadpool, defstrval:NULL, TYPE_STRING, sizeof(threadpool)}, \
{"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \
{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \
{"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \
......
#define __USE_GNU
#define _GNU_SOURCE
#include <stdio.h>
#include <pthread.h>
#include <sched.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <stdint.h>
#include <sys/stat.h>
#include <fcntl.h>
// OAI includes
uint64_t cpuCyclesMicroSec;
static __inline__ uint64_t rdtsc(void) {
uint64_t a, d;
__asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
return (d<<32) | a;
}
#include "thread-pool.h"
int main(int argc, char* argv[]) {
uint64_t deb=rdtsc();
usleep(100000);
cpuCyclesMicroSec=(rdtsc()-deb)/100000;
printf("Cycles per µs: %lu\n",cpuCyclesMicroSec);
#define SEP " "
printf("Frame" SEP "SubFrame" SEP "CodeBlock" SEP "RNTI" SEP "Iterations" SEP
"StartTime" SEP "RunTime" SEP "ReturnTime" SEP
"CPUcore" SEP "ThreadID" "\n");
mkfifo("/tmp/test-tcri",0666);
int fd=open("/tmp/test-tcri", O_RDONLY);
if ( fd == -1 ) {
perror("open read mode trace file:");
exit(1);
}
request_t doneRequest;
int s=sizeof(request_t) -2*sizeof(void*);
while ( 1 ) {
if ( read(fd,&doneRequest, s) == s ) {
union turboReqUnion id={.p=doneRequest.id};
doneRequest.processedBy[15]='\0';
printf("%u" SEP "%u" SEP "%u" SEP "%u" SEP "%lu" SEP
"%lu" SEP "%lu" SEP "%lu" SEP
"%u" SEP "%s" "\n",
id.s.frame,
id.s.subframe,
id.s.codeblock,
id.s.rnti,
doneRequest.decodeIterations,
(doneRequest.startProcessingTime-doneRequest.creationTime)/cpuCyclesMicroSec,
(doneRequest.endProcessingTime-doneRequest.startProcessingTime)/cpuCyclesMicroSec,
(doneRequest.returnTime-doneRequest.endProcessingTime)/cpuCyclesMicroSec,
doneRequest.coreId,
doneRequest.processedBy
);
} else {
printf("no measurements\n");
sleep(1);
}
}
}
This diff is collapsed.
#ifndef THREAD_POOL_H
#define THREAD_POOL_H
#include <stdbool.h>
#include <openair2/COMMON/platform_types.h>
enum request_t {
DECODE,
ENCODE
};
struct turboReqId {
uint16_t rnti;
uint16_t frame;
uint8_t subframe;
uint8_t codeblock;
uint16_t spare;
} __attribute__((packed));
union turboReqUnion {
struct turboReqId s;
uint64_t p;
};
typedef struct request {
uint64_t id;
enum request_t type;
uint64_t creationTime;
uint64_t startProcessingTime;
uint64_t endProcessingTime;
uint64_t returnTime;
uint64_t decodeIterations;
int coreId;
char processedBy[16];
struct request* next;
void * data __attribute__((aligned(32)));
} request_t;
struct one_thread {
pthread_t threadID;
int id;
int coreID;
char name[256];
struct thread_pool * pool;
struct one_thread* next;
};
typedef struct thread_pool {
int activated;
pthread_mutex_t lockRequests;
pthread_cond_t notifRequest;
pthread_mutex_t lockReportDone;
pthread_cond_t notifDone;
request_t* oldestRequests;
request_t* newestRequests;
request_t* doneRequests;
int notFinishedJobs;
int traceFd;
int dummyTraceFd;
uint64_t cpuCyclesMicroSec;
int nbThreads;
bool restrictRNTI;
struct one_thread * allthreads;
} tpool_t;
void init_tpool(char*,tpool_t* );
request_t * createRequest(enum request_t type,int size);
void freeRequest(request_t* request);
int add_request(request_t* request, tpool_t * tp);
request_t * searchRNTI(tpool_t*, rnti_t rnti);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment