7 Usage: make_deployment.pl platform_file.xml nb_host
9 This script generates a deployment file for the PMM 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.
19 my $input = shift @ARGV || usage();
20 my $nb_hosts = shift @ARGV || usage();
21 my $source = shift || "";
25 open IN,$input || die "Cannot open $input: $!\n";
28 next unless /<cpu name="([^"]*)"/; # "
33 # map { print "$_\n" } @host;
35 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"
36 unless (scalar @host);
40 # generate the file. Master first (quite logical, indeed)
42 print "<?xml version='1.0'?>\n";
43 print "<!DOCTYPE platform_description SYSTEM \"surfxml.dtd\">\n";
44 print "<platform_description version=\"1\">\n\n";
45 print " <!-- The master, arguments :: all others nodes -->\n";
46 print " <process host=\"$host[0]\" function=\"master\">\n";
48 # put the slaves as argument of the master
50 my $it_host=0; # iterator
51 my $it_port=4000; # iterator, in case we have so much processes to add that we must change it
52 for (my $i=0; $i<$nb_hosts; $i++) {
53 print " <argument value=\"$host[$it_host]:$it_port\"/>\n";
55 if ($it_host == scalar @host) {
60 print " </process>\n";
62 # Start the slaves also
67 for (my $i=0; $i<$nb_hosts; $i++) {
68 print " <process host=\"".$host[$it_host]."\" function=\"slave\"><argument value=\"$it_port\"/></process>\n";
71 if ($it_host == scalar @host) {
78 print "</platform_description>\n";