1 |
38 |
alirezamon |
#!/usr/bin/perl
|
2 |
|
|
use strict;
|
3 |
|
|
use warnings;
|
4 |
|
|
|
5 |
|
|
use Glib qw(TRUE FALSE);
|
6 |
|
|
use Gtk2 '-init';
|
7 |
|
|
use Gtk2::SourceView2;
|
8 |
|
|
use Data::Dumper;
|
9 |
|
|
use List::Util 'shuffle';
|
10 |
|
|
use File::Path;
|
11 |
|
|
use File::Copy;
|
12 |
|
|
use POSIX qw(ceil floor);
|
13 |
|
|
use Cwd 'abs_path';
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
use base 'Class::Accessor::Fast';
|
18 |
|
|
require "widget.pl";
|
19 |
|
|
require "diagram.pl";
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
__PACKAGE__->mk_accessors(qw{
|
23 |
|
|
window
|
24 |
|
|
sourceview
|
25 |
|
|
buffer
|
26 |
|
|
filename
|
27 |
|
|
search_regexp
|
28 |
|
|
search_case
|
29 |
|
|
search_entry
|
30 |
|
|
regexp
|
31 |
|
|
highlighted
|
32 |
|
|
|
33 |
|
|
});
|
34 |
|
|
|
35 |
|
|
my $NAME = 'Trace_gen';
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
exit trace_gen_main() unless caller;
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
sub trace_gen_main {
|
42 |
|
|
|
43 |
|
|
my $app = __PACKAGE__->new();
|
44 |
|
|
my $table=$app->build_trace_gui();
|
45 |
|
|
|
46 |
|
|
return $table;
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
sub build_trace_gui {
|
52 |
|
|
my ($self) = @_;
|
53 |
|
|
$self->object_add_attribute("file_id",undef,'a');
|
54 |
|
|
$self->object_add_attribute("trace_id",undef,0);
|
55 |
|
|
$self->object_add_attribute('select_multiple','action',"_");
|
56 |
|
|
$self->object_add_attribute('Auto','Auto_inject',"1\'b1");
|
57 |
|
|
|
58 |
|
|
set_gui_status($self,"ideal",0);
|
59 |
|
|
|
60 |
|
|
my $main_table= def_table(2,10,FALSE);
|
61 |
|
|
my ($scwin_info,$tview)= create_text();
|
62 |
|
|
|
63 |
|
|
my $traces=trace_pad($self,$tview);
|
64 |
|
|
my $traces_ctrl=trace_pad_ctrl($self,$tview);
|
65 |
|
|
|
66 |
|
|
my $map= trace_map($self,$tview);
|
67 |
|
|
my $map_ctrl= trace_map_ctrl($self,$tview);
|
68 |
|
|
my $map_info=map_info($self);
|
69 |
|
|
|
70 |
|
|
my $h1=gen_hpaned($traces_ctrl,.25,$traces);
|
71 |
|
|
my $h2=gen_hpaned($map_ctrl,.25,$map);
|
72 |
|
|
my $h3=gen_hpaned($h2,.65,$map_info);
|
73 |
|
|
|
74 |
|
|
my $v1=gen_vpaned($h1,.3,$h3);
|
75 |
|
|
#my $v2=gen_vpaned($v1,.6,$scwin_info);
|
76 |
|
|
|
77 |
|
|
my $generate = def_image_button('icons/gen.png','Generate');
|
78 |
|
|
my $open = def_image_button('icons/browse.png','Load');
|
79 |
|
|
my ($entrybox,$entry) = def_h_labeled_entry('Save as:',undef);
|
80 |
|
|
$entry->signal_connect( 'changed'=> sub{
|
81 |
|
|
my $name=$entry->get_text();
|
82 |
|
|
$self->object_add_attribute ("save_as",undef,$name);
|
83 |
|
|
});
|
84 |
|
|
|
85 |
|
|
my $entry2=gen_entry_object($self,'out_name',undef,undef,undef,undef);
|
86 |
|
|
my $entrybox2=labele_widget_info(" Output file name:",$entry2);
|
87 |
|
|
|
88 |
|
|
my $save = def_image_button('icons/save.png','Save');
|
89 |
|
|
$entrybox->pack_end($save, FALSE, FALSE,0);
|
90 |
|
|
|
91 |
|
|
$main_table->attach_defaults ($v1 , 0, 12, 0,24);
|
92 |
|
|
$main_table->attach ($open,0, 3, 24,25,'expand','shrink',2,2);
|
93 |
|
|
$main_table->attach ($entrybox,3, 5, 24,25,'expand','shrink',2,2);
|
94 |
|
|
$main_table->attach ($entrybox2,5,6 , 24,25,'expand','shrink',2,2);
|
95 |
|
|
$main_table->attach ($generate, 6, 9, 24,25,'expand','shrink',2,2);
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
|
99 |
|
|
$sc_win->set_policy( "automatic", "automatic" );
|
100 |
|
|
$sc_win->add_with_viewport($main_table);
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
$open-> signal_connect("clicked" => sub{
|
105 |
|
|
|
106 |
|
|
load_workspace($self);
|
107 |
|
|
set_gui_status($self,"ref",5);
|
108 |
|
|
|
109 |
|
|
});
|
110 |
|
|
|
111 |
|
|
$save-> signal_connect("clicked" => sub{
|
112 |
|
|
save_as($self);
|
113 |
|
|
set_gui_status($self,"ref",5);
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
});
|
117 |
|
|
|
118 |
|
|
$generate->signal_connect("clicked" => sub{
|
119 |
|
|
genereate_output($self);
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
});
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
#check soc status every 0.5 second. referesh device table if there is any changes
|
130 |
|
|
Glib::Timeout->add (100, sub{
|
131 |
|
|
|
132 |
|
|
my ($state,$timeout)= get_gui_status($self);
|
133 |
|
|
|
134 |
|
|
if ($timeout>0){
|
135 |
|
|
$timeout--;
|
136 |
|
|
set_gui_status($self,$state,$timeout);
|
137 |
|
|
return TRUE;
|
138 |
|
|
|
139 |
|
|
}
|
140 |
|
|
if($state eq "ideal"){
|
141 |
|
|
return TRUE;
|
142 |
|
|
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
#refresh GUI
|
148 |
|
|
my $saved_name=$self->object_get_attribute('save_as');
|
149 |
|
|
if(defined $saved_name) {$entry->set_text($saved_name);}
|
150 |
|
|
|
151 |
|
|
$saved_name=$self->object_get_attribute('out_name');
|
152 |
|
|
if(defined $saved_name) {$entry2->set_text($saved_name);}
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
$traces->destroy();
|
157 |
|
|
$traces=trace_pad($self,$tview);
|
158 |
|
|
$map->destroy();
|
159 |
|
|
$map= trace_map($self,$tview);
|
160 |
|
|
$map_ctrl->destroy();
|
161 |
|
|
$map_ctrl= trace_map_ctrl($self,$tview);
|
162 |
|
|
$traces_ctrl->destroy();
|
163 |
|
|
$traces_ctrl=trace_pad_ctrl($self,$tview);
|
164 |
|
|
$map_info->destroy();
|
165 |
|
|
$map_info=map_info($self);
|
166 |
|
|
|
167 |
|
|
$h1 -> pack1($traces_ctrl, TRUE, TRUE);
|
168 |
|
|
$h1 -> pack2($traces, TRUE, TRUE);
|
169 |
|
|
$h2 -> pack1($map_ctrl, TRUE, TRUE);
|
170 |
|
|
$h2 -> pack2($map, TRUE, TRUE);
|
171 |
|
|
$h3 -> pack2($map_info, TRUE, TRUE);
|
172 |
|
|
|
173 |
|
|
$traces->show_all();
|
174 |
|
|
$map->show_all();
|
175 |
|
|
$main_table->show_all();
|
176 |
|
|
set_gui_status($self,"ideal",0);
|
177 |
|
|
|
178 |
|
|
return TRUE;
|
179 |
|
|
|
180 |
|
|
} );
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
return $sc_win;
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
########
|
191 |
|
|
# trace_ctr
|
192 |
|
|
########
|
193 |
|
|
|
194 |
|
|
sub trace_pad_ctrl{
|
195 |
|
|
my ($self,$tview)=@_;
|
196 |
|
|
|
197 |
|
|
my $table= def_table(2,10,FALSE);
|
198 |
|
|
#my $separator = Gtk2::HSeparator->new;
|
199 |
|
|
my $row=0;
|
200 |
|
|
my $col=0;
|
201 |
|
|
#$table->attach ($separator , 0, 10 , $row, $row+1,'fill','fill',2,2); $row++;
|
202 |
|
|
|
203 |
|
|
my $add = def_image_button('icons/import.png');
|
204 |
|
|
set_tip($add,'Load Task Graph');
|
205 |
|
|
my $remove = def_image_button('icons/cancel.png');
|
206 |
|
|
set_tip($remove,'Remove Selected Trace(s)');
|
207 |
|
|
my $draw = def_image_button('icons/diagram.png');
|
208 |
|
|
set_tip($draw,'View Task Graph');
|
209 |
|
|
my $auto = def_image_button('icons/refresh.png');
|
210 |
|
|
set_tip($auto,'Automatically calculate the traces burst size and injection ratio according to their bandwith');
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
my $box=def_pack_hbox(FALSE,FALSE,$add,$draw,$remove,$auto);
|
216 |
|
|
|
217 |
|
|
#my $auto = def_image_button('icons/setting.png');
|
218 |
|
|
#set_tip($auto,'Automatically set the burst size and injection ratio according to the packet size and bandwidth');
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
$col=0;
|
222 |
|
|
$table->attach ($box,$col, $col+1, $row, $row+1,'shrink','shrink',2,2);$col++;
|
223 |
|
|
|
224 |
|
|
$row++;
|
225 |
|
|
$col=0;
|
226 |
|
|
my $info="Automatically set the burst size and injection ratio according to the packet size and bandwidth";
|
227 |
|
|
#add_param_widget($self,"Auto inject rate \& burst size",'Auto_inject', 0,"Check-box",1,$info, $table,$row,$col,1,'Auto',0,'ref',"vertical");
|
228 |
|
|
$row++;
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
$col=0;
|
233 |
|
|
|
234 |
|
|
my $info1="If hard-bulid QoS is enabled in NoC by using Wieghted round robin arbiter (WRRA) instead of RRA, then the initial weights allow QoS support in NoC as in presence of contention, packets with higher initial weights receive higher bandwidth and lower worst case delay compared to others." ;
|
235 |
|
|
|
236 |
|
|
my $selects="tornado,transposed 1,transposed 2,bit reverse,bit complement,random,hot spot";
|
237 |
|
|
my $min=$self->object_get_attribute('select_multiple','min_pck_size');
|
238 |
|
|
my $max=$self->object_get_attribute('select_multiple','max_pck_size');
|
239 |
|
|
$min=$max=5 if(!defined $min);
|
240 |
|
|
|
241 |
|
|
my @selectedinfo;
|
242 |
|
|
$self->object_add_attribute('Auto','Auto_inject',"1\'b0" );
|
243 |
|
|
my $a= $self->object_get_attribute('Auto','Auto_inject');
|
244 |
|
|
if ($a eq "1\'b0"){
|
245 |
|
|
@selectedinfo = (
|
246 |
|
|
{ label=>" Initial weight ", param_name=>'init_weight', type=>'Spin-button', default_val=>1, content=>"1,16,1", info=>$info1, param_parent=>'select_multiple', ref_delay=> undef, new_status=>undef},
|
247 |
|
|
{ label=>" Min pck size ", param_name=>'min_pck_size', type=>'Spin-button', default_val=>5, content=>"2,$max,1", info=>undef, param_parent=>'select_multiple', ref_delay=> 10, new_status=>'ref'},
|
248 |
|
|
{ label=>" Max pck size ",param_name=>'max_pck_size', type=>'Spin-button', default_val=>5, content=>"$min,1024,1", info=>undef, param_parent=>'select_multiple', ref_delay=> 10, new_status=>'ref'},
|
249 |
|
|
{ label=>" Burst_size ", param_name=>'burst_size', type=>'Spin-button', default_val=>1, content=>"1,1024,1", info=>undef, param_parent=>'select_multiple', ref_delay=> undef, new_status=>undef},
|
250 |
|
|
{ label=>" Inject rate(%) ", param_name=>'injct_rate', type=>'Spin-button', default_val=>10, content=>"1,100,1", info=>undef, param_parent=>'select_multiple', ref_delay=> undef, new_status=>undef},
|
251 |
|
|
{ label=>" Inject rate variation(%) ", param_name=>'injct_rate_var', type=>'Spin-button', default_val=>20, content=>"0,100,1", info=>undef, param_parent=>'select_multiple', ref_delay=> undef, new_status=>undef},
|
252 |
|
|
|
253 |
|
|
);
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
}else{
|
257 |
|
|
@selectedinfo = (
|
258 |
|
|
{ label=>" Initial weight ", param_name=>'init_weight', type=>'Spin-button', default_val=>1, content=>"1,16,1", info=>undef, param_parent=>'select_multiple', ref_delay=> undef, new_status=>undef},
|
259 |
|
|
{ label=>" Min pck size ", param_name=>'min_pck_size', type=>'Spin-button', default_val=>5, content=>"2,$max,1", info=>undef, param_parent=>'select_multiple', ref_delay=> 10, new_status=>'ref'},
|
260 |
|
|
{ label=>" Max pck size ",param_name=>'max_pck_size', type=>'Spin-button', default_val=>5, content=>"$min,1024,1", info=>undef, param_parent=>'select_multiple', ref_delay=> 10, new_status=>'ref'},
|
261 |
|
|
|
262 |
|
|
);
|
263 |
|
|
|
264 |
|
|
}
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
my @traces= $self->get_trace_list();
|
268 |
|
|
my $any_selected=0;
|
269 |
|
|
foreach my $p (@traces) {
|
270 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name)=$self->get_trace($p);
|
271 |
|
|
$any_selected=1 if($self->object_get_attribute("trace_$p",'selected')==1);
|
272 |
|
|
|
273 |
|
|
}
|
274 |
|
|
|
275 |
|
|
if($any_selected){
|
276 |
|
|
$table->attach (Gtk2::HSeparator->new,0, 10, $row, $row+1,'fill','fill',2,2);$row++;
|
277 |
|
|
$table->attach (gen_label_in_center('Apply to all selected traces'),0, 10, $row, $row+1,'fill','fill',2,2);$row++;
|
278 |
|
|
}
|
279 |
|
|
|
280 |
|
|
foreach my $d (@selectedinfo) {
|
281 |
|
|
my $apply= def_image_button("icons/enter.png",undef);
|
282 |
|
|
$apply->signal_connect( 'clicked'=> sub{
|
283 |
|
|
$self->object_add_attribute('select_multiple','action',$d->{param_name});
|
284 |
|
|
$self->set_gui_status('ref',0);
|
285 |
|
|
});
|
286 |
|
|
if($any_selected){
|
287 |
|
|
($row,$col)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,$col,1, $d->{param_parent}, $d->{ref_delay},$d->{new_status},"horizental");
|
288 |
|
|
$table->attach ($apply , $col, $col+1, $row,$row+1,'shrink','shrink',2,2);$row++;$col=0;
|
289 |
|
|
# $row=noc_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
|
290 |
|
|
}
|
291 |
|
|
}
|
292 |
|
|
|
293 |
|
|
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
|
297 |
|
|
my $dir = Cwd::getcwd();
|
298 |
|
|
my $project_dir = abs_path("$dir/.."); #mpsoc directory address
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
$add->signal_connect ( 'clicked'=> sub{
|
302 |
|
|
|
303 |
|
|
my $file;
|
304 |
|
|
my $dialog = Gtk2::FileChooserDialog->new(
|
305 |
|
|
'Select a File', undef,
|
306 |
|
|
'open',
|
307 |
|
|
'gtk-cancel' => 'cancel',
|
308 |
|
|
'gtk-ok' => 'ok',
|
309 |
|
|
);
|
310 |
|
|
my $open_in = abs_path("${project_dir}/perl_gui/lib/simulate/embedded_app_graphs");
|
311 |
|
|
$dialog->set_current_folder ($open_in);
|
312 |
|
|
my $filter = Gtk2::FileFilter->new();
|
313 |
|
|
$filter->set_name("app");
|
314 |
|
|
$filter->add_pattern("*.app");
|
315 |
|
|
$dialog->add_filter ($filter);
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
if ( "ok" eq $dialog->run ) {
|
319 |
|
|
$file = $dialog->get_filename;
|
320 |
|
|
$self->load_tarce_file($file,$tview);
|
321 |
|
|
}
|
322 |
|
|
$dialog->destroy;
|
323 |
|
|
});
|
324 |
|
|
|
325 |
|
|
$draw->signal_connect ( 'clicked'=> sub{
|
326 |
|
|
show_trace_diagram($self,'trace');
|
327 |
|
|
});
|
328 |
|
|
|
329 |
|
|
$remove->signal_connect ( 'clicked'=> sub{
|
330 |
|
|
$self->remove_selected_traces();
|
331 |
|
|
});
|
332 |
|
|
|
333 |
|
|
$auto->signal_connect ( 'clicked'=> sub{
|
334 |
|
|
$self->auto_generate_injtratio();
|
335 |
|
|
});
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
|
339 |
|
|
$sc_win->set_policy( "automatic", "automatic" );
|
340 |
|
|
$sc_win->add_with_viewport($table);
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
return $sc_win;
|
344 |
|
|
|
345 |
|
|
}
|
346 |
|
|
|
347 |
|
|
|
348 |
|
|
######
|
349 |
|
|
# map_ctr
|
350 |
|
|
######
|
351 |
|
|
|
352 |
|
|
sub trace_map_ctrl{
|
353 |
|
|
|
354 |
|
|
my ($self,$tview)=@_;
|
355 |
|
|
my $table= def_table(2,10,FALSE);
|
356 |
|
|
|
357 |
|
|
my $run_map= def_image_button("icons/enter.png",undef);
|
358 |
|
|
my $drawmap = def_image_button('icons/diagram.png');
|
359 |
|
|
set_tip($drawmap,'View Task Mapping');
|
360 |
|
|
my $auto = def_image_button('icons/refresh.png');
|
361 |
|
|
set_tip($auto,'Automatically set the network dimentions acording to the task number');
|
362 |
|
|
|
363 |
|
|
my $clean = def_image_button('icons/clear.png');
|
364 |
|
|
set_tip($clean,'Remove mapping');
|
365 |
|
|
|
366 |
|
|
|
367 |
|
|
|
368 |
|
|
|
369 |
|
|
my $box=def_pack_hbox(FALSE,FALSE,$drawmap,$clean,$auto);
|
370 |
|
|
|
371 |
|
|
|
372 |
|
|
|
373 |
|
|
|
374 |
|
|
my $col=0;
|
375 |
|
|
my $row=0;
|
376 |
|
|
$table->attach ($box,$col, $col+1, $row, $row+1,'shrink','shrink',2,2);$row++;
|
377 |
|
|
|
378 |
|
|
|
379 |
|
|
|
380 |
|
|
my @info = (
|
381 |
43 |
alirezamon |
{ label=>'Routers per Row', param_name=>'T1', type=>"Spin-button", default_val=>2, content=>"2,64,1", info=>undef, param_parent=>'noc_param', ref_delay=>1,placement=>'vertical'},
|
382 |
|
|
{ label=>"Routers per Column", param_name=>"T2", type=>"Spin-button", default_val=>2, content=>"1,64,1", info=>undef, param_parent=>'noc_param',ref_delay=>1, placement=>'vertical'},
|
383 |
38 |
alirezamon |
{ label=>"Mapping Algorithm", param_name=>"Map_Algrm", type=>"Combo-box", default_val=>'Random', content=>"Nmap,Random,Reverse-NMAP,Direct", info=>undef, param_parent=>'map_param',ref_delay=>undef,placement=>'horizental'},
|
384 |
|
|
|
385 |
|
|
);
|
386 |
|
|
|
387 |
|
|
|
388 |
|
|
|
389 |
|
|
foreach my $d (@info) {
|
390 |
|
|
($row,$col)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,$col,1, $d->{param_parent}, $d->{ref_delay},'ref',$d->{placement});
|
391 |
|
|
if($d->{param_name} eq "Map_Algrm"){$table->attach ($run_map , $col, $col+1, $row,$row+1,'shrink','shrink',2,2);$row++;$col=0;}
|
392 |
|
|
|
393 |
|
|
}
|
394 |
|
|
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
$run_map->signal_connect( 'clicked'=> sub{
|
399 |
|
|
my $alg=$self->object_get_attribute('map_param','Map_Algrm');
|
400 |
|
|
|
401 |
|
|
$self->random_map() if ($alg eq 'Random');
|
402 |
|
|
$self->worst_map_algorithm() if ($alg eq 'Reverse-NMAP');
|
403 |
|
|
$self->nmap_algorithm() if ($alg eq 'Nmap');
|
404 |
|
|
$self->direct_map() if ($alg eq 'Direct');
|
405 |
|
|
|
406 |
|
|
|
407 |
|
|
});
|
408 |
|
|
|
409 |
|
|
$drawmap->signal_connect ( 'clicked'=> sub{
|
410 |
|
|
show_trace_diagram($self,'map');
|
411 |
|
|
});
|
412 |
|
|
|
413 |
|
|
$auto->signal_connect ( 'clicked'=> sub{
|
414 |
|
|
my @tasks = $self->get_all_tasks();
|
415 |
|
|
my $task_num= scalar @tasks;
|
416 |
|
|
return if($task_num ==0);
|
417 |
|
|
my ($nx,$ny) =network_dim_cal($task_num);
|
418 |
43 |
alirezamon |
$self->object_add_attribute('noc_param','T1',$nx);
|
419 |
|
|
$self->object_add_attribute('noc_param','T2',$ny);
|
420 |
38 |
alirezamon |
set_gui_status($self,"ref",1);
|
421 |
|
|
});
|
422 |
|
|
|
423 |
|
|
$clean->signal_connect ( 'clicked'=> sub{
|
424 |
|
|
remove_mapping($self);
|
425 |
|
|
set_gui_status($self,"ref",1);
|
426 |
|
|
});
|
427 |
|
|
|
428 |
|
|
|
429 |
|
|
my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
|
430 |
|
|
$sc_win->set_policy( "automatic", "automatic" );
|
431 |
|
|
$sc_win->add_with_viewport($table);
|
432 |
|
|
|
433 |
|
|
|
434 |
|
|
return $sc_win;
|
435 |
|
|
}
|
436 |
|
|
|
437 |
|
|
#########
|
438 |
|
|
# trace
|
439 |
|
|
#########
|
440 |
|
|
|
441 |
|
|
sub trace_pad{
|
442 |
|
|
my ($self,$tview)=@_;
|
443 |
|
|
my $table= def_table(10,10,FALSE);
|
444 |
|
|
#my $separator = Gtk2::HSeparator->new;
|
445 |
|
|
my $row=0;
|
446 |
|
|
my $col=0;
|
447 |
|
|
|
448 |
|
|
|
449 |
|
|
my @selectedinfo = (
|
450 |
|
|
{ label=>" Initial weight ", param_name=>'init_weight', type=>'Spin-button', default_val=>1, content=>"1,16,1", info=>undef, param_parent=>'select_multiple', ref_delay=> undef, new_status=>undef},
|
451 |
|
|
{ label=>" Min pck size ", param_name=>'min_pck_size', type=>'Spin-button', default_val=>5, content=>"2,1024,1", info=>undef, param_parent=>'select_multiple', ref_delay=> 10, new_status=>'ref'},
|
452 |
|
|
{ label=>" Max pck size ",param_name=>'max_pck_size', type=>'Spin-button', default_val=>5, content=>"2,1024,1", info=>undef, param_parent=>'select_multiple', ref_delay=> 10, new_status=>'ref'},
|
453 |
|
|
{ label=>" Burst_size ", param_name=>'burst_size', type=>'Spin-button', default_val=>1, content=>"1,1024,1", info=>undef, param_parent=>'select_multiple', ref_delay=> undef, new_status=>undef},
|
454 |
|
|
{ label=>" Inject rate(%) ", param_name=>'injct_rate', type=>'Spin-button', default_val=>10, content=>"1,100,1", info=>undef, param_parent=>'select_multiple', ref_delay=> undef, new_status=>undef},
|
455 |
|
|
{ label=>" Inject rate variation (%) ", param_name=>'injct_rate_var', type=>'Spin-button', default_val=>20, content=>"0,100,1", info=>undef, param_parent=>'select_multiple', ref_delay=> undef, new_status=>undef},
|
456 |
|
|
);
|
457 |
|
|
|
458 |
|
|
|
459 |
|
|
my @traces= $self->get_trace_list();
|
460 |
|
|
my %f;
|
461 |
|
|
|
462 |
|
|
|
463 |
|
|
my $sel=$self->object_get_attribute('select_multiple','action');
|
464 |
|
|
|
465 |
|
|
foreach my $p (@traces) {
|
466 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name)=$self->get_trace($p);
|
467 |
|
|
$f{$file_id}=$file_id.'*';
|
468 |
|
|
$self->object_add_attribute("trace_$p",'selected', 1 ) if ($sel eq 'All');
|
469 |
|
|
$self->object_add_attribute("trace_$p",'selected', 0 ) if ($sel eq 'None');
|
470 |
|
|
$self->object_add_attribute("trace_$p",'selected', 1 ) if ($sel eq "All-$file_id*");
|
471 |
|
|
$self->object_add_attribute("trace_$p",'selected', 0 ) if ($sel eq "None-$file_id*");
|
472 |
|
|
|
473 |
|
|
my $seleceted =$self->object_get_attribute("trace_$p",'selected');
|
474 |
|
|
foreach my $d (@selectedinfo) {
|
475 |
|
|
my $val=$self->object_get_attribute($d->{param_parent},$d->{param_name}) if ($sel eq $d->{param_name} && $seleceted);
|
476 |
|
|
$self->object_add_attribute("trace_$p",$d->{param_name}, $val ) if ($sel eq $d->{param_name}&& $seleceted);
|
477 |
|
|
|
478 |
|
|
}
|
479 |
|
|
}
|
480 |
|
|
my $sel_options= "Select,All,None";
|
481 |
|
|
if( keys %f > 1){
|
482 |
|
|
foreach my $p (sort keys %f) {
|
483 |
|
|
$sel_options="$sel_options,All-$f{$p}";
|
484 |
|
|
$sel_options="$sel_options,None-$f{$p}";
|
485 |
|
|
}
|
486 |
|
|
}
|
487 |
|
|
$self->object_add_attribute('select_multiple','action',"Select");
|
488 |
|
|
my $selcombo = $self-> gen_combobox_object ('select_multiple',"action", $sel_options,'-','ref',1);
|
489 |
|
|
|
490 |
|
|
|
491 |
|
|
if(scalar @traces ){$table-> attach ($selcombo, $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;}
|
492 |
|
|
|
493 |
|
|
|
494 |
|
|
my @titles = (scalar @traces ) ? (" # "," Source "," Destination "," Bandwidth(MB) ", " Initial weight ", " Min pck size ", " Max pck size "):
|
495 |
|
|
("Load a task graph");
|
496 |
|
|
|
497 |
|
|
my $auto=$self->object_get_attribute('Auto','Auto_inject');
|
498 |
|
|
|
499 |
|
|
push (@titles, (" Burst_size ", " Inject rate(%) ", " Inject rate variation(%) ")) if ($auto eq "1\'b0");
|
500 |
|
|
foreach my $p (@titles){
|
501 |
|
|
$table-> attach (gen_label_in_left($p), $col, $col+1, $row, $row+1,'shrink','shrink',2,2);
|
502 |
|
|
$col++;
|
503 |
|
|
}
|
504 |
|
|
$row++;
|
505 |
|
|
|
506 |
|
|
my $i=0;
|
507 |
|
|
#my @t=sort { $a cmp $b } @traces;
|
508 |
|
|
|
509 |
|
|
foreach my $p (@traces) {
|
510 |
|
|
$col=0;
|
511 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name)=$self->get_trace($p);
|
512 |
|
|
|
513 |
|
|
|
514 |
|
|
my $check = gen_check_box_object ($self,"trace_$p",'selected',0,'ref',0);
|
515 |
|
|
my $weight= gen_spin_object ($self,"trace_$p",'init_weight',"1,16,1", 1,undef,undef);
|
516 |
|
|
|
517 |
|
|
my $min=$self->object_get_attribute("trace_$p",'min_pck_size');
|
518 |
|
|
my $max=$self->object_get_attribute("trace_$p",'max_pck_size');
|
519 |
|
|
$min=$max=5 if(!defined $min);
|
520 |
|
|
my $min_pck_size= gen_spin_object ($self,"trace_$p",'min_pck_size',"2,$max,1", 5,'ref',10);
|
521 |
|
|
my $max_pck_size= gen_spin_object ($self,"trace_$p",'max_pck_size',"$min,1024,1", 5,'ref',10);
|
522 |
|
|
|
523 |
|
|
my $burst_size = gen_spin_object ($self,"trace_$p",'burst_size',"1,1024,1", 1,undef,undef);
|
524 |
|
|
my $injct_rate = gen_spin_object ($self,"trace_$p",'injct_rate',"1,100,1", 10,undef,undef);
|
525 |
|
|
my $injct_rate_var = gen_spin_object ($self,"trace_$p",'injct_rate_var',"0,100,1", 20,undef,undef);
|
526 |
|
|
|
527 |
|
|
#my $weight= trace_$trace_id",'init_weight'
|
528 |
|
|
|
529 |
|
|
$table-> attach ($check, $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
530 |
|
|
|
531 |
|
|
$table-> attach (gen_label_in_left($i), $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
532 |
|
|
$table-> attach (gen_label_in_left("$src") ,$col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
533 |
|
|
$table-> attach (gen_label_in_left("$dst") , $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
534 |
|
|
$table-> attach (gen_label_in_left("$Mbytes") ,$col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
535 |
|
|
$table-> attach ($weight ,$col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
536 |
|
|
$table-> attach ($min_pck_size, $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
537 |
|
|
$table-> attach ($max_pck_size, $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
538 |
|
|
if ($auto eq "1\'b0"){
|
539 |
|
|
$table-> attach ($burst_size ,$col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
540 |
|
|
$table-> attach ($injct_rate ,$col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
541 |
|
|
$table-> attach ($injct_rate_var ,$col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
542 |
|
|
|
543 |
|
|
}
|
544 |
|
|
|
545 |
|
|
|
546 |
|
|
$row++;
|
547 |
|
|
$i++;
|
548 |
|
|
|
549 |
|
|
}
|
550 |
|
|
|
551 |
|
|
my $sc_win = gen_scr_win_with_adjst($self,'trace_pad');
|
552 |
|
|
$sc_win->add_with_viewport($table);
|
553 |
|
|
|
554 |
|
|
return $sc_win;
|
555 |
|
|
}
|
556 |
|
|
|
557 |
|
|
|
558 |
|
|
|
559 |
|
|
sub load_tarce_file{
|
560 |
|
|
my ($self,$file,$tview)=@_;
|
561 |
|
|
#open file
|
562 |
|
|
my @x;
|
563 |
|
|
my %traces;
|
564 |
|
|
if (!defined $file) {return; }
|
565 |
|
|
if (-e $file) {
|
566 |
|
|
my $f_id=$self->object_get_attribute("file_id",undef);
|
567 |
|
|
my $t_id=$self->object_get_attribute("trace_id",undef);
|
568 |
|
|
open(my $fh, '<:encoding(UTF-8)', $file) or die "Could not open file '$file' $!";
|
569 |
|
|
while (my $row = <$fh>) {
|
570 |
|
|
chomp $row;
|
571 |
|
|
my @data = split (/\s/,$row);
|
572 |
|
|
|
573 |
|
|
next if (! defined $data[0]);
|
574 |
|
|
next if ($data[0] eq '#' || scalar @data < 3);
|
575 |
|
|
|
576 |
|
|
$self->add_trace($f_id,$t_id,$data[0],$data[1],$data[2],$file);
|
577 |
|
|
$t_id++;
|
578 |
|
|
}
|
579 |
|
|
$f_id++;
|
580 |
|
|
$self->object_add_attribute("trace_id",undef,$t_id);
|
581 |
|
|
$self->object_add_attribute("file_id",undef,$f_id);
|
582 |
|
|
}
|
583 |
|
|
set_gui_status($self,"ref",1);
|
584 |
|
|
|
585 |
|
|
}
|
586 |
|
|
|
587 |
|
|
|
588 |
|
|
|
589 |
|
|
|
590 |
|
|
########
|
591 |
|
|
# map
|
592 |
|
|
#######
|
593 |
|
|
|
594 |
|
|
|
595 |
|
|
sub trace_map {
|
596 |
|
|
my ($self,$tview)=@_;
|
597 |
|
|
my $table= def_table(10,10,FALSE);
|
598 |
|
|
|
599 |
|
|
|
600 |
|
|
my $sc_win = gen_scr_win_with_adjst($self,'trace_map');
|
601 |
|
|
$sc_win->add_with_viewport($table);
|
602 |
|
|
|
603 |
|
|
my $row=0;
|
604 |
|
|
my $col=0;
|
605 |
|
|
|
606 |
|
|
my @titles = (" # "," Task-name ", " Mapped-to " ,"Lock ", " Sent-Bandwidth ", " Resvd-Bandwidth ", " Total-Bandwidth ");
|
607 |
|
|
foreach my $p (@titles){
|
608 |
|
|
$table-> attach (gen_label_in_left($p), $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
609 |
|
|
}
|
610 |
|
|
$col=0;
|
611 |
|
|
$row++;
|
612 |
|
|
|
613 |
43 |
alirezamon |
# { label=>'Routers per Row', param_name=>'T1', type=>"Spin-button", default_val=>2, content=>"2,64,1", info=>undef, param_parent=>'noc_param', ref_delay=>undef},
|
614 |
38 |
alirezamon |
|
615 |
43 |
alirezamon |
my $nx=$self->object_get_attribute('noc_param','T1');
|
616 |
|
|
my $ny=$self->object_get_attribute('noc_param','T2');
|
617 |
38 |
alirezamon |
|
618 |
|
|
|
619 |
|
|
|
620 |
|
|
my @tiles=get_tiles_name($self);
|
621 |
|
|
|
622 |
|
|
|
623 |
|
|
my $i=0;
|
624 |
|
|
my @tasks=get_all_tasks($self);
|
625 |
|
|
|
626 |
|
|
my @assigned = $self->get_assigned_tiles();
|
627 |
|
|
|
628 |
|
|
|
629 |
|
|
#a-b
|
630 |
|
|
my @list= get_diff_array(\@tiles ,\@assigned);
|
631 |
|
|
push(@list,'-');
|
632 |
|
|
|
633 |
|
|
#print "tils=@tiles \nass=@assigned \nlist=@list\n";
|
634 |
|
|
my %com_tasks= $self->get_communication_task();
|
635 |
|
|
|
636 |
|
|
foreach my $p (@tasks){
|
637 |
|
|
my $value=$self->object_get_attribute("MAP_TILE",$p);
|
638 |
|
|
$value = "-" if (!defined $value);
|
639 |
|
|
my @l=($value eq "-" || grep (/^\Q$value\E$/,@tiles)==0 )? @list : (@list,$value);
|
640 |
|
|
my $combo= map_combobox ($self,"$p",\@l,'-');
|
641 |
|
|
|
642 |
|
|
#my $lock=$self->object_get_attribute("MAP_LOCK",$p);
|
643 |
|
|
#$lock = 0 if (!defined $lock);
|
644 |
|
|
my $lock = gen_check_box_object ($self,"MAP_LOCK",$p,0,undef,undef);
|
645 |
|
|
|
646 |
|
|
|
647 |
|
|
$table-> attach (gen_label_in_left($i), $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
648 |
|
|
$table-> attach (gen_label_in_left($p), $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
649 |
|
|
$table-> attach ($combo, $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
650 |
|
|
$table-> attach ($lock, $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
651 |
|
|
my @a=('sent','rsv','total');
|
652 |
|
|
foreach my $q (@a){
|
653 |
|
|
my $s = (defined $com_tasks{$p}{$q}) ? $com_tasks{$p}{$q} : '-';
|
654 |
|
|
$table-> attach (gen_label_in_left($s), $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $col++;
|
655 |
|
|
|
656 |
|
|
}
|
657 |
|
|
|
658 |
|
|
|
659 |
|
|
|
660 |
|
|
|
661 |
|
|
|
662 |
|
|
$i++;
|
663 |
|
|
$col=0;
|
664 |
|
|
$row++;
|
665 |
|
|
}
|
666 |
|
|
|
667 |
|
|
|
668 |
|
|
return $sc_win;
|
669 |
|
|
|
670 |
|
|
}
|
671 |
|
|
|
672 |
|
|
|
673 |
|
|
|
674 |
|
|
########
|
675 |
|
|
# map_info
|
676 |
|
|
#######
|
677 |
|
|
|
678 |
|
|
|
679 |
|
|
sub map_info {
|
680 |
|
|
my ($self)=@_;
|
681 |
|
|
my $sc_win = gen_scr_win_with_adjst($self,'map_info');
|
682 |
|
|
my $table= def_table(10,10,FALSE);
|
683 |
|
|
$sc_win->add_with_viewport($table);
|
684 |
|
|
|
685 |
|
|
my $row=0;
|
686 |
|
|
my $col=0;
|
687 |
|
|
my ($avg,$max,$min,$norm)=get_map_info($self);
|
688 |
|
|
|
689 |
|
|
|
690 |
|
|
my @data = (
|
691 |
|
|
{label => "Average distance", value =>"$avg"},
|
692 |
|
|
{label => "Max distance", value =>"$max" },
|
693 |
|
|
{label => "Min distance",value => "$min"},
|
694 |
|
|
{label => "Normlized data per hop", value =>"$norm" }
|
695 |
|
|
);
|
696 |
|
|
|
697 |
|
|
|
698 |
|
|
|
699 |
|
|
# create list store
|
700 |
|
|
my $store = Gtk2::ListStore->new (#'Glib::Boolean', # => G_TYPE_BOOLEAN
|
701 |
|
|
#'Glib::Uint', # => G_TYPE_UINT
|
702 |
|
|
'Glib::String', # => G_TYPE_STRING
|
703 |
|
|
'Glib::String'); # you get the idea
|
704 |
|
|
|
705 |
|
|
# add data to the list store
|
706 |
|
|
foreach my $d (@data) {
|
707 |
|
|
my $iter = $store->append;
|
708 |
|
|
$store->set ($iter,
|
709 |
|
|
0, $d->{label},
|
710 |
|
|
1, $d->{value},
|
711 |
|
|
);
|
712 |
|
|
}
|
713 |
|
|
|
714 |
|
|
my $treeview = Gtk2::TreeView->new ($store);
|
715 |
|
|
$treeview->set_rules_hint (TRUE);
|
716 |
|
|
|
717 |
|
|
|
718 |
|
|
$treeview->set_search_column (1);
|
719 |
|
|
|
720 |
|
|
|
721 |
|
|
# add columns to the tree view
|
722 |
|
|
my $renderer = Gtk2::CellRendererToggle->new;
|
723 |
|
|
$renderer->signal_connect (toggled => \&fixed_toggled, $store);
|
724 |
|
|
|
725 |
|
|
|
726 |
|
|
|
727 |
|
|
# column for severities
|
728 |
|
|
$renderer = Gtk2::CellRendererText->new;
|
729 |
|
|
my $column = Gtk2::TreeViewColumn->new_with_attributes ("Mapping summary",
|
730 |
|
|
$renderer,
|
731 |
|
|
text => 0);
|
732 |
|
|
$column->set_sort_column_id (0);
|
733 |
|
|
$treeview->append_column ($column);
|
734 |
|
|
|
735 |
|
|
# column for description
|
736 |
|
|
$renderer = Gtk2::CellRendererText->new;
|
737 |
|
|
$column = Gtk2::TreeViewColumn->new_with_attributes (" ",
|
738 |
|
|
$renderer,
|
739 |
|
|
text => 1);
|
740 |
|
|
$column->set_sort_column_id (1);
|
741 |
|
|
$treeview->append_column ($column);
|
742 |
|
|
|
743 |
|
|
|
744 |
|
|
$table-> attach ($treeview, $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $row++;
|
745 |
|
|
#$table-> attach (gen_label_in_left("Max distance: $max "), $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $row++;
|
746 |
|
|
#$table-> attach (gen_label_in_left("Min distance: $min "), $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $row++;
|
747 |
|
|
#$table-> attach (gen_label_in_left("Normlized data per hop: $norm"), $col, $col+1, $row, $row+1,'shrink','shrink',2,2); $row++;
|
748 |
|
|
|
749 |
|
|
|
750 |
|
|
return $sc_win;
|
751 |
|
|
|
752 |
|
|
}
|
753 |
|
|
|
754 |
|
|
|
755 |
|
|
|
756 |
|
|
|
757 |
|
|
sub get_map_info {
|
758 |
|
|
my $self=shift;
|
759 |
|
|
my ($avg,$max,$min,$norm)=(0,0,999999,0);
|
760 |
|
|
my $sum=0;
|
761 |
|
|
my $num=0;
|
762 |
|
|
|
763 |
|
|
my $data=0;
|
764 |
|
|
my $comtotal=0;
|
765 |
|
|
|
766 |
|
|
my @traces= $self->get_trace_list();
|
767 |
|
|
foreach my $p (@traces) {
|
768 |
|
|
my ($src, $dst, $Mbytes, $file_id, $file_name)=$self->get_trace($p);
|
769 |
|
|
my $src_tile = $self->object_get_attribute('MAP_TILE',"$src");
|
770 |
|
|
my $dst_tile = $self->object_get_attribute('MAP_TILE',"$dst");
|
771 |
|
|
next if(!defined $src_tile || !defined $dst_tile );
|
772 |
|
|
next if($src_tile eq '-' || $dst_tile eq "-" );
|
773 |
|
|
my ($src_x,$src_y)= tile_id_to_loc($src_tile);
|
774 |
|
|
my ($dst_x,$dst_y)= tile_id_to_loc($dst_tile);
|
775 |
|
|
|
776 |
|
|
|
777 |
|
|
|
778 |
|
|
#print" ($dst_x,$dst_y)= tile_id_to_loc($dst_tile)\n";
|
779 |
|
|
|
780 |
|
|
my $mah_distance=get_mah_distance($src_x,$src_y,$dst_x,$dst_y);
|
781 |
|
|
#print "$mah_distance=get_mah_distance($src_x,$src_y,$dst_x,$dst_y);\n";
|
782 |
|
|
$min = $mah_distance if($min> $mah_distance);
|
783 |
|
|
$max = $mah_distance if($max< $mah_distance);
|
784 |
|
|
$sum+=$mah_distance;
|
785 |
|
|
$num++;
|
786 |
|
|
|
787 |
|
|
$data+=($Mbytes*$mah_distance);
|
788 |
|
|
$comtotal+=$Mbytes;
|
789 |
|
|
|
790 |
|
|
}
|
791 |
|
|
|
792 |
|
|
$avg=$sum/$num if($num!=0);
|
793 |
|
|
$min = 0 if $min == 999999;
|
794 |
|
|
$norm = $data/$comtotal if ($comtotal !=0);
|
795 |
|
|
return ($avg,$max,$min,$norm);
|
796 |
|
|
|
797 |
|
|
}
|
798 |
|
|
|
799 |
|
|
|
800 |
|
|
|
801 |
|
|
|
802 |
|
|
|
803 |
|
|
sub map_combobox {
|
804 |
|
|
my ($object,$task_name,$content,$default)=@_;
|
805 |
|
|
my @combo_list=@{$content};
|
806 |
|
|
my $value=$object->object_get_attribute("MAP_TILE",$task_name);
|
807 |
|
|
my $pos;
|
808 |
|
|
$pos=get_pos($value, @combo_list) if (defined $value);
|
809 |
|
|
if(!defined $pos && defined $default){
|
810 |
|
|
$object->object_add_attribute("MAP_TILE",$task_name,$default);
|
811 |
|
|
$pos=get_item_pos($default, @combo_list);
|
812 |
|
|
}
|
813 |
|
|
#print " my $pos=get_item_pos($value, @combo_list);\n";
|
814 |
|
|
my $widget=gen_combo(\@combo_list, $pos);
|
815 |
|
|
$widget-> signal_connect("changed" => sub{
|
816 |
|
|
my $new_tile=$widget->get_active_text();
|
817 |
|
|
$object->map_task($task_name,$new_tile);
|
818 |
|
|
|
819 |
|
|
set_gui_status($object,'ref',1);
|
820 |
|
|
});
|
821 |
|
|
return $widget;
|
822 |
|
|
}
|
823 |
|
|
|
824 |
|
|
|
825 |
|
|
##########
|
826 |
|
|
# save_as
|
827 |
|
|
##########
|
828 |
|
|
sub save_as{
|
829 |
|
|
my ($self)=@_;
|
830 |
|
|
# read emulation name
|
831 |
|
|
my $name=$self->object_get_attribute ("save_as",undef);
|
832 |
|
|
my $s= (!defined $name)? 0 : (length($name)==0)? 0 :1;
|
833 |
|
|
if ($s == 0){
|
834 |
|
|
message_dialog("Please define file name!");
|
835 |
|
|
return 0;
|
836 |
|
|
}
|
837 |
|
|
# Write object file
|
838 |
|
|
open(FILE, ">lib/simulate/$name.TRC") || die "Can not open: $!";
|
839 |
|
|
print FILE perl_file_header("$name.TRC");
|
840 |
|
|
print FILE Data::Dumper->Dump([\%$self],['Trace']);
|
841 |
|
|
close(FILE) || die "Error closing file: $!";
|
842 |
|
|
message_dialog("workspace has been saved as lib/simulate/$name.TRC!");
|
843 |
|
|
return 1;
|
844 |
|
|
}
|
845 |
|
|
|
846 |
|
|
|
847 |
|
|
|
848 |
|
|
|
849 |
|
|
#############
|
850 |
|
|
# load_workspace
|
851 |
|
|
############
|
852 |
|
|
|
853 |
|
|
sub load_workspace {
|
854 |
|
|
my $self=shift;
|
855 |
|
|
my $file;
|
856 |
|
|
my $dialog = Gtk2::FileChooserDialog->new(
|
857 |
|
|
'Select a File', undef,
|
858 |
|
|
'open',
|
859 |
|
|
'gtk-cancel' => 'cancel',
|
860 |
|
|
'gtk-ok' => 'ok',
|
861 |
|
|
);
|
862 |
|
|
|
863 |
|
|
my $filter = Gtk2::FileFilter->new();
|
864 |
|
|
$filter->set_name("TRC");
|
865 |
|
|
$filter->add_pattern("*.TRC");
|
866 |
|
|
$dialog->add_filter ($filter);
|
867 |
|
|
my $dir = Cwd::getcwd();
|
868 |
|
|
$dialog->set_current_folder ("$dir/lib/simulate");
|
869 |
|
|
|
870 |
|
|
|
871 |
|
|
if ( "ok" eq $dialog->run ) {
|
872 |
|
|
$file = $dialog->get_filename;
|
873 |
|
|
my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
|
874 |
43 |
alirezamon |
if($suffix eq '.TRC'){
|
875 |
|
|
my ($pp,$r,$err) = regen_object($file);
|
876 |
|
|
if ($r){
|
877 |
|
|
message_dialog("**Error reading $file file: $err\n");
|
878 |
38 |
alirezamon |
$dialog->destroy;
|
879 |
|
|
return;
|
880 |
|
|
}
|
881 |
|
|
|
882 |
|
|
clone_obj($self,$pp);
|
883 |
|
|
#message_dialog("done!");
|
884 |
|
|
}
|
885 |
|
|
}
|
886 |
|
|
$dialog->destroy;
|
887 |
|
|
}
|
888 |
|
|
|
889 |
|
|
|
890 |
|
|
########
|
891 |
|
|
# genereate_output
|
892 |
|
|
########
|
893 |
|
|
|
894 |
|
|
sub genereate_output{
|
895 |
|
|
my $self=shift;
|
896 |
|
|
my $name= $self->object_get_attribute('out_name');
|
897 |
|
|
my $size= (defined $name)? length($name) :0;
|
898 |
|
|
if ($size ==0) {
|
899 |
|
|
message_dialog("Please define the output file name!");
|
900 |
|
|
return 0;
|
901 |
|
|
}
|
902 |
|
|
|
903 |
|
|
|
904 |
|
|
|
905 |
|
|
# make target dir
|
906 |
|
|
my $dir = Cwd::getcwd();
|
907 |
|
|
my $target_dir = "$ENV{'PRONOC_WORK'}/traffic_pattern";
|
908 |
|
|
mkpath("$target_dir",1,0755);
|
909 |
|
|
|
910 |
|
|
my @tasks=get_all_tasks($self);
|
911 |
|
|
foreach my $p (@tasks) {
|
912 |
|
|
my $tile=$self->object_get_attribute("MAP_TILE",$p);
|
913 |
|
|
if ( $tile eq "-" ){
|
914 |
|
|
message_dialog("Error: unmapped task. Please map task $p to a tile", 'error' );
|
915 |
|
|
return;
|
916 |
|
|
}
|
917 |
|
|
|
918 |
|
|
}
|
919 |
|
|
#creat output file
|
920 |
|
|
open(FILE, ">$target_dir/$name.cfg") || die "Can not open: $!";
|
921 |
|
|
print FILE get_cfg_content($self);
|
922 |
|
|
close(FILE) || die "Error closing file: $!";
|
923 |
|
|
message_dialog("The traffic pattern is saved as $target_dir/$name.cfg" );
|
924 |
|
|
|
925 |
|
|
}
|
926 |
|
|
|
927 |
|
|
sub get_cfg_content{
|
928 |
|
|
my $self=shift;
|
929 |
|
|
my $file="% source tile, destination tile, bytes, initial_weight, min_pck_size, max_pck_size, burst_size, injection_rate(%), injection_rate variation(%)\n";
|
930 |
|
|
|
931 |
|
|
|
932 |
|
|
|
933 |
|
|
my @traces= $self->get_trace_list();
|
934 |
|
|
foreach my $p (@traces) {
|
935 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var)=$self->get_trace($p);
|
936 |
|
|
|
937 |
|
|
|
938 |
|
|
my $src_tile=$self->get_tile_id($src);
|
939 |
|
|
my $dst_tile=$self->get_tile_id($dst);
|
940 |
|
|
my $auto=$self->object_get_attribute('Auto','Auto_inject');
|
941 |
|
|
|
942 |
|
|
my $bytes = $Mbytes * 1000000;
|
943 |
|
|
|
944 |
|
|
$file=$file."$src_tile, $dst_tile, $bytes, $init_weight, $min_pck, $max_pck";
|
945 |
|
|
$file=$file.", $burst, $injct_rate, $injct_rate_var \n" if ($auto eq "1\'b0");
|
946 |
|
|
$file=$file." \n" if ($auto eq "1\'b1");
|
947 |
|
|
}
|
948 |
|
|
|
949 |
|
|
return $file;
|
950 |
|
|
}
|
951 |
|
|
|
952 |
|
|
sub get_tile_id{
|
953 |
|
|
my ($self,$task)=@_;
|
954 |
43 |
alirezamon |
my $nx=$self->object_get_attribute('noc_param','T1');
|
955 |
38 |
alirezamon |
my $tile=$self->object_get_attribute("MAP_TILE",$task);
|
956 |
|
|
my ($x, $y) = $tile =~ /(\d+)/g;
|
957 |
|
|
$y=0 if(!defined $y);
|
958 |
|
|
my $IP_NUM = ($y * $nx) + $x;
|
959 |
|
|
return $IP_NUM;
|
960 |
|
|
}
|
961 |
|
|
|
962 |
|
|
sub object_add_attribute{
|
963 |
|
|
my ($self,$attribute1,$attribute2,$value)=@_;
|
964 |
|
|
if(!defined $attribute2){$self->{$attribute1}=$value;}
|
965 |
|
|
else {$self->{$attribute1}{$attribute2}=$value;}
|
966 |
|
|
|
967 |
|
|
}
|
968 |
|
|
|
969 |
|
|
|
970 |
|
|
|
971 |
|
|
sub object_get_attribute{
|
972 |
|
|
my ($self,$attribute1,$attribute2)=@_;
|
973 |
|
|
if(!defined $attribute2) {return $self->{$attribute1};}
|
974 |
|
|
return $self->{$attribute1}{$attribute2};
|
975 |
|
|
|
976 |
|
|
|
977 |
|
|
}
|
978 |
|
|
|
979 |
|
|
|
980 |
|
|
sub object_add_attribute_order{
|
981 |
|
|
my ($self,$attribute,@param)=@_;
|
982 |
|
|
$self->{'parameters_order'}{$attribute}=[] if (!defined $self->{parameters_order}{$attribute});
|
983 |
|
|
foreach my $p (@param){
|
984 |
|
|
push (@{$self->{parameters_order}{$attribute}},$p);
|
985 |
|
|
|
986 |
|
|
}
|
987 |
|
|
}
|
988 |
|
|
sub object_get_attribute_order{
|
989 |
|
|
my ($self,$attribute)=@_;
|
990 |
|
|
return @{$self->{parameters_order}{$attribute}};
|
991 |
|
|
}
|
992 |
|
|
|
993 |
|
|
sub object_remove_attribute{
|
994 |
|
|
my ($self,$attribute1,$attribute2)=@_;
|
995 |
|
|
if(!defined $attribute2){
|
996 |
|
|
delete $self->{$attribute1} if ( exists( $self->{$attribute1}));
|
997 |
|
|
}
|
998 |
|
|
else {
|
999 |
|
|
delete $self->{$attribute1}{$attribute2} if ( exists( $self->{$attribute1}{$attribute2})); ;
|
1000 |
|
|
|
1001 |
|
|
}
|
1002 |
|
|
|
1003 |
|
|
}
|
1004 |
|
|
|
1005 |
|
|
sub add_trace{
|
1006 |
|
|
my ($self, $file_id,$trace_id, $source,$dest, $Mbytes, $file_name)=@_;
|
1007 |
|
|
$self->object_add_attribute("trace_$trace_id",'file',$file_id);
|
1008 |
|
|
$self->object_add_attribute("trace_$trace_id",'source',"${file_id}${source}");
|
1009 |
|
|
$self->object_add_attribute("trace_$trace_id",'destination',"${file_id}${dest}");
|
1010 |
|
|
$self->object_add_attribute("trace_$trace_id",'Mbytes', $Mbytes);
|
1011 |
|
|
$self->object_add_attribute("trace_$trace_id",'file_name', $file_name);
|
1012 |
|
|
$self->object_add_attribute("trace_$trace_id",'selected', 0);
|
1013 |
|
|
$self->object_add_attribute("trace_$trace_id",'init_weight', 1);
|
1014 |
|
|
|
1015 |
|
|
$self->{'traces'}{$trace_id}=1;
|
1016 |
|
|
|
1017 |
|
|
}
|
1018 |
|
|
|
1019 |
|
|
sub remove_trace{
|
1020 |
|
|
my ($self, $trace_id)=@_;
|
1021 |
|
|
delete $self->{"trace_$trace_id"};
|
1022 |
|
|
delete $self->{'traces'}{$trace_id};
|
1023 |
|
|
}
|
1024 |
|
|
|
1025 |
|
|
sub get_trace_list{
|
1026 |
|
|
my ($self)=@_;
|
1027 |
|
|
return sort (keys %{$self->{'traces'}});
|
1028 |
|
|
}
|
1029 |
|
|
|
1030 |
|
|
sub get_trace{
|
1031 |
|
|
my ($self,$trace_id)=@_;
|
1032 |
|
|
my $file_id = $self->object_get_attribute("trace_$trace_id",'file');
|
1033 |
|
|
my $source = $self->object_get_attribute("trace_$trace_id",'source');
|
1034 |
|
|
my $dest = $self->object_get_attribute("trace_$trace_id",'destination');
|
1035 |
|
|
my $Mbytes = $self->object_get_attribute("trace_$trace_id",'Mbytes');
|
1036 |
|
|
my $file_name = $self->object_get_attribute("trace_$trace_id",'file_name');
|
1037 |
|
|
my $init_weight = $self->object_get_attribute("trace_$trace_id",'init_weight');
|
1038 |
|
|
my $min_pck_size= $self->object_get_attribute("trace_$trace_id",'min_pck_size');
|
1039 |
|
|
my $max_pck_size= $self->object_get_attribute("trace_$trace_id",'max_pck_size');
|
1040 |
|
|
my $burst_size = $self->object_get_attribute("trace_$trace_id",'burst_size');
|
1041 |
|
|
my $injct_rate = $self->object_get_attribute("trace_$trace_id",'injct_rate');
|
1042 |
|
|
my $injct_rate_var = $self->object_get_attribute("trace_$trace_id",'injct_rate_var');
|
1043 |
|
|
|
1044 |
|
|
return ($source,$dest, $Mbytes, $file_id,$file_name,$init_weight,$min_pck_size, $max_pck_size, $burst_size, $injct_rate, $injct_rate_var);
|
1045 |
|
|
}
|
1046 |
|
|
|
1047 |
|
|
sub get_all_tasks{
|
1048 |
|
|
my $self=shift;
|
1049 |
|
|
my @traces= $self->get_trace_list();
|
1050 |
|
|
my @x;
|
1051 |
|
|
foreach my $p (@traces){
|
1052 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name)=$self->get_trace($p);
|
1053 |
|
|
push(@x,$src);
|
1054 |
|
|
push(@x,$dst);
|
1055 |
|
|
}
|
1056 |
|
|
my @x2 = uniq(sort @x) if (scalar @x);
|
1057 |
|
|
return @x2;
|
1058 |
|
|
}
|
1059 |
|
|
|
1060 |
|
|
|
1061 |
|
|
sub remove_mapping{
|
1062 |
|
|
my $self=shift;
|
1063 |
|
|
$self->object_add_attribute('MAP_TASK',undef,undef);
|
1064 |
|
|
$self->object_add_attribute('MAP_TILE',undef,undef);
|
1065 |
|
|
}
|
1066 |
|
|
|
1067 |
|
|
|
1068 |
|
|
|
1069 |
|
|
sub remove_nlock_mapping{
|
1070 |
|
|
my $self=shift;
|
1071 |
|
|
my @tasks=get_all_tasks($self);
|
1072 |
|
|
|
1073 |
|
|
foreach my $p (@tasks){
|
1074 |
|
|
my $lock=$self->object_get_attribute("MAP_LOCK",$p);
|
1075 |
|
|
$lock = 0 if (!defined $lock);
|
1076 |
|
|
if($lock == 0){
|
1077 |
|
|
my $tile=$self->object_get_attribute("MAP_TILE",$p);
|
1078 |
|
|
$self->object_add_attribute("MAP_TILE",$p,undef);
|
1079 |
|
|
$self->object_add_attribute("MAP_TASK",$tile,undef);
|
1080 |
|
|
|
1081 |
|
|
}
|
1082 |
|
|
}
|
1083 |
|
|
}
|
1084 |
|
|
|
1085 |
|
|
|
1086 |
|
|
sub get_nlock_tasks {
|
1087 |
|
|
#my ($self,$taskref,$tileref)=shift;
|
1088 |
|
|
my $self=shift;
|
1089 |
|
|
my @unluck_tasks;
|
1090 |
|
|
my @tasks=get_all_tasks($self);
|
1091 |
|
|
|
1092 |
|
|
foreach my $p (@tasks){
|
1093 |
|
|
my $lock=$self->object_get_attribute("MAP_LOCK",$p);
|
1094 |
|
|
$lock = 0 if (!defined $lock);
|
1095 |
|
|
if($lock == 0){
|
1096 |
|
|
push(@unluck_tasks,$p);
|
1097 |
|
|
}
|
1098 |
|
|
|
1099 |
|
|
}
|
1100 |
|
|
return @unluck_tasks;
|
1101 |
|
|
}
|
1102 |
|
|
|
1103 |
|
|
sub get_nlock_tiles {
|
1104 |
|
|
#my ($self,$taskref,$tileref)=shift;
|
1105 |
|
|
my $self=shift;
|
1106 |
|
|
my @luck_tiles;
|
1107 |
|
|
my @tasks=get_all_tasks($self);
|
1108 |
|
|
|
1109 |
|
|
foreach my $task (@tasks){
|
1110 |
|
|
my $lock=$self->object_get_attribute("MAP_LOCK",$task);
|
1111 |
|
|
$lock = 0 if (!defined $lock);
|
1112 |
|
|
if($lock == 1){
|
1113 |
|
|
my $tile=$self->object_get_attribute('MAP_TILE',"$task");
|
1114 |
|
|
push(@luck_tiles,$tile);
|
1115 |
|
|
}
|
1116 |
|
|
|
1117 |
|
|
}
|
1118 |
|
|
my @tiles=get_tiles_name($self);
|
1119 |
|
|
|
1120 |
|
|
#a-b
|
1121 |
|
|
return get_diff_array(\@tiles,\@luck_tiles);
|
1122 |
|
|
}
|
1123 |
|
|
|
1124 |
|
|
|
1125 |
|
|
sub get_locked_map {
|
1126 |
|
|
my $self=shift;
|
1127 |
|
|
my %map;
|
1128 |
|
|
my @tasks=get_all_tasks($self);
|
1129 |
|
|
|
1130 |
|
|
foreach my $task (@tasks){
|
1131 |
|
|
my $lock=$self->object_get_attribute("MAP_LOCK",$task);
|
1132 |
|
|
|
1133 |
|
|
$lock = 0 if (!defined $lock);
|
1134 |
|
|
if($lock == 1){
|
1135 |
|
|
my $tile=$self->object_get_attribute('MAP_TILE',"$task");
|
1136 |
|
|
$map{$task}=$tile;
|
1137 |
|
|
}
|
1138 |
|
|
|
1139 |
|
|
}
|
1140 |
|
|
return %map;
|
1141 |
|
|
}
|
1142 |
|
|
|
1143 |
|
|
|
1144 |
|
|
#########
|
1145 |
|
|
# Mapping algorithm
|
1146 |
|
|
#########
|
1147 |
|
|
sub random_map{
|
1148 |
|
|
my $self=shift;
|
1149 |
|
|
|
1150 |
|
|
|
1151 |
|
|
|
1152 |
43 |
alirezamon |
my $nx=$self->object_get_attribute('noc_param','T1');
|
1153 |
|
|
my $ny=$self->object_get_attribute('noc_param','T2');
|
1154 |
38 |
alirezamon |
my $nc= $nx * $ny;
|
1155 |
|
|
|
1156 |
|
|
|
1157 |
|
|
|
1158 |
|
|
my @tasks=get_nlock_tasks($self);
|
1159 |
|
|
my @tiles=get_nlock_tiles($self);
|
1160 |
|
|
$self->remove_nlock_mapping() ;
|
1161 |
|
|
|
1162 |
|
|
|
1163 |
|
|
my @rnd= shuffle @tiles;
|
1164 |
|
|
|
1165 |
|
|
my $i=0;
|
1166 |
|
|
foreach my $task (@tasks){
|
1167 |
|
|
if($i>=scalar @rnd){
|
1168 |
|
|
last;
|
1169 |
|
|
};
|
1170 |
|
|
my $tile=$rnd[$i];
|
1171 |
|
|
$self->object_add_attribute('MAP_TILE',"$task",$tile);
|
1172 |
|
|
$self->object_add_attribute('MAP_TASK',"$tile",$task);
|
1173 |
|
|
|
1174 |
|
|
$i++;
|
1175 |
|
|
|
1176 |
|
|
}
|
1177 |
|
|
|
1178 |
|
|
set_gui_status($self,"ref",1);
|
1179 |
|
|
|
1180 |
|
|
}
|
1181 |
|
|
|
1182 |
|
|
sub direct_map {
|
1183 |
|
|
my $self=shift;
|
1184 |
|
|
|
1185 |
43 |
alirezamon |
my $nx=$self->object_get_attribute('noc_param','T1');
|
1186 |
|
|
my $ny=$self->object_get_attribute('noc_param','T2');
|
1187 |
38 |
alirezamon |
my $nc= $nx * $ny;
|
1188 |
|
|
my @tasks=get_nlock_tasks($self);
|
1189 |
|
|
my @tiles=get_nlock_tiles($self);
|
1190 |
|
|
$self->remove_nlock_mapping() ;
|
1191 |
|
|
|
1192 |
|
|
my @sort_tiles;
|
1193 |
|
|
my %tilenum;
|
1194 |
|
|
foreach my $tile (@tiles){
|
1195 |
|
|
my ($x,$y)=tile_id_to_loc($tile);
|
1196 |
|
|
my $id= $y*$nx+$x;
|
1197 |
|
|
$tilenum{$id}=$tile;
|
1198 |
|
|
}
|
1199 |
|
|
|
1200 |
|
|
foreach my $id (sort keys %tilenum){
|
1201 |
|
|
|
1202 |
|
|
push(@sort_tiles, $tilenum{$id});
|
1203 |
|
|
}
|
1204 |
|
|
|
1205 |
|
|
|
1206 |
|
|
my @sort_tasks = sort @tasks;
|
1207 |
|
|
|
1208 |
|
|
|
1209 |
|
|
my $i=0;
|
1210 |
|
|
foreach my $task (@sort_tasks){
|
1211 |
|
|
if($i>=scalar @sort_tiles){
|
1212 |
|
|
last;
|
1213 |
|
|
};
|
1214 |
|
|
my $tile=$sort_tiles[$i];
|
1215 |
|
|
$self->object_add_attribute('MAP_TILE',"$task",$tile);
|
1216 |
|
|
$self->object_add_attribute('MAP_TASK',"$tile",$task);
|
1217 |
|
|
|
1218 |
|
|
$i++;
|
1219 |
|
|
|
1220 |
|
|
}
|
1221 |
|
|
|
1222 |
|
|
set_gui_status($self,"ref",1);
|
1223 |
|
|
|
1224 |
|
|
|
1225 |
|
|
}
|
1226 |
|
|
|
1227 |
|
|
|
1228 |
|
|
|
1229 |
|
|
|
1230 |
|
|
|
1231 |
|
|
|
1232 |
|
|
|
1233 |
|
|
|
1234 |
|
|
|
1235 |
|
|
|
1236 |
|
|
sub network_dim_cal{
|
1237 |
|
|
my $n_tasks= shift;
|
1238 |
|
|
|
1239 |
|
|
my $dim_y = floor(sqrt($n_tasks));
|
1240 |
|
|
|
1241 |
|
|
my $dim_x = ceil($n_tasks/$dim_y);
|
1242 |
|
|
|
1243 |
|
|
return ($dim_x,$dim_y);
|
1244 |
|
|
|
1245 |
|
|
#cout << "dim_x = " << dim_x << "; dim_y = " << dim_y << endl;
|
1246 |
|
|
}
|
1247 |
|
|
|
1248 |
|
|
|
1249 |
|
|
sub get_tiles_name{
|
1250 |
|
|
my $self=shift;
|
1251 |
|
|
my @tiles;
|
1252 |
43 |
alirezamon |
my $nx=$self->object_get_attribute('noc_param','T1');
|
1253 |
|
|
my $ny=$self->object_get_attribute('noc_param','T2');
|
1254 |
38 |
alirezamon |
if(defined $ny){
|
1255 |
|
|
if($ny == 1){
|
1256 |
|
|
for(my $x=0; $x<$nx; $x++){
|
1257 |
|
|
push(@tiles,"tile($x)");
|
1258 |
|
|
}
|
1259 |
|
|
|
1260 |
|
|
}
|
1261 |
|
|
else{
|
1262 |
43 |
alirezamon |
for(my $y=0; $y<$ny; $y++){my $nx=$self->object_get_attribute('noc_param','T1');
|
1263 |
|
|
my $ny=$self->object_get_attribute('noc_param','T2');
|
1264 |
38 |
alirezamon |
for(my $x=0; $x<$nx; $x++){
|
1265 |
|
|
push(@tiles,"tile(${x}_$y)");
|
1266 |
|
|
}
|
1267 |
|
|
}
|
1268 |
|
|
|
1269 |
|
|
}
|
1270 |
|
|
}
|
1271 |
|
|
return @tiles;
|
1272 |
|
|
}
|
1273 |
|
|
|
1274 |
|
|
sub get_tile_name{
|
1275 |
|
|
my ($self,$x,$y)=@_;
|
1276 |
|
|
|
1277 |
43 |
alirezamon |
my $nx=$self->object_get_attribute('noc_param','T1');
|
1278 |
|
|
my $ny=$self->object_get_attribute('noc_param','T2');
|
1279 |
38 |
alirezamon |
if(defined $ny){
|
1280 |
|
|
return "tile($x)" if($ny == 1);
|
1281 |
|
|
}
|
1282 |
|
|
return "tile(${x}_$y)";
|
1283 |
|
|
}
|
1284 |
|
|
|
1285 |
|
|
|
1286 |
|
|
sub tile_id_to_loc{
|
1287 |
|
|
my $tile=shift;
|
1288 |
|
|
my ($x, $y) = $tile =~ /(\d+)/g;
|
1289 |
|
|
$y=0 if(!defined $y);
|
1290 |
|
|
return ($x,$y);
|
1291 |
|
|
}
|
1292 |
|
|
|
1293 |
|
|
sub get_mah_distance{
|
1294 |
|
|
my ($x1,$y1,$x2,$y2)=@_;
|
1295 |
|
|
my $x_diff = ($x1 > $x2) ? ($x1 - $x2) : ($x2 - $x1);
|
1296 |
|
|
my $y_diff = ($y1 > $y2) ? ($y1 - $y2) : ($y2 - $y1);
|
1297 |
|
|
my $mah_distance = $x_diff + $y_diff;
|
1298 |
|
|
return $mah_distance;
|
1299 |
|
|
}
|
1300 |
|
|
|
1301 |
|
|
sub get_communication_task{
|
1302 |
|
|
my $self=shift;
|
1303 |
|
|
my %com_tasks;
|
1304 |
|
|
my @traces= $self->get_trace_list();
|
1305 |
|
|
my @tasks=get_all_tasks($self);
|
1306 |
|
|
foreach my $p (@tasks){
|
1307 |
|
|
$com_tasks{$p}{'total'}= 0;
|
1308 |
|
|
foreach my $q (@tasks){
|
1309 |
|
|
$com_tasks{$p}{$q}= 0;
|
1310 |
|
|
|
1311 |
|
|
}
|
1312 |
|
|
}
|
1313 |
|
|
|
1314 |
|
|
foreach my $p (@traces){
|
1315 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name)=$self->get_trace($p);
|
1316 |
|
|
|
1317 |
|
|
|
1318 |
|
|
$com_tasks{$src}{'sent'} += $Mbytes;
|
1319 |
|
|
$com_tasks{$dst}{'rsv'} += $Mbytes;
|
1320 |
|
|
|
1321 |
|
|
$com_tasks{$src}{'total'} += $Mbytes;
|
1322 |
|
|
$com_tasks{$dst}{'total'} += $Mbytes;
|
1323 |
|
|
$com_tasks{$src}{$dst} += $Mbytes;
|
1324 |
|
|
$com_tasks{$file_id}{'maxsent'} = $com_tasks{$src}{'sent'} if(!defined $com_tasks{$file_id}{'maxsent'});
|
1325 |
|
|
$com_tasks{$file_id}{'maxsent'} = $com_tasks{$src}{'sent'} if( $com_tasks{$file_id}{'maxsent'}<$com_tasks{$src}{'sent'});
|
1326 |
|
|
|
1327 |
|
|
|
1328 |
|
|
|
1329 |
|
|
my $minpck = $self->object_get_attribute("trace_$p",'min_pck_size');
|
1330 |
|
|
my $maxpck = $self->object_get_attribute("trace_$p",'max_pck_size');
|
1331 |
|
|
my $avg_pck_size =($minpck+ $maxpck)/2;
|
1332 |
|
|
my $pck_num = ($Mbytes*8) /($avg_pck_size*64);
|
1333 |
|
|
$pck_num= 1 if($pck_num==0);
|
1334 |
|
|
$com_tasks{$src}{'min_pck_num'} =$pck_num if(!defined $com_tasks{$src}{'min_pck_num'});
|
1335 |
|
|
$com_tasks{$src}{'min_pck_num'} =$pck_num if( $com_tasks{$src}{'min_pck_num'} > $pck_num);
|
1336 |
|
|
|
1337 |
|
|
}
|
1338 |
|
|
return %com_tasks;
|
1339 |
|
|
}
|
1340 |
|
|
|
1341 |
|
|
|
1342 |
|
|
sub find_max_neighbor_tile{
|
1343 |
|
|
my $self=shift;
|
1344 |
43 |
alirezamon |
my $nx=$self->object_get_attribute('noc_param','T1');
|
1345 |
|
|
my $ny=$self->object_get_attribute('noc_param','T2');
|
1346 |
38 |
alirezamon |
my $x_mid = floor($nx/2);
|
1347 |
|
|
my $y_mid = floor($ny/2);
|
1348 |
|
|
#my $centered_tile= get_tile_name($self,$x_mid ,$y_mid);
|
1349 |
|
|
#Select the tile located in center as the max-neighbor if its not locked for any other task
|
1350 |
|
|
#therwise select the tile with the min manhatan distance to center tile
|
1351 |
|
|
my @tiles=get_nlock_tiles($self);
|
1352 |
|
|
my $min=1000000;
|
1353 |
|
|
my $max_neighbors_tile_id;
|
1354 |
|
|
foreach my $tile (@tiles){
|
1355 |
|
|
my ($x,$y)=tile_id_to_loc($tile);
|
1356 |
|
|
my $mah_distance=get_mah_distance($x,$y,$x_mid,$y_mid);
|
1357 |
|
|
if($min > $mah_distance ){
|
1358 |
|
|
$min = $mah_distance;
|
1359 |
|
|
$max_neighbors_tile_id=$tile;
|
1360 |
|
|
}
|
1361 |
|
|
|
1362 |
|
|
}
|
1363 |
|
|
|
1364 |
|
|
return $max_neighbors_tile_id;
|
1365 |
|
|
}
|
1366 |
|
|
|
1367 |
|
|
|
1368 |
|
|
sub find_min_neighbor_tile {
|
1369 |
|
|
my $self=shift;
|
1370 |
43 |
alirezamon |
my $nx=$self->object_get_attribute('noc_param','T1');
|
1371 |
|
|
my $ny=$self->object_get_attribute('noc_param','T2');
|
1372 |
38 |
alirezamon |
my $x_mid = 0;
|
1373 |
|
|
my $y_mid = 0;
|
1374 |
|
|
#my $centered_tile= get_tile_name($self,$x_mid ,$y_mid);
|
1375 |
|
|
#Select the tile located in center as the max-neighbor if its not locked for any other task
|
1376 |
|
|
#therwise select the tile with the min manhatan distance to center tile
|
1377 |
|
|
my @tiles=get_nlock_tiles($self);
|
1378 |
|
|
my $min=1000000;
|
1379 |
|
|
my $min_neighbors_tile_id;
|
1380 |
|
|
foreach my $tile (@tiles){
|
1381 |
|
|
my ($x,$y)=tile_id_to_loc($tile);
|
1382 |
|
|
my $mah_distance=get_mah_distance($x,$y,$x_mid,$y_mid);
|
1383 |
|
|
if($min > $mah_distance ){
|
1384 |
|
|
$min = $mah_distance;
|
1385 |
|
|
$min_neighbors_tile_id=$tile;
|
1386 |
|
|
}
|
1387 |
|
|
|
1388 |
|
|
}
|
1389 |
|
|
|
1390 |
|
|
return $min_neighbors_tile_id;
|
1391 |
|
|
}
|
1392 |
|
|
|
1393 |
|
|
|
1394 |
|
|
|
1395 |
|
|
sub nmap_algorithm{
|
1396 |
|
|
|
1397 |
|
|
my $self=shift;
|
1398 |
|
|
|
1399 |
|
|
|
1400 |
43 |
alirezamon |
my $nx=$self->object_get_attribute('noc_param','T1');
|
1401 |
|
|
my $ny=$self->object_get_attribute('noc_param','T2');
|
1402 |
38 |
alirezamon |
my $nc= $nx * $ny;
|
1403 |
|
|
|
1404 |
|
|
my @tasks=get_all_tasks($self);
|
1405 |
|
|
my @tiles= get_tiles_name($self);
|
1406 |
|
|
|
1407 |
|
|
my $n_tasks = scalar @tasks;
|
1408 |
|
|
|
1409 |
|
|
|
1410 |
|
|
|
1411 |
|
|
|
1412 |
|
|
my @unmapped_tasks_set=@tasks; # unmapped set of tasks
|
1413 |
|
|
my @unallocated_tiles_set=@tiles; # tile ids which are not allocated yet
|
1414 |
|
|
|
1415 |
|
|
|
1416 |
|
|
|
1417 |
|
|
|
1418 |
|
|
#------ step 1: find the task with highest weighted communication volume
|
1419 |
|
|
# find the max of com_vol
|
1420 |
|
|
# consider all incoming and outgoing connections of each tasks
|
1421 |
|
|
|
1422 |
|
|
my %com_tasks= $self->get_communication_task();
|
1423 |
|
|
#print Data::Dumper->Dump([\%com_tasks],['mpsoc']);
|
1424 |
|
|
|
1425 |
|
|
my $max_com_task;
|
1426 |
|
|
my $max_com =0;
|
1427 |
|
|
foreach my $p (sort keys %com_tasks){
|
1428 |
|
|
#print "$p\n";
|
1429 |
|
|
if(defined $com_tasks{$p}{'total'}){
|
1430 |
|
|
if ($com_tasks{$p}{'total'} >$max_com){
|
1431 |
|
|
$max_com = $com_tasks{$p}{'total'};
|
1432 |
|
|
$max_com_task = $p;
|
1433 |
|
|
}}
|
1434 |
|
|
}
|
1435 |
|
|
|
1436 |
|
|
|
1437 |
|
|
|
1438 |
|
|
|
1439 |
|
|
#------ step 2: find the tile with max number of neighbors
|
1440 |
|
|
# normally, this tile is in the middle of the array
|
1441 |
|
|
my $max_neighbors_tile_id = find_max_neighbor_tile($self);
|
1442 |
|
|
|
1443 |
|
|
|
1444 |
|
|
|
1445 |
|
|
|
1446 |
|
|
my %map=get_locked_map ($self);
|
1447 |
|
|
$self->remove_nlock_mapping();
|
1448 |
|
|
foreach my $mapped_task (sort keys %map){
|
1449 |
|
|
my $mapped_tile=$map{$mapped_task};
|
1450 |
|
|
@unmapped_tasks_set=remove_scolar_from_array(\@unmapped_tasks_set,$mapped_task);
|
1451 |
|
|
@unallocated_tiles_set=remove_scolar_from_array(\@unallocated_tiles_set,$mapped_tile);
|
1452 |
|
|
}
|
1453 |
|
|
|
1454 |
|
|
|
1455 |
|
|
|
1456 |
|
|
|
1457 |
|
|
# add this task with highest weighted communication volume to the mapped task set
|
1458 |
|
|
#push(@mapped_tasks_set,$max_com_task);
|
1459 |
|
|
#task_mapping[max_com_task] = max_neighbors_tile_id;
|
1460 |
|
|
|
1461 |
|
|
if(!defined $map{$max_com_task}){
|
1462 |
|
|
$map{$max_com_task}=$max_neighbors_tile_id;
|
1463 |
|
|
@unmapped_tasks_set=remove_scolar_from_array(\@unmapped_tasks_set,$max_com_task);
|
1464 |
|
|
@unallocated_tiles_set=remove_scolar_from_array(\@unallocated_tiles_set,$max_neighbors_tile_id);
|
1465 |
|
|
}
|
1466 |
|
|
|
1467 |
|
|
|
1468 |
|
|
|
1469 |
|
|
|
1470 |
|
|
|
1471 |
|
|
|
1472 |
|
|
|
1473 |
|
|
#------ step 3: map all unmapped tasks
|
1474 |
|
|
while(scalar @unmapped_tasks_set){
|
1475 |
|
|
$max_com =0;
|
1476 |
|
|
my $max_com_unmapped_task;
|
1477 |
|
|
my $max_overall_com=0;
|
1478 |
|
|
#--------- step 3.1:
|
1479 |
|
|
# find the unmapped task which communicates most with mapped_tasks_set
|
1480 |
|
|
# among many tasks which have the same communication volume with mapped_tasks,
|
1481 |
|
|
# choose the task with highest communication volume with others
|
1482 |
|
|
|
1483 |
|
|
foreach my $unmapped_task (@unmapped_tasks_set){
|
1484 |
|
|
|
1485 |
|
|
my $com_vol=0;
|
1486 |
|
|
foreach my $mapped_task (sort keys %map){
|
1487 |
|
|
$com_vol += $com_tasks{$unmapped_task}{$mapped_task};
|
1488 |
|
|
$com_vol += $com_tasks{$mapped_task}{$unmapped_task};
|
1489 |
|
|
}
|
1490 |
|
|
|
1491 |
|
|
my $overall_com_vol = 0;
|
1492 |
|
|
foreach my $p (@tasks){
|
1493 |
|
|
$overall_com_vol += $com_tasks{$unmapped_task}{$p};
|
1494 |
|
|
$overall_com_vol += $com_tasks{$p}{$unmapped_task};
|
1495 |
|
|
}
|
1496 |
|
|
|
1497 |
|
|
|
1498 |
|
|
if ($com_vol > $max_com){
|
1499 |
|
|
$max_com = $com_vol;
|
1500 |
|
|
$max_com_unmapped_task = $unmapped_task;
|
1501 |
|
|
$max_overall_com = $overall_com_vol;
|
1502 |
|
|
}
|
1503 |
|
|
elsif ($com_vol == $max_com){ # choose if it have higher comm volume
|
1504 |
|
|
if ($overall_com_vol > $max_overall_com){
|
1505 |
|
|
$max_com_unmapped_task = $unmapped_task;
|
1506 |
|
|
$max_overall_com = $overall_com_vol;
|
1507 |
|
|
}
|
1508 |
|
|
}
|
1509 |
|
|
}#foreach my $unmapped_task (@unmapped_tasks_set)
|
1510 |
|
|
|
1511 |
|
|
#--------- step 3.2, find the unallocated tile with lowest communication cost to/from allocated_tile_set
|
1512 |
|
|
my $min_com_cost;
|
1513 |
|
|
my $min_com_cost_tile_id;
|
1514 |
|
|
|
1515 |
|
|
|
1516 |
|
|
foreach my $unallocated_tile(@unallocated_tiles_set){
|
1517 |
|
|
my $com_cost = 0;
|
1518 |
|
|
my ($unallocated_x,$unallocated_y)=tile_id_to_loc($unallocated_tile);
|
1519 |
|
|
# scan all mapped tasks
|
1520 |
|
|
foreach my $mapped_task (sort keys %map){
|
1521 |
|
|
# get location of this mapped task
|
1522 |
|
|
my $mapped_tile=$map{$mapped_task};
|
1523 |
|
|
my ($allocated_x,$allocated_y)=tile_id_to_loc($mapped_tile);
|
1524 |
|
|
# mahattan distance of 2 tiles
|
1525 |
|
|
my $mah_distance=get_mah_distance($unallocated_x,$unallocated_y,$allocated_x,$allocated_y);
|
1526 |
|
|
|
1527 |
|
|
|
1528 |
|
|
$com_cost += $com_tasks{$max_com_unmapped_task}{$mapped_task} * $mah_distance;
|
1529 |
|
|
$com_cost += $com_tasks{$mapped_task}{$max_com_unmapped_task} * $mah_distance;
|
1530 |
|
|
|
1531 |
|
|
}
|
1532 |
|
|
$min_com_cost = $com_cost+1 if(!defined $min_com_cost);
|
1533 |
|
|
if ($com_cost < $min_com_cost){
|
1534 |
|
|
$min_com_cost = $com_cost;
|
1535 |
|
|
$min_com_cost_tile_id = $unallocated_tile;
|
1536 |
|
|
}
|
1537 |
|
|
}
|
1538 |
|
|
|
1539 |
|
|
# add max_com_unmapped_task to the mapped_tasks_set set
|
1540 |
|
|
#task_mapping[max_com_unmapped_task] = min_com_cost_tile_id;
|
1541 |
|
|
$map{$max_com_unmapped_task}=$min_com_cost_tile_id;
|
1542 |
|
|
@unmapped_tasks_set=remove_scolar_from_array(\@unmapped_tasks_set,$max_com_unmapped_task);
|
1543 |
|
|
@unallocated_tiles_set=remove_scolar_from_array(\@unallocated_tiles_set,$min_com_cost_tile_id);
|
1544 |
|
|
|
1545 |
|
|
}
|
1546 |
|
|
|
1547 |
|
|
|
1548 |
|
|
foreach my $mapped_task (sort keys %map){
|
1549 |
|
|
my $mapped_tile=$map{$mapped_task};
|
1550 |
|
|
#print "$mapped_tile=\$map{$mapped_task};\n";
|
1551 |
|
|
$self->object_add_attribute('MAP_TILE',"$mapped_task", $mapped_tile) if(defined $mapped_tile);
|
1552 |
|
|
$self->object_add_attribute('MAP_TASK',"$mapped_tile",$mapped_task) if(defined $mapped_tile);
|
1553 |
|
|
|
1554 |
|
|
}
|
1555 |
|
|
set_gui_status($self,"ref",1);
|
1556 |
|
|
|
1557 |
|
|
}
|
1558 |
|
|
|
1559 |
|
|
|
1560 |
|
|
|
1561 |
|
|
|
1562 |
|
|
|
1563 |
|
|
|
1564 |
|
|
|
1565 |
|
|
|
1566 |
|
|
sub worst_map_algorithm{
|
1567 |
|
|
|
1568 |
|
|
my $self=shift;
|
1569 |
|
|
|
1570 |
|
|
|
1571 |
43 |
alirezamon |
my $nx=$self->object_get_attribute('noc_param','T1');
|
1572 |
|
|
my $ny=$self->object_get_attribute('noc_param','T2');
|
1573 |
38 |
alirezamon |
my $nc= $nx * $ny;
|
1574 |
|
|
|
1575 |
|
|
my @tasks=get_all_tasks($self);
|
1576 |
|
|
my @tiles= get_tiles_name($self);
|
1577 |
|
|
|
1578 |
|
|
my $n_tasks = scalar @tasks;
|
1579 |
|
|
|
1580 |
|
|
|
1581 |
|
|
|
1582 |
|
|
|
1583 |
|
|
my @unmapped_tasks_set=@tasks; # unmapped set of tasks
|
1584 |
|
|
my @unallocated_tiles_set=@tiles; # tile ids which are not allocated yet
|
1585 |
|
|
|
1586 |
|
|
|
1587 |
|
|
|
1588 |
|
|
|
1589 |
|
|
#------ step 1: find the task with highest weighted communication volume
|
1590 |
|
|
# find the max of com_vol
|
1591 |
|
|
# consider all incoming and outgoing connections of each tasks
|
1592 |
|
|
|
1593 |
|
|
my %com_tasks= $self->get_communication_task();
|
1594 |
|
|
#print Data::Dumper->Dump([\%com_tasks],['mpsoc']);
|
1595 |
|
|
|
1596 |
|
|
my $max_com_task;
|
1597 |
|
|
my $max_com =0;
|
1598 |
|
|
foreach my $p (sort keys %com_tasks){
|
1599 |
|
|
#print "$p\n";
|
1600 |
|
|
if(defined $com_tasks{$p}{'total'}){
|
1601 |
|
|
if ($com_tasks{$p}{'total'} >$max_com){
|
1602 |
|
|
$max_com = $com_tasks{$p}{'total'};
|
1603 |
|
|
$max_com_task = $p;
|
1604 |
|
|
}}
|
1605 |
|
|
}
|
1606 |
|
|
|
1607 |
|
|
|
1608 |
|
|
|
1609 |
|
|
|
1610 |
|
|
#------ step 2: find the tile with min number of neighbors
|
1611 |
|
|
# normally, this tile is in the corners
|
1612 |
|
|
my $min_neighbors_tile_id = find_min_neighbor_tile($self);
|
1613 |
|
|
|
1614 |
|
|
|
1615 |
|
|
|
1616 |
|
|
|
1617 |
|
|
my %map=get_locked_map ($self);
|
1618 |
|
|
$self->remove_nlock_mapping();
|
1619 |
|
|
foreach my $mapped_task (sort keys %map){
|
1620 |
|
|
my $mapped_tile=$map{$mapped_task};
|
1621 |
|
|
@unmapped_tasks_set=remove_scolar_from_array(\@unmapped_tasks_set,$mapped_task);
|
1622 |
|
|
@unallocated_tiles_set=remove_scolar_from_array(\@unallocated_tiles_set,$mapped_tile);
|
1623 |
|
|
}
|
1624 |
|
|
|
1625 |
|
|
|
1626 |
|
|
|
1627 |
|
|
|
1628 |
|
|
# add this task with highest weighted communication volume to the mapped task set
|
1629 |
|
|
#push(@mapped_tasks_set,$max_com_task);
|
1630 |
|
|
#task_mapping[max_com_task] = max_neighbors_tile_id;
|
1631 |
|
|
|
1632 |
|
|
if(!defined $map{$max_com_task}){
|
1633 |
|
|
$map{$max_com_task}=$min_neighbors_tile_id;
|
1634 |
|
|
@unmapped_tasks_set=remove_scolar_from_array(\@unmapped_tasks_set,$max_com_task);
|
1635 |
|
|
@unallocated_tiles_set=remove_scolar_from_array(\@unallocated_tiles_set,$min_neighbors_tile_id);
|
1636 |
|
|
}
|
1637 |
|
|
|
1638 |
|
|
|
1639 |
|
|
|
1640 |
|
|
|
1641 |
|
|
|
1642 |
|
|
|
1643 |
|
|
|
1644 |
|
|
#------ step 3: map all unmapped tasks
|
1645 |
|
|
while(scalar @unmapped_tasks_set){
|
1646 |
|
|
$max_com =0;
|
1647 |
|
|
my $max_com_unmapped_task;
|
1648 |
|
|
my $max_overall_com=0;
|
1649 |
|
|
#--------- step 3.1:
|
1650 |
|
|
# find the unmapped task which communicates most with mapped_tasks_set
|
1651 |
|
|
# among many tasks which have the same communication volume with mapped_tasks,
|
1652 |
|
|
# choose the task with highest communication volume with others
|
1653 |
|
|
|
1654 |
|
|
foreach my $unmapped_task (@unmapped_tasks_set){
|
1655 |
|
|
|
1656 |
|
|
my $com_vol=0;
|
1657 |
|
|
foreach my $mapped_task (sort keys %map){
|
1658 |
|
|
$com_vol += $com_tasks{$unmapped_task}{$mapped_task};
|
1659 |
|
|
$com_vol += $com_tasks{$mapped_task}{$unmapped_task};
|
1660 |
|
|
}
|
1661 |
|
|
|
1662 |
|
|
my $overall_com_vol = 0;
|
1663 |
|
|
foreach my $p (@tasks){
|
1664 |
|
|
$overall_com_vol += $com_tasks{$unmapped_task}{$p};
|
1665 |
|
|
$overall_com_vol += $com_tasks{$p}{$unmapped_task};
|
1666 |
|
|
}
|
1667 |
|
|
|
1668 |
|
|
|
1669 |
|
|
if ($com_vol > $max_com){
|
1670 |
|
|
$max_com = $com_vol;
|
1671 |
|
|
$max_com_unmapped_task = $unmapped_task;
|
1672 |
|
|
$max_overall_com = $overall_com_vol;
|
1673 |
|
|
}
|
1674 |
|
|
elsif ($com_vol == $max_com){ # choose if it have higher comm volume
|
1675 |
|
|
if ($overall_com_vol > $max_overall_com){
|
1676 |
|
|
$max_com_unmapped_task = $unmapped_task;
|
1677 |
|
|
$max_overall_com = $overall_com_vol;
|
1678 |
|
|
}
|
1679 |
|
|
}
|
1680 |
|
|
}#foreach my $unmapped_task (@unmapped_tasks_set)
|
1681 |
|
|
|
1682 |
|
|
#--------- step 3.2, find the unallocated tile with highest communication cost to/from allocated_tile_set
|
1683 |
|
|
my $max_com_cost;
|
1684 |
|
|
my $max_com_cost_tile_id;
|
1685 |
|
|
|
1686 |
|
|
|
1687 |
|
|
foreach my $unallocated_tile(@unallocated_tiles_set){
|
1688 |
|
|
my $com_cost = 0;
|
1689 |
|
|
my ($unallocated_x,$unallocated_y)=tile_id_to_loc($unallocated_tile);
|
1690 |
|
|
# scan all mapped tasks
|
1691 |
|
|
foreach my $mapped_task (sort keys %map){
|
1692 |
|
|
# get location of this mapped task
|
1693 |
|
|
my $mapped_tile=$map{$mapped_task};
|
1694 |
|
|
my ($allocated_x,$allocated_y)=tile_id_to_loc($mapped_tile);
|
1695 |
|
|
# mahattan distance of 2 tiles
|
1696 |
|
|
my $mah_distance=get_mah_distance($unallocated_x,$unallocated_y,$allocated_x,$allocated_y);
|
1697 |
|
|
|
1698 |
|
|
|
1699 |
|
|
$com_cost += $com_tasks{$max_com_unmapped_task}{$mapped_task} * $mah_distance;
|
1700 |
|
|
$com_cost += $com_tasks{$mapped_task}{$max_com_unmapped_task} * $mah_distance;
|
1701 |
|
|
|
1702 |
|
|
}
|
1703 |
|
|
$max_com_cost = $com_cost-1 if(!defined $max_com_cost);
|
1704 |
|
|
if ($com_cost > $max_com_cost){
|
1705 |
|
|
$max_com_cost = $com_cost;
|
1706 |
|
|
$max_com_cost_tile_id = $unallocated_tile;
|
1707 |
|
|
}
|
1708 |
|
|
}
|
1709 |
|
|
|
1710 |
|
|
# add max_com_unmapped_task to the mapped_tasks_set set
|
1711 |
|
|
#task_mapping[max_com_unmapped_task] = min_com_cost_tile_id;
|
1712 |
|
|
$map{$max_com_unmapped_task}=$max_com_cost_tile_id;
|
1713 |
|
|
@unmapped_tasks_set=remove_scolar_from_array(\@unmapped_tasks_set,$max_com_unmapped_task);
|
1714 |
|
|
@unallocated_tiles_set=remove_scolar_from_array(\@unallocated_tiles_set,$max_com_cost_tile_id);
|
1715 |
|
|
|
1716 |
|
|
}
|
1717 |
|
|
|
1718 |
|
|
|
1719 |
|
|
foreach my $mapped_task (sort keys %map){
|
1720 |
|
|
my $mapped_tile=$map{$mapped_task};
|
1721 |
|
|
#print "$mapped_tile=\$map{$mapped_task};\n";
|
1722 |
|
|
$self->object_add_attribute('MAP_TILE',"$mapped_task", $mapped_tile) if(defined $mapped_tile);
|
1723 |
|
|
$self->object_add_attribute('MAP_TASK',"$mapped_tile",$mapped_task) if(defined $mapped_tile);
|
1724 |
|
|
|
1725 |
|
|
}
|
1726 |
|
|
set_gui_status($self,"ref",1);
|
1727 |
|
|
|
1728 |
|
|
}
|
1729 |
|
|
|
1730 |
|
|
|
1731 |
|
|
|
1732 |
|
|
|
1733 |
|
|
|
1734 |
|
|
|
1735 |
|
|
|
1736 |
|
|
|
1737 |
|
|
|
1738 |
|
|
|
1739 |
|
|
|
1740 |
|
|
|
1741 |
|
|
|
1742 |
|
|
|
1743 |
|
|
sub get_task_assigned_to_tile {
|
1744 |
|
|
my ($self,$x,$y)=@_;
|
1745 |
|
|
my $p;
|
1746 |
|
|
$p= $self->object_get_attribute("MAP_TASK","tile($x)");
|
1747 |
|
|
return $p if (defined $p);
|
1748 |
|
|
$p= $self->object_get_attribute("MAP_TASK","tile(${x}_$y)");
|
1749 |
|
|
return $p;
|
1750 |
|
|
}
|
1751 |
|
|
|
1752 |
|
|
|
1753 |
|
|
|
1754 |
|
|
sub get_assigned_tiles{
|
1755 |
|
|
my $self=shift;
|
1756 |
|
|
my @tiles = sort keys %{$self->{'MAP_TASK'}};
|
1757 |
|
|
return @tiles;
|
1758 |
|
|
|
1759 |
|
|
}
|
1760 |
|
|
|
1761 |
|
|
sub map_task {
|
1762 |
|
|
my ($self,$task,$tile)=@_;
|
1763 |
|
|
my $oldtile= $self->{"MAP_TILE"}{$task};
|
1764 |
|
|
if($tile eq "-"){
|
1765 |
|
|
delete $self->{"MAP_TILE"}{$task};
|
1766 |
|
|
}else{
|
1767 |
|
|
$self->{"MAP_TILE"}{$task}= $tile;
|
1768 |
|
|
$self->{'MAP_TASK'}{$tile}= $task;
|
1769 |
|
|
}
|
1770 |
|
|
delete $self->{"MAP_TASK"}{$oldtile} if(defined $oldtile);
|
1771 |
|
|
}
|
1772 |
|
|
|
1773 |
|
|
sub remove_selected_traces{
|
1774 |
|
|
my $self=shift;
|
1775 |
|
|
my @traces= $self->get_trace_list();
|
1776 |
|
|
foreach my $p (@traces) {
|
1777 |
|
|
my $select=$self->object_get_attribute("trace_$p",'selected', 0);
|
1778 |
|
|
|
1779 |
|
|
if($select){
|
1780 |
|
|
$self->remove_trace("$p");
|
1781 |
|
|
|
1782 |
|
|
}
|
1783 |
|
|
}
|
1784 |
|
|
set_gui_status($self,"ref",1);
|
1785 |
|
|
}
|
1786 |
|
|
|
1787 |
|
|
|
1788 |
|
|
|
1789 |
|
|
sub auto_generate_injtratio{
|
1790 |
|
|
my $self=shift;
|
1791 |
|
|
my %com_tasks= $self->get_communication_task();
|
1792 |
|
|
my @traces= $self->get_trace_list();
|
1793 |
|
|
foreach my $p (@traces) {
|
1794 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name)=$self->get_trace($p);
|
1795 |
|
|
my $max= $com_tasks{$file_id}{'maxsent'};
|
1796 |
|
|
my $sent= $com_tasks{$src}{'sent'};
|
1797 |
|
|
my $ratio = ($sent*100)/$max;
|
1798 |
|
|
$self->object_add_attribute("trace_$p",'injct_rate',$ratio);
|
1799 |
|
|
|
1800 |
|
|
my $minpck = $self->object_get_attribute("trace_$p",'min_pck_size');
|
1801 |
|
|
my $maxpck = $self->object_get_attribute("trace_$p",'max_pck_size' );
|
1802 |
|
|
my $avg_pck_size =($minpck+ $maxpck)/2;
|
1803 |
|
|
my $pck_num = ($Mbytes*8) /($avg_pck_size*64);
|
1804 |
|
|
|
1805 |
|
|
|
1806 |
|
|
my $burst =$pck_num/ $com_tasks{$src}{'min_pck_num'} ;
|
1807 |
|
|
$self->object_add_attribute("trace_$p",'burst_size',ceil($burst));
|
1808 |
|
|
|
1809 |
|
|
#my $burst_size = gen_spin_object ($self,"trace_$p",'burst_size',"1,1024,1", 1,undef,undef);
|
1810 |
|
|
|
1811 |
|
|
|
1812 |
|
|
|
1813 |
|
|
}
|
1814 |
|
|
set_gui_status($self,"ref",1);
|
1815 |
|
|
|
1816 |
|
|
|
1817 |
|
|
}
|
1818 |
|
|
|