-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProcessing_Time_Measurement_timeit.m
298 lines (240 loc) · 8.3 KB
/
Processing_Time_Measurement_timeit.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
% Measure the processing time with timeit function.
% It seems to be more accurate to me (Personal Opinion)
j=sqrt(-1);
% 4x4 MIMO, 4 Streams
nS=4; %number of streams
nT=4; %number of transmit antenna
nR=4; %number of receive antenna
% 4x2 MIMO, 2 Streams
% nS=2; %number of streams
% nT=2; %number of transmit antenna
% nR=4; %number of receive antenna
k=4; %2,4,6
frame_size=nS*k; %bits
seed = 6807;
symbol_vector_num = 1000;
EbNo_lvl = 28; % originally 25
prs_time_ML = zeros(1,symbol_vector_num);
rng('default');
rng(seed);
for i=1:symbol_vector_num
bits=randn(1,frame_size);
neg_idx=find(bits<0);
bits=ones(1,frame_size);
bits(neg_idx)=0;
%QAM mapping
x=QAM_mapper(bits,k);
x=transpose(x);%row->column
%noise variance calculation
n_var=10^(-EbNo_lvl/10)/k;
%wireless transmission
%Rayleigh fading channel
H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nR)+j*randn(nR,nR));
% Select Precoder
% mlf = @() precoder_select_ML_kim_ver1(H, nS);
% mlf = @() precoder_select_ML_kim_ver2(H, nS);
mlf = @() precoder_select_ML_kim_ver3(H, nS);
% mlf = @() precoder_select_ML_ver6(H,nS);
% mlf = @() precoder_select_ML_ver6_rev1(H,nS);
% mlf = @() precoder_select_ML_ver7p2(H,nS);
% mlf = @() precoder_select_ML_ver6_complex(H,nS);
% mlf = @() precoder_select_ML_ver6_complex_ver1(H, nS);
prs_time_ML(i) = timeit(mlf);
end
prs_time_SML = zeros(1,symbol_vector_num);
rng('default');
rng(seed);
for i=1:symbol_vector_num
bits=randn(1,frame_size);
neg_idx=find(bits<0);
bits=ones(1,frame_size);
bits(neg_idx)=0;
%QAM mapping
x=QAM_mapper(bits,k);
x=transpose(x);%row->column
%noise variance calculation
n_var=10^(-EbNo_lvl/10)/k;
%wireless transmission
%Rayleigh fading channel
H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nR)+j*randn(nR,nR));
% H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nT)+j*randn(nR,nT));
% Select Precoder
smlf = @() Simplified_ML_Precoder_Selection(H, nS);
prs_time_SML(i) = timeit(smlf);
end
prs_time_QRD = zeros(1,symbol_vector_num);
rng('default');
rng(seed);
for i=1:symbol_vector_num
bits=randn(1,frame_size);
neg_idx=find(bits<0);
bits=ones(1,frame_size);
bits(neg_idx)=0;
%QAM mapping
x=QAM_mapper(bits,k);
x=transpose(x);%row->column
%noise variance calculation
n_var=10^(-EbNo_lvl/10)/k;
%wireless transmission
%Rayleigh fading channel
H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nR)+j*randn(nR,nR));
% H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nT)+j*randn(nR,nT));
% Select Precoder
qrd_f = @() QRD_based_Method(H, nS);
prs_time_QRD(i) = timeit(qrd_f);
end
prs_time_SVD = zeros(1,symbol_vector_num);
rng('default');
rng(seed);
for i=1:symbol_vector_num
bits=randn(1,frame_size);
neg_idx=find(bits<0);
bits=ones(1,frame_size);
bits(neg_idx)=0;
%QAM mapping
x=QAM_mapper(bits,k);
x=transpose(x);%row->column
%noise variance calculation
n_var=10^(-EbNo_lvl/10)/k;
%wireless transmission
%Rayleigh fading channel
H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nR)+j*randn(nR,nR));
% H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nT)+j*randn(nR,nT));
% Select Precoder
qrd_f = @() SVD_based_Method(H, nS);
prs_time_SVD(i) = timeit(qrd_f);
end
perms_array = perms(1:1:nS).';
[perms_size_case, perm_size_total] = size(perms_array);
perms_idx_refer = zeros(1, 10^(perms_size_case-1) * (perms_size_case+1));
for i = 1:perm_size_total
if perms_size_case == 2
perms_idx = perms_array(1,i) * 10 +perms_array(2,i);
elseif perms_size_case == 3
perms_idx = perms_array(1,i) * 100 + perms_array(2,i) * 10 +perms_array(3,i);
else
% Considered only perms_size_case == 4
perms_idx = perms_array(1,i) * 1000 + perms_array(2,i) * 100 +perms_array(3,i) * 10 + perms_array(4,i);
end
perms_idx_refer(perms_idx) = i;
end
if nS ~= 2
perms_tree = zeros(2, perm_size_total);
perms_queue = zeros(size(perms_array));
tree_idx = 1; queue_curr_idx = 1;
perms_queue(:, queue_curr_idx) = perms_array(:, 1);
tree_checker = zeros(1, perm_size_total);
while queue_curr_idx ~= 0
perms_pattern = perms_queue(: , queue_curr_idx);
queue_curr_idx = queue_curr_idx - 1;
perms_idx = perms_pattern(1) * 1000 + perms_pattern(2) * 100 +perms_pattern(3) * 10 + perms_pattern(4);
parent_checker_idx = perms_idx_refer(perms_idx);
if parent_checker_idx == 1
tree_checker(1) = true;
perms_tree(1, tree_idx) = 1; % child
perms_tree(2, tree_idx) = 1; % parent
tree_idx = tree_idx + 1;
end
for w=1:perms_size_case-1
swapped_pattern = perms_pattern;
% Swap
temp_element = swapped_pattern(w+1);
swapped_pattern(w+1) = swapped_pattern(w);
swapped_pattern(w) = temp_element;
swapped_perms_idx = swapped_pattern(1) * 1000 + swapped_pattern(2) * 100 +swapped_pattern(3) * 10 + swapped_pattern(4);
child_checker_idx = perms_idx_refer(swapped_perms_idx);
if ~tree_checker(child_checker_idx)
tree_checker(child_checker_idx) = true;
perms_tree(1, tree_idx) = child_checker_idx; % child
perms_tree(2, tree_idx) = parent_checker_idx; % parent
tree_idx = tree_idx + 1;
queue_curr_idx = queue_curr_idx + 1;
perms_queue(:, queue_curr_idx) = perms_array(:, child_checker_idx);
end
end
end
end
prs_time_QRD_BTP = zeros(1,symbol_vector_num);
rng('default');
rng(seed);
for i=1:symbol_vector_num
bits=randn(1,frame_size);
neg_idx=find(bits<0);
bits=ones(1,frame_size);
bits(neg_idx)=0;
%QAM mapping
x=QAM_mapper(bits,k);
x=transpose(x);%row->column
%noise variance calculation
n_var=10^(-EbNo_lvl/10)/k;
%wireless transmission
%Rayleigh fading channel
H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nR)+j*randn(nR,nR));
% H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nT)+j*randn(nR,nT));
% Select Precoder
qrd_btp_f = @() QRD_based_BT_P_Method(H, nS);
prs_time_QRD_BTP(i) = timeit(qrd_btp_f);
end
prs_time_previous = zeros(1,symbol_vector_num);
rng('default');
rng(seed);
for i=1:symbol_vector_num
bits=randn(1,frame_size);
neg_idx=find(bits<0);
bits=ones(1,frame_size);
bits(neg_idx)=0;
%QAM mapping
x=QAM_mapper(bits,k);
x=transpose(x);%row->column
%noise variance calculation
n_var=10^(-EbNo_lvl/10)/k;
%wireless transmission
%Rayleigh fading channel
H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nR)+j*randn(nR,nR));
% H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nT)+j*randn(nR,nT));
% Select Precoder
previousf = @() precoder_select_ML_conference(H, nS);
prs_time_previous(i) = timeit(previousf);
end
prs_time_QRD_BTE = zeros(1,symbol_vector_num);
rng('default');
rng(seed);
for i=1:symbol_vector_num
bits=randn(1,frame_size);
neg_idx=find(bits<0);
bits=ones(1,frame_size);
bits(neg_idx)=0;
%QAM mapping
x=QAM_mapper(bits,k);
x=transpose(x);%row->column
%noise variance calculation
n_var=10^(-EbNo_lvl/10)/k;
%wireless transmission
%Rayleigh fading channel
H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nR)+j*randn(nR,nR));
% H=1/sqrt(nS)*sqrt(1/2)*(randn(nR,nT)+j*randn(nR,nT));
% Select Precoder
if nS ~= 2
qrd_bte_f = @() QRD_based_BT_E_Method(H, nS, 3, 0.99);
else
qrd_bte_f = @() QRD_based_BT_E_Method(H, nS, 1, 0.99);
end
prs_time_QRD_BTE(i) = timeit(qrd_bte_f);
end
disp('All over');
c = categorical({'Proposed', 'Proposed(Intermediate)', 'SVD-based', 'QRD-based','LR-based' ,'Limited Search Space'});
prices = [mean(prs_time_ML), mean(prs_time_previous), mean(prs_time_SVD), mean(prs_time_QRD), ...
mean(prs_time_QRD_BTE), mean(prs_time_SML)];
std_prices = [std(prs_time_ML), std(prs_time_previous), std(prs_time_SVD), std(prs_time_QRD), ...
std(prs_time_QRD_BTE), std(prs_time_SML)]/sqrt(symbol_vector_num) ;
[sorted_val, sort_idx] = sort(prices);
sorted_precoder_selection = c(sort_idx);
sorted_std = std_prices(sort_idx);
figure();
barh(sorted_val);
set(gca, 'YTickLabel', sorted_precoder_selection);
tix=get(gca,'xtick')';
set(gca,'xticklabel',num2str(tix,'%.4f'));
xlim([0 2.5*10^(-3)]);
xlabel('Processing time [sec]');
saveas(gcf,'MIMO_test_fig_bar');