8 for($i = @$tableau ; --$i; ) {
11 @$tableau[$i,$j] = @$tableau[$j,$i];
19 open(INPUT,"$filename");
20 while(defined($line=<INPUT>)) {
22 if($line=~/host id/) {
23 $line=~ s/.*host id="//;
25 push @host_list,$line;
32 sub generate_random_deployment{
33 my($host_list,$nflows,$filename)=@_;
35 my($nhost) = scalar(@$host_list);
38 $nflows< $nhost*$nhost-$nhost or die "Too much flows! I can't do it\n";
40 open(OUTPUT,"> $filename");
41 while(scalar(keys(%pairs))<$nflows) {
42 my($src)=int(rand(scalar(@$host_list)));
43 my($dst)=int(rand(scalar(@$host_list)));
45 if($src!=$dst && !defined($pairs{"$$host_list[$src] $$host_list[$dst]"})) {
46 $pairs{"$$host_list[$src] $$host_list[$dst]"}=1;
47 $taken{"$$host_list[$src]"}=1;
48 $taken{"$$host_list[$dst]"}=1;
49 # && !$taken{$$host_list[$src]} && !$taken{$$host_list[$dst]}
58 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
59 <platform version="2">
62 foreach $p (keys %pairs) {
63 my($src,$dst)=split(/ /,$p);
64 print OUTPUT " <process host='$src' function='master'>\n";
65 print OUTPUT " <argument value='10000000'/>\n";
66 print OUTPUT " <argument value='$dst'/>\n";
67 print OUTPUT " <argument value='$count'/>\n";
68 print OUTPUT " </process>\n";
69 print OUTPUT " <process host='$dst' function='slave'>\n";
70 print OUTPUT " <argument value='$count'/>\n";
71 print OUTPUT " </process>\n";
82 sub generate_random_deployment2{
83 my($host_list,$nflows,$filename)=@_;
85 my($nhost) = scalar(@$host_list);
89 $nflows< $nhost/2 or die "Too much flows! I can't do it\n";
91 open(OUTPUT,"> $filename");
92 foreach (0..$nflows-1) {
93 my($src)=shift(@$host_list);
94 my($dst)=shift(@$host_list);
96 $pairs{"$src $dst"}=1;
103 <?xml version='1.0'?>
104 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
105 <platform version="2">
108 foreach $p (keys %pairs) {
109 my($src,$dst)=split(/ /,$p);
110 print OUTPUT " <process host='$src' function='master'>\n";
111 print OUTPUT " <argument value='10000000'/>\n";
112 print OUTPUT " <argument value='$dst'/>\n";
113 print OUTPUT " <argument value='$count'/>\n";
114 print OUTPUT " </process>\n";
115 print OUTPUT " <process host='$dst' function='slave'>\n";
116 print OUTPUT " <argument value='$count'/>\n";
117 print OUTPUT " </process>\n";
128 my($nodes,$edges,$interferences,$host_list,$count_interferences);
130 $#ARGV>=1 or die "Need a xml platform file and a number of flows!";
131 my($filename)=$ARGV[0];
132 my($nflows)=$ARGV[1];
133 $filename =~ s/\.xml$//g;
134 $filename =~ s/-p$//g;
136 $host_list = read_file $ARGV[0];
137 generate_random_deployment2($host_list,$nflows,"$filename-d.xml");