Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
canghaiwuhen
OpenXG-RAN
Commits
84de00ed
Commit
84de00ed
authored
May 13, 2020
by
OpInConnect_NCTU Terngyin/NY/GK/KM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dual thread for pdsch
parent
b18bfe24
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
344 additions
and
53 deletions
+344
-53
openair1/PHY/CODING/TESTBENCH/ldpctest.c
openair1/PHY/CODING/TESTBENCH/ldpctest.c
+0
-11
openair1/PHY/NR_TRANSPORT/nr_dlsch.c
openair1/PHY/NR_TRANSPORT/nr_dlsch.c
+54
-8
openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
+91
-9
openair1/PHY/defs_gNB.h
openair1/PHY/defs_gNB.h
+45
-1
openair1/SIMULATION/NR_PHY/dlsim.c
openair1/SIMULATION/NR_PHY/dlsim.c
+154
-24
No files found.
openair1/PHY/CODING/TESTBENCH/ldpctest.c
View file @
84de00ed
...
...
@@ -103,17 +103,6 @@ uint16_t NB_UE_INST = 1;
short
lift_size
[
51
]
=
{
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
18
,
20
,
22
,
24
,
26
,
28
,
30
,
32
,
36
,
40
,
44
,
48
,
52
,
56
,
60
,
64
,
72
,
80
,
88
,
96
,
104
,
112
,
120
,
128
,
144
,
160
,
176
,
192
,
208
,
224
,
240
,
256
,
288
,
320
,
352
,
384
};
/*! \file openair1/PHY/CODING/TESTBENCH/ldpctest.c
* \brief NCTU OpInConnect
* \author Terngyin Hsu, Sendren Xu, Nungyi Kuo, Kuankai Hsiung, Kaimi Yang (OpInConnect_NCTU)
* \email tyhsu@cs.nctu.edu.tw
* \date 13-05-2020
* \version 2.0
* \note
* \warning
*/
// ==[START]multi_lpdc_encoder
struct
timespec
start_ts
,
end_ts
,
start_per_ts
,
end_per_ts
,
start_enc_ts
[
thread_num_max
],
end_enc_ts
[
thread_num_max
],
start_perenc_ts
[
thread_num_max
],
end_perenc_ts
[
thread_num_max
];
multi_ldpc_encoder
ldpc_enc
[
thread_num_max
];
...
...
openair1/PHY/NR_TRANSPORT/nr_dlsch.c
View file @
84de00ed
...
...
@@ -29,6 +29,17 @@
* \note
* \warning
*/
/*!\file PHY/NR_TRANSPORT/dlsch_decoding.c
* \brief Add triggers for dual thread
* \author Terngyin, NY, GK, KM (OpInConnect_NCTU)
* \email tyhsu@cs.nctu.edu.tw
* \date 24-04-2020
* \version 1.1
* \note
* \warning
*/
//pipeline scrambling and modulation from Ian
#include "PHY/phy_extern.h"
#include "PHY/defs_gNB.h"
...
...
@@ -43,10 +54,10 @@
void
nr_pdsch_codeword_scrambling
(
uint8_t
*
in
,
uint32_t
size
,
uint8_t
q
,
uint8_t
q
,
//use q
uint32_t
Nid
,
uint32_t
n_RNTI
,
uint32_t
*
out
)
{
uint32_t
*
out
)
{
//use q => scrambled_output[q]
uint8_t
reset
,
b_idx
;
uint32_t
x1
,
x2
,
s
=
0
;
...
...
@@ -89,7 +100,7 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch,
NR_DL_gNB_HARQ_t
*
harq
=
dlsch
->
harq_processes
[
dci_alloc
->
harq_pid
];
nfapi_nr_dl_config_dlsch_pdu_rel15_t
*
rel15
=
&
harq
->
dlsch_pdu
.
dlsch_pdu_rel15
;
nfapi_nr_dl_config_pdcch_parameters_rel15_t
pdcch_params
=
dci_alloc
->
pdcch_params
;
uint32_t
scrambled_output
[
NR_MAX_NB_CODEWORDS
][
NR_MAX_PDSCH_ENCODED_LENGTH
>>
5
];
uint32_t
scrambled_output
[
NR_MAX_NB_CODEWORDS
][
NR_MAX_PDSCH_ENCODED_LENGTH
>>
5
];
//NR_MAX_NB_CODEWORDS 2
int16_t
**
mod_symbs
=
(
int16_t
**
)
dlsch
->
mod_symbs
;
int16_t
**
tx_layers
=
(
int16_t
**
)
dlsch
->
txdataF
;
int8_t
Wf
[
2
],
Wt
[
2
],
l0
,
l_prime
[
2
],
delta
;
...
...
@@ -108,9 +119,10 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t *dlsch,
/// CRC, coding, interleaving and rate matching
AssertFatal
(
harq
->
pdu
!=
NULL
,
"harq->pdu is null
\n
"
);
start_meas
(
dlsch_encoding_stats
);
nr_dlsch_encoding
(
harq
->
pdu
,
frame
,
slot
,
dlsch
,
frame_parms
);
nr_dlsch_encoding
(
harq
->
pdu
,
frame
,
slot
,
dlsch
,
frame_parms
);
//the way to encoder
stop_meas
(
dlsch_encoding_stats
);
#ifdef DEBUG_DLSCH
//printf("rel15->nb_codewords : %d\n", rel15->nb_codewords);
#ifdef DEBUG_DLSCH // ==Show original payload & encoded payload ==***
printf
(
"PDSCH encoding:
\n
Payload:
\n
"
);
uint32_t
encoded_length
=
nb_symbols
*
Qm
;
for
(
int
i
=
0
;
i
<
harq
->
B
>>
7
;
i
++
)
{
...
...
@@ -127,7 +139,8 @@ for (int i=0; i<encoded_length>>3; i++) {
printf
(
"
\n
"
);
#endif
long
sum
=
0
;
#ifdef thread_for_scrambling_modulation
#if 0
//#ifdef thread_for_scrambling_modulation //the way to scrambling & modulation
// for(int j = 0;j<100;j++){
gNB->complete_scrambling_and_modulation = 0;
gNB->complete_modulation = 0;
...
...
@@ -150,7 +163,7 @@ printf("\n");
// }
// printf("averge time = %ld\n",sum/100);
#else
#else
if
0
//original
/// scrambling
start_meas
(
dlsch_scrambling_stats
);
//printf("nb_codewords = %d encoded_length = %d\n",rel15->nb_codewords,encoded_length);
...
...
@@ -195,8 +208,41 @@ for (int i=0; i<nb_symbols>>3; i++) {
printf
(
"
\n
"
);
}
#endif
#endif
//[START]multi_genetate_pdsch_proc
struct
timespec
start_ts
,
end_ts
;
for
(
int
q
=
0
;
q
<
rel15
->
nb_codewords
;
q
++
)
// ==Look out!NR_MAX_NB_CODEWORDS is 2!So we can't let q>2 until spec change
memset
((
void
*
)
scrambled_output
[
q
],
0
,
(
encoded_length
>>
5
)
*
sizeof
(
uint32_t
));
uint16_t
n_RNTI
=
(
pdcch_params
.
search_space_type
==
NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC
)
?
((
pdcch_params
.
scrambling_id
==
0
)
?
pdcch_params
.
rnti
:
0
)
:
0
;
uint16_t
Nid
=
(
pdcch_params
.
search_space_type
==
NFAPI_NR_SEARCH_SPACE_TYPE_UE_SPECIFIC
)
?
pdcch_params
.
scrambling_id
:
config
->
sch_config
.
physical_cell_id
.
value
;
printf
(
"================[Scr_Mod]================
\n
"
);
printf
(
" [Movement] [No.] [Round] [Cost time]
\n
"
);
//Get value
for
(
int
q
=
0
;
q
<
2
;
q
++
){
gNB
->
multi_encoder
[
q
].
f
=
harq
->
f
;
gNB
->
multi_encoder
[
q
].
encoded_length
=
encoded_length
;
gNB
->
multi_encoder
[
q
].
Nid
=
Nid
;
gNB
->
multi_encoder
[
q
].
n_RNTI
=
n_RNTI
;
gNB
->
multi_encoder
[
q
].
scrambled_output
=
scrambled_output
[
q
];
// ==Need to change ==***
gNB
->
multi_encoder
[
q
].
Qm
=
Qm
;
gNB
->
multi_encoder
[
q
].
mod_symbs
=
mod_symbs
[
q
];
// ==Need to change ==***
}
//Awake threads
clock_gettime
(
CLOCK_MONOTONIC
,
&
start_ts
);
//timing
for
(
int
q
=
0
;
q
<
2
;
q
++
){
pthread_cond_signal
(
&
(
gNB
->
multi_encoder
[
q
].
cond_scr_mod
));
}
//Wait threads
for
(
int
q
=
0
;
q
<
2
;
q
++
){
while
(
gNB
->
multi_encoder
[
q
].
complete_scr_mod
!=
1
);
}
clock_gettime
(
CLOCK_MONOTONIC
,
&
end_ts
);
//timing
//printf(" Movement No. Round Cost time \n");
printf
(
" Total %.2f usec
\n
"
,
(
end_ts
.
tv_nsec
-
start_ts
.
tv_nsec
)
*
1
.
0
/
1000
);
//[END]multi_genetate_pdsch_proc
/// Layer mapping
nr_layer_mapping
(
mod_symbs
,
rel15
->
nb_layers
,
...
...
openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c
View file @
84de00ed
...
...
@@ -30,6 +30,16 @@
* \warning
*/
/*!\file PHY/NR_TRANSPORT/dlsch_coding.c
* \brief Add triggers for dual thread
* \author Terngyin, NY, GK, KM (OpInConnect_NCTU)
* \email tyhsu@cs.nctu.edu.tw
* \date 24-04-2020
* \version 1.1
* \note
* \warning
*/
#include "PHY/defs_gNB.h"
#include "PHY/phy_extern.h"
#include "PHY/CODING/coding_extern.h"
...
...
@@ -44,6 +54,9 @@
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "common/utils/LOG/log.h"
#include <syscall.h>
#include <time.h>
//multi_ldpc_encoder ldpc_enc[thread_num_max]; //things in ldpc_encoder
//#define DEBUG_DLSCH_CODING
//#define DEBUG_DLSCH_FREE 1
...
...
@@ -273,22 +286,30 @@ void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch)
}
}
int
nr_dlsch_encoding
(
unsigned
char
*
a
,
int
nr_dlsch_encoding
(
unsigned
char
*
a
,
//harq->pdu => dlsch->harq_processes[harq_pid]->b
int
frame
,
uint8_t
slot
,
NR_gNB_DLSCH_t
*
dlsch
,
NR_DL_FRAME_PARMS
*
frame_parms
)
{
/*
PHY_VARS_gNB *gNB = RC.gNB[0][0];
gNB->complete_encode[0] = 0;
gNB->complete_encode[1] = 0;
gNB->complete_encode[2] = 0;
gNB->complete_encode[3] = 0;
clock_gettime(CLOCK_MONOTONIC, &start_ts);//timing
for (int t = 0; t < 4; t++){
pthread_cond_signal(&gNB->thread_encode[t].cond_encode);
}
while((gNB->complete_encode[0] != 1) || (gNB->complete_encode[1] != 1) || (gNB->complete_encode[2] != 1) || (gNB->complete_encode[3] != 1));
/*
clock_gettime(CLOCK_MONOTONIC, &end_ts);//timing
printf("%.2f usec\n", (end_ts.tv_nsec - start_ts.tv_nsec) *1.0 / 1000);
*/
PHY_VARS_gNB
*
gNB
=
RC
.
gNB
[
0
][
0
];
// ==check it! ==***
struct
timespec
start_ts
,
end_ts
;
unsigned
int
G
;
unsigned
int
crc
=
1
;
uint8_t
harq_pid
=
dlsch
->
harq_ids
[
frame
&
2
][
slot
];
...
...
@@ -311,14 +332,14 @@ int nr_dlsch_encoding(unsigned char *a,
uint16_t
length_dmrs
=
1
;
float
Coderate
=
0
.
0
;
uint8_t
Nl
=
4
;
*/
/*
uint8_t *channel_input[MAX_NUM_DLSCH_SEGMENTS]; //unsigned char
for(j=0;j<MAX_NUM_DLSCH_SEGMENTS;j++) {
channel_input[j] = (unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
}
*/
/*
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(
VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING
,
VCD_FUNCTION_IN
);
A
=
rel15
.
transport_block_size
;
...
...
@@ -332,7 +353,7 @@ int nr_dlsch_encoding(unsigned char *a,
#ifdef DEBUG_DLSCH_CODING
printf
(
"encoding thinks this is a new packet
\n
"
);
#endif
*/
/*
int i;
printf("dlsch (tx): \n");
...
...
@@ -340,7 +361,7 @@ int nr_dlsch_encoding(unsigned char *a,
printf("%02x.",a[i]);
printf("\n");
*/
/*
if
(
A
>
3824
)
{
// Add 24-bit crc (polynomial A) to payload
crc
=
crc24a
(
a
,
A
)
>>
8
;
...
...
@@ -418,9 +439,70 @@ int nr_dlsch_encoding(unsigned char *a,
//ldpc_encoder_optim((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][0],*Zc,Kb,Kr,BG,NULL,NULL,NULL,NULL);
}
for(int j=0;j<(dlsch->harq_processes[harq_pid]->C/8+1);j++) {
ldpc_encoder_optim_8seg_multi(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,*Zc,Kb,Kr,BG,dlsch->harq_processes[harq_pid]->C,j,NULL,NULL,NULL,NULL);
}
//[START]Get value & Awake threads & Wait threads finish
// clock_gettime(CLOCK_MONOTONIC, &start_ts); //timing
// for(int i=0;i<2;i++)
// for(int j=0;j<(dlsch->harq_processes[harq_pid]->C/8+1);j++) {
// ldpc_encoder_optim_8seg_multi(dlsch->harq_processes[harq_pid]->c,dlsch->harq_processes[harq_pid]->d,*Zc,Kb,Kr,BG,dlsch->harq_processes[harq_pid]->C,j,NULL,NULL,NULL,NULL);
// }
// clock_gettime(CLOCK_MONOTONIC, &end_ts); //timing
// //printf(" Movement No. Round Cost time \n");
// printf(" Total Single %.2f usec\n", (end_ts.tv_nsec - start_ts.tv_nsec) *1.0 / 1000);
/*get value*/
for
(
int
th
=
0
;
th
<
2
;
th
++
){
gNB
->
multi_encoder
[
th
].
test_input
=
dlsch
->
harq_processes
[
harq_pid
]
->
c
;
gNB
->
multi_encoder
[
th
].
channel_input_optim
=
dlsch
->
harq_processes
[
harq_pid
]
->
d
;
gNB
->
multi_encoder
[
th
].
Zc
=
*
Zc
;
gNB
->
multi_encoder
[
th
].
Kb
=
Kb
;
gNB
->
multi_encoder
[
th
].
block_length
=
Kr
;
gNB
->
multi_encoder
[
th
].
BG
=
BG
;
gNB
->
multi_encoder
[
th
].
n_segments
=
dlsch
->
harq_processes
[
harq_pid
]
->
C
;
}
/*cpy c to c_test*/
// unsigned char bw_scaling =2; // ==Need to change ==***
// for(int r=0;r<MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling;r++){
// dlsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448);
// dlsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output
// }
// for(int th=0;th<2;th++){
// for(int j=0;j<MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling;j++){ // ==Why can not just be MAX_NUM_NR_DLSCH_SEGMENTS ==???
// gNB->multi_encoder[th].c_test[j]=(uint8_t*)malloc16(8448);//(unsigned char *)malloc16(sizeof(unsigned char) * Kr/8);
// gNB->multi_encoder[th].d_test[j]=(uint8_t*)malloc16(68*384);//(unsigned char *)malloc16(sizeof(unsigned char) * 68*384);
// memcpy(gNB->multi_encoder[th].c_test[j], dlsch->harq_processes[harq_pid]->c[j], 8448); // ==Check 8448 ==***
// }
// }
/*Show c_test*/
// printf("c_test :\n");
// for (int i=0; i<3; i++){
// printf("%d", dlsch->harq_processes[harq_pid]->c[0][i]);
// printf("/%d\n", gNB->multi_encoder[0].c_test[0][i]);
// }
// printf("c_test ptr :\n");
// for (int i=0; i<3; i++){
// printf("%p", &dlsch->harq_processes[harq_pid]->c[0][i]);
// printf("/%p\n", &gNB->multi_encoder[0].c_test[0][i]);
// }
printf
(
"================[Encoder]================
\n
"
);
printf
(
" [Movement] [No.] [Round] [Cost time]
\n
"
);
clock_gettime
(
CLOCK_MONOTONIC
,
&
start_ts
);
//timing
for
(
int
th
=
0
;
th
<
2
;
th
++
){
pthread_cond_signal
(
&
(
gNB
->
multi_encoder
[
th
].
cond
));
}
for
(
int
th
=
0
;
th
<
2
;
th
++
){
while
(
gNB
->
multi_encoder
[
th
].
complete
!=
1
);
// ==check if multi_ldpc_enc done ==
}
clock_gettime
(
CLOCK_MONOTONIC
,
&
end_ts
);
//timing
//printf(" Movement No. Round Cost time \n");
printf
(
" Total %.2f usec
\n
"
,
(
end_ts
.
tv_nsec
-
start_ts
.
tv_nsec
)
*
1
.
0
/
1000
);
// for(int th = 0;th<2;th++){
// pthread_mutex_destroy(&gNB->multi_encoder[th].mutex);
// pthread_join(gNB->multi_encoder[th].pthread, NULL);
// }
//[END]Get value & Awake threads & Wait threads finish
#ifdef DEBUG_DLSCH_CODING
...
...
@@ -493,6 +575,6 @@ int nr_dlsch_encoding(unsigned char *a,
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(
VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING
,
VCD_FUNCTION_OUT
);
*/
return
0
;
}
openair1/PHY/defs_gNB.h
View file @
84de00ed
...
...
@@ -30,6 +30,16 @@
\warning
*/
/*! \file PHY/defs_gNB.h
* \brief Add defines and structure for dual thread
* \author Terngyin, NY, GK, KM (OpInConnect_NCTU)
* \email tyhsu@cs.nctu.edu.tw
* \date 24-04-2020
* \version 1.1
* \note
* \warning
*/
#ifndef __PHY_DEFS_GNB__H__
#define __PHY_DEFS_GNB__H__
...
...
@@ -43,8 +53,41 @@
#include "PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.h"
#include "PHY/CODING/nrLDPC_decoder/nrLDPC_types.h"
#include "common/utils/LOG/vcd_signal_dumper.h" //VCD
#define MAX_NUM_RU_PER_gNB MAX_NUM_RU_PER_eNB
typedef
struct
{
/*params of thread*/
int
id
;
volatile
int
flag_wait
;
pthread_t
pthread
;
pthread_cond_t
cond
;
pthread_cond_t
cond_scr_mod
;
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex_scr_mod
;
pthread_attr_t
attr
;
volatile
uint8_t
complete
;
volatile
uint8_t
complete_scr_mod
;
/*encoder*/
unsigned
char
**
test_input
;
unsigned
char
**
channel_input_optim
;
int
Zc
;
int
Kb
;
short
block_length
;
short
BG
;
int
n_segments
;
//unsigned int macro_num; //Not necessary to do
/*scrambling & modulation*/
uint8_t
*
f
;
uint32_t
*
scrambled_output
;
int16_t
*
mod_symbs
;
uint32_t
encoded_length
;
uint16_t
Nid
;
uint16_t
n_RNTI
;
uint8_t
Qm
;
}
multi_ldpc_encoder_gNB
;
typedef
struct
{
uint32_t
pbch_a
;
uint32_t
pbch_a_interleaved
;
...
...
@@ -874,6 +917,7 @@ typedef struct PHY_VARS_gNB_s {
//**************************DLSCH ENCODING**************************//
dlsch_encoding_ISIP
thread_encode
[
4
];
ldpc_encoding_ISIP
ldpc_encode
;
multi_ldpc_encoder_gNB
multi_encoder
[
2
];
volatile
uint8_t
complete_encode
[
4
];
...
...
openair1/SIMULATION/NR_PHY/dlsim.c
View file @
84de00ed
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment