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 $nb_hosts = shift @ARGV || usage();
25 my $size_msg = shift @ARGV || usage();
26 my $source = shift || "";
30 open IN,$input || die "Cannot open $input: $!\n";
33 next unless /<cpu name="([^"]*)"/; # "
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 # Build the receiver string
46 my $receivers; # strings containing sender argument describing all receivers.
48 my $it_host=0; # iterator
49 my $it_port=4000; # iterator, in case we have so much processes to add that we must change it
51 for (my $i=0; $i<$nb_hosts; $i++) {
52 $receivers .= " <argument value=\"$host[$it_host]:$it_port\"/>\n";
54 if ($it_host == scalar @host) {
59 $receivers .= " <argument value=\"$size_msg\"/>\n";
62 # and now, really generate the file. Receiver first.
64 print "<?xml version='1.0'?>\n";
65 print "<!DOCTYPE platform_description SYSTEM \"surfxml.dtd\">\n";
66 print "<platform_description version=\"1\">\n\n";
72 for (my $i=0; $i<$nb_hosts; $i++) {
73 print " <process host=\"".$host[$it_host]."\" function=\"receiver\">\n";
74 print " <argument value=\"$it_port\"/><argument value=\"".(length($source)?1:$nb_hosts)."\"/>\n";
75 print " </process>\n\n";
78 if ($it_host == scalar @host) {
85 # Here come the sender(s)
91 for (my $i=0; $i<$nb_hosts; $i++) {
92 if (!length($source) || $source == $i) {
93 print " <process host=\"".$host[$it_host]."\" function=\"sender\">\n";
95 print " </process>\n";
99 if ($it_host == scalar @host) {
105 print "</platform_description>\n";
107 # print "source='$source' nb_hosts=$nb_hosts\n";