7 Usage: all2all_make_deployment.pl platform_file.xml nb_host (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 If a third argument is passed, this is the source of the broadcast
15 (given as a number between 0 and nb_host-1).
21 my $input = shift @ARGV || usage();
22 my $nb_hosts = shift @ARGV || usage();
23 my $source = shift || "";
27 open IN,$input || die "Cannot open $input: $!\n";
30 next unless /<cpu name="([^"]*)"/; # "
35 # map { print "$_\n" } @host;
37 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"
38 unless (scalar @host);
41 # Build the receiver string
43 my $receivers; # strings containing sender argument describing all receivers.
45 my $it_host=0; # iterator
46 my $it_port=4000; # iterator, in case we have so much processes to add that we must change it
48 for (my $i=0; $i<$nb_hosts; $i++) {
49 $receivers .= " <argument value=\"$host[$it_host]:$it_port\"/>\n";
51 if ($it_host == scalar @host) {
58 # and now, really generate the file. Receiver first.
60 print "<?xml version='1.0'?>\n";
61 print "<!DOCTYPE platform_description SYSTEM \"surfxml.dtd\">\n";
62 print "<platform_description version=\"1\">\n\n";
68 for (my $i=0; $i<$nb_hosts; $i++) {
69 print " <process host=\"".$host[$it_host]."\" function=\"receiver\">\n";
70 print " <argument value=\"$it_port\"/><argument value=\"".(length($source)?1:$nb_hosts)."\"/>\n";
71 print " </process>\n\n";
74 if ($it_host == scalar @host) {
81 # Here come the sender(s)
87 for (my $i=0; $i<$nb_hosts; $i++) {
88 if (!length($source) || $source == $i) {
89 print " <process host=\"".$host[$it_host]."\" function=\"sender\">\n";
91 print " </process>\n";
95 if ($it_host == scalar @host) {
101 print "</platform_description>\n";
103 # print "source='$source' nb_hosts=$nb_hosts\n";