Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
A few more tiers file and a convenient perl script for the alnem project. I
[simgrid.git] / tools / platform_generation / tiers_simgrid_darina.pl
1 #!/usr/bin/perl -w
2 use strict;
3
4 use AlvinMisc;
5 use graph_viz;
6 use graph_tbx;
7 use tiers;
8
9 my (%machine);
10 $machine{"canaria.ens-lyon.fr"}{"CPU_clock"} = "347.669";
11 $machine{"canaria.ens-lyon.fr"}{"CPU_Mflops"} = "34.333";
12 $machine{"canaria.ens-lyon.fr"}{"CPU_model"} = "Pentium II (Deschutes)";
13 $machine{"canaria.ens-lyon.fr"}{"CPU_num"} = "2";
14 $machine{"canaria.ens-lyon.fr"}{"Machine_type"} = "i686";
15 $machine{"canaria.ens-lyon.fr"}{"OS_version"} = "Linux 2.2.19pre17";
16
17 $machine{"moby.ens-lyon.fr"}{"CPU_clock"} = "996.698";
18 $machine{"moby.ens-lyon.fr"}{"CPU_Mflops"} = "114.444";
19 $machine{"moby.ens-lyon.fr"}{"CPU_model"} = "Intel(R) Pentium(R) III Mobile CPU 1000MHz";
20 $machine{"moby.ens-lyon.fr"}{"CPU_num"} = "1";
21 $machine{"moby.ens-lyon.fr"}{"Machine_type"} = "i686";
22 $machine{"moby.ens-lyon.fr"}{"OS_version"} = "Linux 2.4.18-accelerated";
23
24 $machine{"popc0.ens-lyon.fr"}{"CPU_clock"} = "199.095";
25 $machine{"popc0.ens-lyon.fr"}{"CPU_Mflops"} = "22.151";
26 $machine{"popc0.ens-lyon.fr"}{"CPU_model"} = "Pentium Pro";
27 $machine{"popc0.ens-lyon.fr"}{"CPU_num"} = "1";
28 $machine{"popc0.ens-lyon.fr"}{"Machine_type"} = "i686";
29 $machine{"popc0.ens-lyon.fr"}{"OS_version"} = "Linux 2.2.19";
30
31 $machine{"sci0.ens-lyon.fr"}{"CPU_clock"} = "451.032446";
32 $machine{"sci0.ens-lyon.fr"}{"CPU_Mflops"} = "48.492";
33 $machine{"sci0.ens-lyon.fr"}{"CPU_model"} = "Pentium II (Deschutes)";
34 $machine{"sci0.ens-lyon.fr"}{"CPU_num"} = "2";
35 $machine{"sci0.ens-lyon.fr"}{"Machine_type"} = "i686";
36 $machine{"sci0.ens-lyon.fr"}{"OS_version"} = "Linux 2.2.13";
37
38 $machine{"lancelot.u-strasbg.fr"}{"OS_version"} = "Linux 2.2.17-21mdk";
39 $machine{"lancelot.u-strasbg.fr"}{"CPU_clock"} = "400.916";
40 $machine{"lancelot.u-strasbg.fr"}{"CPU_model"} = "Celeron (Mendocino)";
41 $machine{"lancelot.u-strasbg.fr"}{"CPU_Mflops"} = "42.917000000000002";
42 $machine{"lancelot.u-strasbg.fr"}{"Machine_type"} = "i686";
43 $machine{"lancelot.u-strasbg.fr"}{"CPU_num"} = "1";
44
45 $machine{"caseb.u-strasbg.fr"}{"OS_version"} = "Linux 2.4.8-26mdk";
46 $machine{"caseb.u-strasbg.fr"}{"CPU_clock"} = "1399.763";
47 $machine{"caseb.u-strasbg.fr"}{"CPU_model"} = "AMD Athlon(tm) 4 Processor";
48 $machine{"caseb.u-strasbg.fr"}{"CPU_Mflops"} = "137.333";
49 $machine{"caseb.u-strasbg.fr"}{"Machine_type"} = "i686";
50 $machine{"caseb.u-strasbg.fr"}{"CPU_num"} = "1";
51
52 $machine{"pellinore.u-strasbg.fr"}{"OS_version"} = "Linux 2.4.18-6mdksmp";
53 $machine{"pellinore.u-strasbg.fr"}{"CPU_clock"} = "802.922";
54 $machine{"pellinore.u-strasbg.fr"}{"CPU_model"} = "Pentium III (Coppermine)";
55 $machine{"pellinore.u-strasbg.fr"}{"CPU_Mflops"} = "68.667000000000002";
56 $machine{"pellinore.u-strasbg.fr"}{"Machine_type"} = "i686";
57 $machine{"pellinore.u-strasbg.fr"}{"CPU_num"} = "2";
58
59 $machine{"dinadan.u-strasbg.fr"}{"OS_version"} = "Linux 2.4.19-686";
60 $machine{"dinadan.u-strasbg.fr"}{"CPU_clock"} = "933.375";
61 $machine{"dinadan.u-strasbg.fr"}{"CPU_model"} = "Pentium III (Coppermine)";
62 $machine{"dinadan.u-strasbg.fr"}{"CPU_Mflops"} = "85.832999999999998";
63 $machine{"dinadan.u-strasbg.fr"}{"Machine_type"} = "i686";
64 $machine{"dinadan.u-strasbg.fr"}{"CPU_num"} = "1";
65
66 $machine{"darjeeling.u-strasbg.fr"}{"OS_version"} = "Linux 2.4.18-5";
67 $machine{"darjeeling.u-strasbg.fr"}{"CPU_clock"} = "1793.371";
68 $machine{"darjeeling.u-strasbg.fr"}{"CPU_model"} = "Intel(R) Pentium(R) 4 CPU 1.80GHz";
69 $machine{"darjeeling.u-strasbg.fr"}{"CPU_Mflops"} = "98.094999999999999";
70 $machine{"darjeeling.u-strasbg.fr"}{"Machine_type"} = "i686";
71 $machine{"darjeeling.u-strasbg.fr"}{"CPU_num"} = "1";
72
73 $machine{"gauvain.u-strasbg.fr"}{"OS_version"} = "Linux 2.4.17";
74 $machine{"gauvain.u-strasbg.fr"}{"CPU_clock"} = "1050.034";
75 $machine{"gauvain.u-strasbg.fr"}{"CPU_model"} = "AMD Athlon(tm) Processor";
76 $machine{"gauvain.u-strasbg.fr"}{"CPU_Mflops"} = "114.444";
77 $machine{"gauvain.u-strasbg.fr"}{"Machine_type"} = "i686";
78 $machine{"gauvain.u-strasbg.fr"}{"CPU_num"} = "1";
79
80 $machine{"sekhmet.u-strasbg.fr"}{"OS_version"} = "Linux 2.4.18-k7";
81 $machine{"sekhmet.u-strasbg.fr"}{"CPU_clock"} = "1399.803";
82 $machine{"sekhmet.u-strasbg.fr"}{"CPU_model"} = "AMD Athlon(tm) 4 Processor";
83 $machine{"sekhmet.u-strasbg.fr"}{"CPU_Mflops"} = "171.667";
84 $machine{"sekhmet.u-strasbg.fr"}{"Machine_type"} = "i686";
85 $machine{"sekhmet.u-strasbg.fr"}{"CPU_num"} = "1";
86
87 $machine{"shaitan.u-strasbg.fr"}{"OS_version"} = "Linux 2.4.18-6mdk";
88 $machine{"shaitan.u-strasbg.fr"}{"CPU_clock"} = "800.030";
89 $machine{"shaitan.u-strasbg.fr"}{"CPU_model"} = "Pentium III (Coppermine)";
90 $machine{"shaitan.u-strasbg.fr"}{"CPU_Mflops"} = "76.296000000000006";
91 $machine{"shaitan.u-strasbg.fr"}{"Machine_type"} = "i686";
92 $machine{"shaitan.u-strasbg.fr"}{"CPU_num"} = "1";
93
94 my (%network);
95 #0.587500,0.655,0.681
96
97 $network{"bw"}{10} = [ [274285,0.514433], [330233,0.059904],
98                 [949460,0.136931], [1063823,0.131098],
99                 [2041829,7.413073] ];
100
101 $network{"bw"}{100} = [ [64121,35.076518], [65264,0.270544],
102                 [67418,0.156056], [80797,0.479780], [82517,6.932556],
103                 [92951,0.189980], [94763,0.370788],
104                 [123015,35.083019], [171318,295.890617],
105                 [223570,0.278066], [274285,0.514433],
106                 [330233,0.059904] ];
107
108 $network{"bw"}{1000} = [ [937,53.930106], [2013,4.455826],
109                 [2022,5.704550], [2025,5.652577], [2073,4.460898],
110                 [2179,5.922616], [2195,4.669142], [2321,4.522355],
111                 [2327,4.477270], [2427,4.062241], [2539,4.583831],
112                 [3777,5.161451], [4448,3.101854], [4629,5.473705],
113                 [4840,87.981858], [5773,0.006406], [6150,8.762440],
114                 [7413,0.601375], [7837,0.424305], [7867,2.885584],
115                 [7924,1.742977], [8394,9.647856], [9015,0.287840],
116                 [9612,0.468130], [9842,1.502106], [10069,1.340162],
117                 [10255,6.104672], [10609,1.402769], [11014,0.449267],
118                 [11724,0.863872], [11741,0.869727], [11753,1.114548],
119                 [12100,1.200141], [12122,0.844683], [12513,0.788956],
120                 [13022,0.278175], [14341,7.877863], [14864,0.820952],
121                 [15084,0.950938], [15111,1.081287], [15141,0.162735],
122                 [15449,0.951830], [15797,0.380044], [15868,0.848211],
123                 [17433,0.320114], [17819,0.907120], [17906,1.043314],
124                 [18382,1.087968], [18788,0.259761], [18944,9.547561],
125                 [20667,0.410463], [20864,0.637001], [22546,0.247605],
126                 [24227,0.677908], [24547,0.040300], [25404,0.472524],
127                 [26205,0.658142], [26382,0.595883], [26970,0.666676],
128                 [27441,0.536941], [28416,3.870785], [29714,3.866813],
129                 [31020,0.863123], [31452,1.913591], [31964,0.678645],
130                 [33067,9.693542], [33378,0.728103], [34162,0.672289],
131                 [34363,0.539000], [35178,0.677601], [35333,0.019773],
132                 [35689,0.106949], [35881,0.126045], [37202,0.705967],
133                 [37438,0.848712], [38536,0.117352], [38723,0.751810],
134                 [39826,7.164412], [41518,0.630529], [41827,0.039417],
135                 [42392,0.520693], [43729,0.272268], [44597,0.227430],
136                 [45776,0.789218], [46068,4.760145], [46531,0.164758],
137                 [52408,0.522878], [54216,0.533340], [57678,1.461517],
138                 [60272,0.125428] ];
139
140 sub assign_host_speed{
141     my($nodes,$edges) = @_;
142
143     my($u);
144
145     my(@label_list) = keys %machine;
146     foreach $u (keys %$nodes) {
147         my($mach_type_nb) = scalar(@label_list);
148         my($mach_type) = int rand($mach_type_nb);
149         $$nodes{$u}{Mflops} = $machine{$label_list[$mach_type]}{CPU_Mflops};
150     }
151 }
152
153 sub assign_host_names{
154     my($nodes,$edges) = @_;
155
156     my(@name_list) = qw(Abbott Adoncourt Aikin Alain Alfred Amadeus
157                         Angie Anjou Anne_Marie Apple April Archibald
158                         Aubertin Auclair Audy AutoCAD Barry BASIC
159                         Beaudoin Beaulac Bellemarre Bellevue
160                         Bell_Northern Benoit Bentz Bernard Bescherelle
161                         Blais Boily Boivin Borduas Boston Boucherville
162                         Bourassa Bousquet Boyer Brian Brosseau Brown
163                         Browne Cadieux Cambridge Canada Carole
164                         Casavant Chambly Charles Charron Christian
165                         Claude Cloutier Colin Comeau Corp Coulombe
166                         Cousineau Croteau Daniel Decelles Denis Denise
167                         Desjardins Dick Dionne Disney Dodge Domey
168                         Dominique Doris Dorval Doyon Drouin Dumoulin
169                         EDF Emacs Ethernet Europe Fafard Fernand
170                         Fernet Flamand Florient Foisy Forget Fourier
171                         FrameMaker France Francine Frank Fraser
172                         Freedman Gagnon Gaston Gatien Gaudreault
173                         Gauthier Gavrel Gendron Gentilly Geoff
174                         Geoffray George Georges Gilles Ginette Girard
175                         Goodwin Gordon Gosselin Gratton Greg Gregory
176                         Guy Harry Harwell Hayward Hollerbach Horne
177                         Houde Hubert Hz Inc Inmos Intel Interleaf
178                         Internet iRMX iRMXII iRMXIII Isabelle ISPELL
179                         Jackson Jacobsen Jacquelin Jacques
180                         Jacques_Cartier Jamie Jean Jean_Claude
181                         Jean_Louis Jean_Maurice Jeannine Jean_Paul
182                         Jean_Pierre Jean_Yves Jill Jobin Jocelyne John
183                         Jones Joynes Jude Julian Julien Juneau Jupiter
184                         Kansas Kent Khan King Kuenning kV Lachapelle
185                         Laflamme Lafontaine Lamothe Lapointe Laroche
186                         LaSalle LaTeX Laugier Laurendeau Laval Lavoie
187                         Leblanc Lecavalier Leclerc Lepage Lessard
188                         Letarte Linda LISP Longueuil Louis Louise
189                         Louis_Marc Ltd Lucie Mahoney Maltais Manseau
190                         Marc Marcel Marcoux Marie Marielle Mark
191                         Marseille Martin Masson Mathematica Matlab
192                         McGee McGill Messier METAFONT Michel Mike
193                         Minneapolis Mireille Mongenot Monique
194                         Mont_Tremblant Morin Morissette Moshe Mulhouse
195                         mW Nagle Nelligan Nestor Nicole OHara Olivier
196                         Ontario Ottawa Ouellet Owen Ozias Papineau
197                         Paul Pellan Pelletier PERL Phaneuf Phil Pierre
198                         Pierrefonds Plante Pointe_Claire PostScript
199                         Poussart Pronovost Provost Raymond Re README
200                         Renato Ricard Richard Ringuet Riopelle Rioux
201                         Roberge Robert Rochefort Roger Romano Ronald
202                         Roy Rubin Sacramento Saint_Amand Sainte_Foy
203                         Sainte_Julie Saint_Marc_sur_Richelieu Seattle
204                         Shawinigan Sherbrooke Sirois Smith Sorel Soucy
205                         SPARC SPARCs SPICE St_Antoine St_Bruno
206                         Ste_Anne Steele Ste_Julie Stephen St_Jacques
207                         St_Jean St_Paul Strasbourg Sun SunOS Suzanne
208                         Tanguay Tessier TeX Texas Thibault Thierry
209                         Todd Tokyo Toronto Toulouse Tremblay Turcotte
210                         Uintas UniPress Unix UNIX Utah Vancouver
211                         Varennes Verville Victoria Victoriaville Viger
212                         Vincent VxWorks Wilfrid William Williams
213                         Wright Yolande Yvan Yves Zawinski);
214
215     AlvinMisc::melange(\@name_list);
216
217     my($u);
218     foreach $u (keys %$nodes) {
219         if($$nodes{$u}{host}==1) {
220             $$nodes{$u}{name} = shift @name_list;
221         }
222     }
223 }
224
225 sub assign_link_speed{
226     my($nodes,$edges) = @_;
227
228     my($e);
229
230     foreach $e (keys %$edges) {
231         my($bw) = $$edges{$e}{bw};
232
233         my(@choice) = @{$network{"bw"}{$bw}};
234         my($choice_nb) = scalar(@choice);
235         my($chosen_link) = $choice[(int rand($choice_nb))];
236         $$edges{$e}{bw} = $$chosen_link[0]/8000;
237         $$edges{$e}{delay} = $$chosen_link[1];
238     }
239 }
240
241
242 sub affiche_graph{
243     my($nodes,$edges,$filename) = @_;
244     my($u,$v,$w,$e);
245     
246     my(%node_to_export);
247     my(%edge_to_export);
248
249     my(@host_list,@routeur_list,@link_list);
250
251     foreach $u (keys %{$nodes}) {
252         if (!((defined($$nodes{$u}{host}))&&($$nodes{$u}{host}==1))) { next; }
253         if (!((defined($$nodes{$u}{Mflops}))&&($$nodes{$u}{host}==1))) { 
254             die "Lacking Mflops for $u\n"; 
255         }
256         push @host_list,$u;
257         $node_to_export{$u}=$#host_list;
258     }
259
260     foreach $u (@host_list){
261         foreach $v (@host_list){
262             if($u ne $v) {
263                 $w = $u;
264                 if(!defined($node_to_export{$w})) {
265                     push @routeur_list,$w;
266                     $node_to_export{$w}=$#host_list + $#routeur_list + 1;
267                 }
268                 while ($w ne $v) {
269                     my($next) = $$nodes{$w}{shortest_route}{$v};
270                     my($e) = $$nodes{$w}{out}{$next};
271                     if(!defined($edge_to_export{$e})) {
272                         push @link_list,$e;
273                         $edge_to_export{$e}=$#link_list;
274                     }
275                     $w = $next;
276                     if(!defined($node_to_export{$w})) {
277                         push @routeur_list,$w;
278                         $node_to_export{$w}=$#host_list + $#routeur_list + 1;
279                     }
280                 }
281             }
282         }
283     }
284
285     open VIZ, "> $filename.dot";
286     print VIZ "graph essai  { \n";
287     print VIZ "  graph [overlap=scale]\n";
288     #print VIZ "  graph [overlap=false spline=true]\n";
289     print VIZ "  node [shape=box, style=filled]\n";
290     print VIZ "  node [width=.3, height=.3, style=filled]\n";
291
292     foreach $u (@host_list) {
293         print VIZ "  \"$u\" [label=\"$$nodes{$u}{name}\",color=red,shape=box];\n";
294     }
295     foreach $u (@routeur_list) {
296             print VIZ "  \"$u\" [label=\"$$nodes{$u}{name}\",fontsize=2,color=skyblue,shape=circle];\n";
297     }
298     foreach $e (@link_list) {
299         my($src)=$$edges{$e}{src};
300         my($dst)=$$edges{$e}{dst};
301         (defined($$edges{$e}{bw})) or die "Lacking bw for $u\n"; 
302         (defined($$edges{$e}{delay})) or die "Lacking bw for $u\n"; 
303         print VIZ "  \"$src\" -- \"$dst\";\n";
304     }
305
306     print VIZ "}\n";
307     close VIZ;
308
309     system("neato -Tps $filename.dot  > $filename.ps");
310 #    system("gv $filename.ps");
311     system("pstoedit -f fig $filename.ps $filename.fig 2>/dev/null");
312 #    system("xfig -startg 0 $filename.fig ");
313 }
314
315 sub graphxml_export {
316     my($nodes,$edges,$filename) = @_;
317     my($u,$v,$w,$e);
318     my(@host_list)=();
319     
320     open OUTPUT, "> $filename";
321
322     print OUTPUT "<?xml version='1.0'?>\n";
323     print OUTPUT "<!DOCTYPE graph SYSTEM \"graphxml.dtd\">\n";
324     print OUTPUT "<graph isDirected=\"false\">\n";
325
326     foreach $u (keys %{$nodes}) {
327         if (!((defined($$nodes{$u}{host}))&&($$nodes{$u}{host}==1))) { next; }
328         if (!((defined($$nodes{$u}{Mflops}))&&($$nodes{$u}{host}==1))) { 
329             die "Lacking Mflops for $u\n"; 
330         }
331         print OUTPUT "  <node name=\"$$nodes{$u}{name}\" label=\"$$nodes{$u}{name}\" data=\"$$nodes{$u}{Mflops}\" position_x=\"$$nodes{$u}{X}\" position_y=\"$$nodes{$u}{Y}\"/>\n";
332         push @host_list,$u;
333     }
334     print OUTPUT "</graph>\n";
335     close(OUTPUT);
336 }
337
338 sub get_layout{
339     my($nodes,$edges,$filename) = @_;
340
341     system("neato -Tfig $filename.dot  > $filename.fig");
342
343     my($u);
344     foreach $u (sort (keys %$nodes)){
345         if (((defined($$nodes{$u}{Mflops}))&&($$nodes{$u}{host}==1))) { 
346             my($val_u) = `grep ' $$nodes{$u}{name}\\\\001' $filename.fig`;
347             if(defined($val_u)) {
348                 my(@tab) = split(/\s+/,$val_u);
349                 my($x1) = $tab[11];
350                 my($y1) = $tab[12];
351                 $$nodes{$u}{X}=$x1;
352                 $$nodes{$u}{Y}=$y1;
353             }
354         }
355     }
356 }
357
358 sub main {
359     my($nodes,$edges,$interferences,$host_list,$count_interferences);
360
361     $#ARGV>=0 or die "Need a tiers file!";
362     my($filename)=$ARGV[0];
363     $filename =~ s/\.[^\.]*$//g;
364     if(1) {
365         print STDERR "Reading graph\n";
366         ($nodes,$edges) = parse_tiers_file $ARGV[0];
367
368         print STDERR "Generating host list\n";
369         $host_list = generate_host_list($nodes,$edges,.7);
370         assign_host_speed($nodes,$edges);
371         assign_link_speed($nodes,$edges);
372         assign_host_names($nodes,$edges);
373         print STDERR "Computing Shortest Paths \n";
374         shortest_paths($nodes,$edges);
375         print STDERR "Exporting to surfxml\n";
376         G_surfxml_export($nodes,$edges,"$filename.xml");
377         print STDERR "Calling graphviz\n";
378         affiche_graph($nodes,$edges,"$filename");
379         print STDERR "Getting layout\n";
380         get_layout($nodes,$edges,"$filename");
381         print STDERR "Exporting layout to graphxml\n";
382         graphxml_export($nodes,$edges,"$filename.graphxml");
383     }
384 }
385
386 main;