3 # Copyright (c) 2009, 2011, 2014. The SimGrid Team.
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the license (GNU LGPL) which comes with this package.
15 for($i = @$tableau ; --$i; ) {
18 @$tableau[$i,$j] = @$tableau[$j,$i];
26 open(INPUT,"$filename");
27 while(defined($line=<INPUT>)) {
29 if($line=~/host id/) {
30 $line=~ s/.*host id="//;
32 push @host_list,$line;
39 sub generate_random_deployment{
40 my($host_list,$nflows,$filename)=@_;
42 my($nhost) = scalar(@$host_list);
45 $nflows< $nhost*$nhost-$nhost or die "Too much flows! I can't do it\n";
47 open(OUTPUT,"> $filename");
48 while(scalar(keys(%pairs))<$nflows) {
49 my($src)=int(rand(scalar(@$host_list)));
50 my($dst)=int(rand(scalar(@$host_list)));
52 if($src!=$dst && !defined($pairs{"$$host_list[$src] $$host_list[$dst]"})) {
53 $pairs{"$$host_list[$src] $$host_list[$dst]"}=1;
54 $taken{"$$host_list[$src]"}=1;
55 $taken{"$$host_list[$dst]"}=1;
56 # && !$taken{$$host_list[$src]} && !$taken{$$host_list[$dst]}
65 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
66 <platform version="2">
69 foreach $p (keys %pairs) {
70 my($src,$dst)=split(/ /,$p);
71 print OUTPUT " <process host='$src' function='master'>\n";
72 print OUTPUT " <argument value='10000000'/>\n";
73 print OUTPUT " <argument value='$dst'/>\n";
74 print OUTPUT " <argument value='$count'/>\n";
75 print OUTPUT " </process>\n";
76 print OUTPUT " <process host='$dst' function='slave'>\n";
77 print OUTPUT " <argument value='$count'/>\n";
78 print OUTPUT " </process>\n";
89 sub generate_random_deployment2{
90 my($host_list,$nflows,$filename)=@_;
92 my($nhost) = scalar(@$host_list);
96 $nflows< $nhost/2 or die "Too much flows! I can't do it\n";
98 open(OUTPUT,"> $filename");
99 foreach (0..$nflows-1) {
100 my($src)=shift(@$host_list);
101 my($dst)=shift(@$host_list);
103 $pairs{"$src $dst"}=1;
110 <?xml version='1.0'?>
111 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
112 <platform version="2">
115 foreach $p (keys %pairs) {
116 my($src,$dst)=split(/ /,$p);
117 print OUTPUT " <process host='$src' function='master'>\n";
118 print OUTPUT " <argument value='10000000'/>\n";
119 print OUTPUT " <argument value='$dst'/>\n";
120 print OUTPUT " <argument value='$count'/>\n";
121 print OUTPUT " </process>\n";
122 print OUTPUT " <process host='$dst' function='slave'>\n";
123 print OUTPUT " <argument value='$count'/>\n";
124 print OUTPUT " </process>\n";
135 my($nodes,$edges,$interferences,$host_list,$count_interferences);
137 $#ARGV>=1 or die "Need a xml platform file and a number of flows!";
138 my($filename)=$ARGV[0];
139 my($nflows)=$ARGV[1];
140 $filename =~ s/\.xml$//g;
141 $filename =~ s/-p$//g;
143 $host_list = read_file $ARGV[0];
144 generate_random_deployment2($host_list,$nflows,"$filename-d.xml");