X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/94446121333b0ae1ae6eea3c32124fd4b3df62f2..d44ed07cd1cb3f4fceb9dc45e1161723f0fdc9a0:/examples/gras/all2all/make_deployment.pl diff --git a/examples/gras/all2all/make_deployment.pl b/examples/gras/all2all/make_deployment.pl index 1e4bf687a5..3220e86353 100755 --- a/examples/gras/all2all/make_deployment.pl +++ b/examples/gras/all2all/make_deployment.pl @@ -21,16 +21,16 @@ EOH } my $input = shift @ARGV || usage(); -my $nb_hosts = shift @ARGV || usage(); my $size_msg = shift @ARGV || usage(); -my $source = shift || ""; +my $source = shift @ARGV || ""; +my $nb_hosts = shift @ARGV || 0; my @host; open IN,$input || die "Cannot open $input: $!\n"; while () { - next unless /) { die "No host found in $input. Is it really a SimGrid platform file?\nCheck that you didn't pass a deployment file, for example.\n" unless (scalar @host); +if (! $nb_hosts) { + $nb_hosts = scalar @host; +} + + # # Build the receiver string -my $receivers; # strings containing sender argument describing all receivers. +my @receivers; # strings containing sender argument describing all receivers. my $it_host=0; # iterator my $it_port=4000; # iterator, in case we have so much processes to add that we must change it for (my $i=0; $i<$nb_hosts; $i++) { - $receivers .= " \n"; + push (@receivers, "$host[$it_host]:$it_port"); $it_host ++; if ($it_host == scalar @host) { $it_host=0; $it_port++; } } -$receivers .= " \n"; # # and now, really generate the file. Receiver first. print "\n"; -print "\n"; -print "\n\n"; - -# reset iterators -$it_port=4000; -$it_host=0; - -for (my $i=0; $i<$nb_hosts; $i++) { - print " \n"; - print " \n"; - print " \n\n"; - - $it_host ++; - if ($it_host == scalar @host) { - $it_host=0; - $it_port++; - } +print "\n"; +print "\n\n"; + +for my $r (@receivers) { + my ($h, $p) = split(':', $r); + print " \n"; + print " \n"; + print " \n\n"; } # # Here come the sender(s) -# reset iterators -$it_port=4000; -$it_host=0; - -for (my $i=0; $i<$nb_hosts; $i++) { - if (!length($source) || $source == $i) { - print " \n"; - print $receivers; - print " \n"; - } - - $it_host ++; - if ($it_host == scalar @host) { - $it_host=0; - $it_port++; - } +if(length($source)) { + print " \n"; + for my $r (@receivers) { + print " \n"; + } + print " \n"; + print " \n"; +} else { + my $i = 0; + for my $r (@receivers) { + my ($h, $p) = split(":", $r); + print " \n"; + for (my $j = 0; $j < $nb_hosts; $j++) { + my $r2 = $receivers[($i + $j) % ($nb_hosts)]; + print " \n"; + } + print " \n"; + print " \n"; + $i++; + } } -print "\n"; +print "\n"; # print "source='$source' nb_hosts=$nb_hosts\n";