7 Usage: all2all_make_deployment.pl platform_file.xml nb_host
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.
18 my $input = shift @ARGV || usage();
19 my $nb_hosts = shift @ARGV || usage();
23 open IN,$input || die "Cannot open $input: $!\n";
26 next unless /<cpu name="([^"]*)"/; # "
31 # map { print "$_\n" } @host;
33 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"
34 unless (scalar @host);
37 # Build the receiver string
39 my $receivers; # strings containing sender argument describing all receivers.
41 my $it_host=0; # iterator
42 my $it_port=4000; # iterator, in case we have so much processes to add that we must change it
44 for (my $i=0; $i<$nb_hosts; $i++) {
45 $receivers .= " <argument value=\"$host[$it_host]:$it_port\"/>\n";
47 if ($it_host == scalar @host) {
54 # and now, really generate the file
56 print "<?xml version='1.0'?>\n";
57 print "<!DOCTYPE platform_description SYSTEM \"surfxml.dtd\">\n";
58 print "<platform_description>\n\n";
64 for (my $i=0; $i<$nb_hosts; $i++) {
65 print " <process host=\"".$host[$it_host]."\" function=\"sender\">\n";
67 print " </process>\n";
69 print " <process host=\"".$host[$it_host]."\" function=\"receiver\">\n";
70 print " <argument value=\"$it_port\"/><argument value=\"$nb_hosts\"/>\n";
71 print " </process>\n\n";
74 if ($it_host == scalar @host) {
80 print "</platform_description>\n";