From f55a4dd8e0e413c60a54f3ea1dfeb99b08e440cb Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Mon, 23 Nov 2020 16:45:59 +0100 Subject: [PATCH 1/6] Remove hard-coding of no of threads Script added to set the no of threads according to run-time conditions of the machine. --- executables/nr-gnb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 7f01ce6745..1a7a6aa373 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -869,7 +869,14 @@ void init_gNB_proc(int inst) { gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); - char ul_pool[] = "-1,-1"; + int numCPU = sysconf(_SC_NPROCESSORS_ONLN); + char ul_pool[80]; + sprintf(ul_pool,"%d",1); + int s_offset = 0; + for (int icpu=2; icputhreadPool, false); initNotifiedFIFO(gNB->respDecode); } From 80ea03931c762437fe9aeb91ab96f60dfa894fe8 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Tue, 24 Nov 2020 14:59:15 +0100 Subject: [PATCH 2/6] Added no of thread to config file The thread count would me minimum of (no of cores in the machine) or (parameter mentioned in config file) --- executables/nr-gnb.c | 9 +++++---- executables/thread-common.h | 4 ++++ openair1/PHY/defs_common.h | 1 + .../CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 1a7a6aa373..88351c9d5e 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -870,12 +870,13 @@ void init_gNB_proc(int inst) { gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); int numCPU = sysconf(_SC_NPROCESSORS_ONLN); + int threadCnt = min(numCPU, get_uldeocde_thread_count()); char ul_pool[80]; - sprintf(ul_pool,"%d",1); + sprintf(ul_pool,"-1"); int s_offset = 0; - for (int icpu=2; icputhreadPool, false); initNotifiedFIFO(gNB->respDecode); diff --git a/executables/thread-common.h b/executables/thread-common.h index 6f3af3cfc0..c5e8587e77 100644 --- a/executables/thread-common.h +++ b/executables/thread-common.h @@ -39,4 +39,8 @@ static inline WORKER_CONF_t get_thread_worker_conf(void) { return thread_struct.worker_conf; } +static inline uint8_t get_uldeocde_thread_count(void) { + return thread_struct.numULProcThreads; +} + #endif diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h index 27765a8548..e7cc5923ba 100644 --- a/openair1/PHY/defs_common.h +++ b/openair1/PHY/defs_common.h @@ -891,6 +891,7 @@ typedef enum { typedef struct THREAD_STRUCT_s { PARALLEL_CONF_t parallel_conf; WORKER_CONF_t worker_conf; + uint8_t numULProcThreads; } THREAD_STRUCT; typedef enum {SF_DL, SF_UL, SF_S} lte_subframe_t; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index 6f081fa24f..255cfb08dc 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -260,6 +260,7 @@ THREAD_STRUCT = ( parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" worker_config = "WORKER_ENABLE"; + numULProcThreads = 8; } ); From f9c3ff3ca3839b0c9d555d8a249ebeff8297b187 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Wed, 25 Nov 2020 11:12:32 +0100 Subject: [PATCH 3/6] Updated the config files --- executables/nr-gnb.c | 6 ++++-- executables/nr-softmodem.c | 2 ++ executables/thread-common.h | 4 ---- openair1/PHY/defs_common.h | 1 - openair2/GNB_APP/gnb_paramdef.h | 5 ++++- .../CONF/gnb.band78.tm1.106PRB.usrpn300.conf | 2 +- targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf | 1 + 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 88351c9d5e..2f3c89f5e4 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -100,6 +100,8 @@ extern int transmission_mode; extern uint16_t sf_ahead; extern uint16_t sl_ahead; + +extern uint32_t num_threads_pusch; //pthread_t main_gNB_thread; time_stats_t softmodem_stats_mt; // main thread @@ -870,11 +872,11 @@ void init_gNB_proc(int inst) { gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); int numCPU = sysconf(_SC_NPROCESSORS_ONLN); - int threadCnt = min(numCPU, get_uldeocde_thread_count()); + int threadCnt = min(numCPU, num_threads_pusch); char ul_pool[80]; sprintf(ul_pool,"-1"); int s_offset = 0; - for (int icpu=2; icpu Date: Fri, 27 Nov 2020 14:48:11 +0100 Subject: [PATCH 4/6] resolved build error --- openair1/SIMULATION/NR_PHY/dlsim.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index f311e0eefa..f4b3e48ffc 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -75,6 +75,7 @@ rlc_info_t Rlc_info_um,Rlc_info_am_config; PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +uint32_t num_threads_pusch; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; double cpuf; From 24bf54b2af95453eac02855cf32c8cc71e937966 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Mon, 30 Nov 2020 11:44:31 +0100 Subject: [PATCH 5/6] fixed one more build error --- openair1/SIMULATION/NR_PHY/ulsim.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index d924f7ef34..43162e7e15 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -71,6 +71,7 @@ rlc_info_t Rlc_info_um,Rlc_info_am_config; PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; +uint32_t num_threads_pusch; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; int sf_ahead=4 ; From e5cd573ecb95eb71217b935e48c1248dcd8494a0 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Fri, 4 Dec 2020 15:10:58 +0100 Subject: [PATCH 6/6] Added a local variable instead of global --- executables/nr-gnb.c | 5 ++++- executables/nr-softmodem.c | 2 -- openair1/SIMULATION/NR_PHY/dlsim.c | 1 - openair1/SIMULATION/NR_PHY/ulsim.c | 1 - openair2/GNB_APP/gnb_paramdef.h | 7 +++++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 2f3c89f5e4..2c01d458ac 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -71,6 +71,7 @@ #include "common/utils/LOG/vcd_signal_dumper.h" #include "UTIL/OPT/opt.h" #include "enb_config.h" +#include "gnb_paramdef.h" #ifndef OPENAIR2 @@ -101,7 +102,6 @@ extern int transmission_mode; extern uint16_t sf_ahead; extern uint16_t sl_ahead; -extern uint32_t num_threads_pusch; //pthread_t main_gNB_thread; time_stats_t softmodem_stats_mt; // main thread @@ -872,6 +872,9 @@ void init_gNB_proc(int inst) { gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); gNB->respDecode = (notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); int numCPU = sysconf(_SC_NPROCESSORS_ONLN); + uint32_t num_threads_pusch; + paramdef_t PUSCHThreads[] = NUM_THREADS_DESC; + config_get( PUSCHThreads,sizeof(PUSCHThreads)/sizeof(paramdef_t),NULL); int threadCnt = min(numCPU, num_threads_pusch); char ul_pool[80]; sprintf(ul_pool,"-1"); diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index adda039eaf..8271e66e2f 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -98,8 +98,6 @@ int config_sync_var=-1; volatile int start_gNB = 0; volatile int oai_exit = 0; -uint32_t num_threads_pusch; - static int wait_for_sync = 0; unsigned int mmapped_dma=0; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index f4b3e48ffc..f311e0eefa 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -75,7 +75,6 @@ rlc_info_t Rlc_info_um,Rlc_info_am_config; PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; -uint32_t num_threads_pusch; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; double cpuf; diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 43162e7e15..d924f7ef34 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -71,7 +71,6 @@ rlc_info_t Rlc_info_um,Rlc_info_am_config; PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; -uint32_t num_threads_pusch; int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; int sf_ahead=4 ; diff --git a/openair2/GNB_APP/gnb_paramdef.h b/openair2/GNB_APP/gnb_paramdef.h index d892e667d4..ec1ee01b10 100644 --- a/openair2/GNB_APP/gnb_paramdef.h +++ b/openair2/GNB_APP/gnb_paramdef.h @@ -50,7 +50,6 @@ extern int asn_debug; extern int asn1_xer_print; -extern uint32_t num_threads_pusch; #ifdef LIBCONFIG_LONG #define libconfig_int long @@ -91,9 +90,13 @@ typedef enum { /*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define GNBSPARAMS_DESC { \ {GNB_CONFIG_STRING_ASN1_VERBOSITY, NULL, 0, uptr:NULL, defstrval:GNB_CONFIG_STRING_ASN1_VERBOSITY_NONE, TYPE_STRING, 0}, \ -{GNB_CONFIG_STRING_ACTIVE_GNBS, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRINGLIST, 0}, \ +{GNB_CONFIG_STRING_ACTIVE_GNBS, NULL, 0, uptr:NULL, defstrval:NULL, TYPE_STRINGLIST, 0} \ +} + +#define NUM_THREADS_DESC { \ {GNB_CONFIG_PUSCH_THREADS, NULL, 0, uptr:&num_threads_pusch, defuintval:1, TYPE_UINT, 0} \ } + #define GNB_ASN1_VERBOSITY_IDX 0 #define GNB_ACTIVE_GNBS_IDX 1