7 Usage: all2all_make_deployment.pl platform_file.xml nb_host size_msg (bcast source?)
9 This script generates a deployment file for the all2all program. It takes
10 a SimGrid platform file as first argument and the number of wanted peers as
11 second argument. If the amount of peers exceeds the amount of available
12 hosts in the deployment file, several peers will be placed on the same host.
14 The third argument is a size of the message to send ( octets )
16 If a fourth argument is passed, this is the source of the broadcast
17 (given as a number between 0 and nb_host-1).
23 my $input = shift @ARGV || usage();
24 my $size_msg = shift @ARGV || usage();
25 my $source = shift @ARGV || "";
26 my $nb_hosts = shift @ARGV || 0;
30 open IN,$input || die "Cannot open $input: $!\n";
33 next unless /<host id="([^"]*)"/; # "
38 # map { print "$_\n" } @host;
40 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"
41 unless (scalar @host);
44 $nb_hosts = scalar @host;
49 # Build the receiver string
51 my @receivers; # strings containing sender argument describing all receivers.
53 my $it_host=0; # iterator
54 my $it_port=4000; # iterator, in case we have so much processes to add that we must change it
56 for (my $i=0; $i<$nb_hosts; $i++) {
57 push (@receivers, "$host[$it_host]:$it_port");
59 if ($it_host == scalar @host) {
66 # and now, really generate the file. Receiver first.
68 print "<?xml version='1.0'?>\n";
69 print "<!DOCTYPE platform SYSTEM \"simgrid.dtd\">\n";
70 print "<platform version=\"2\">\n\n";
72 for my $r (@receivers) {
73 my ($h, $p) = split(':', $r);
74 print " <process host=\"".$h."\" function=\"receiver\">\n";
75 print " <argument value=\"$p\"/><argument value=\"".(length($source)?1:$nb_hosts)."\"/>\n";
76 print " </process>\n\n";
80 # Here come the sender(s)
83 print " <process host=\"".$host[$source % (scalar @host)].
84 "\" function=\"sender\">\n";
85 for my $r (@receivers) {
86 print " <argument value=\"$r\"/>\n";
88 print " <argument value=\"$size_msg\"/>\n";
89 print " </process>\n";
92 for my $r (@receivers) {
93 my ($h, $p) = split(":", $r);
94 print " <process host=\"".$h."\" function=\"sender\">\n";
95 for (my $j = 0; $j < $nb_hosts; $j++) {
96 my $r2 = $receivers[($i + $j) % ($nb_hosts)];
97 print " <argument value=\"$r2\"/>\n";
99 print " <argument value=\"$size_msg\"/>\n";
100 print " </process>\n";
105 print "</platform>\n";
107 # print "source='$source' nb_hosts=$nb_hosts\n";