Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Round-robin deployment so that everybody does not send to the same guy at the same...
authoreyraudl <eyraudl@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 27 Aug 2007 14:24:46 +0000 (14:24 +0000)
committereyraudl <eyraudl@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 27 Aug 2007 14:24:46 +0000 (14:24 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4118 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/gras/all2all/make_deployment.pl

index 1e4bf68..8698ac6 100755 (executable)
@@ -21,9 +21,9 @@ EOH
 }
 
 my $input    = shift @ARGV || usage();
 }
 
 my $input    = shift @ARGV || usage();
-my $nb_hosts = shift @ARGV || usage();
 my $size_msg = shift @ARGV || usage();
 my $size_msg = shift @ARGV || usage();
-my $source   = shift || "";
+my $source   = shift @ARGV || "";
+my $nb_hosts = shift @ARGV || 0;
 
 my @host;
 
 
 my @host;
 
@@ -40,23 +40,27 @@ while (<IN>) {
 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"
   unless (scalar @host);
 
 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"
   unless (scalar @host);
 
+if (! $nb_hosts) {
+    $nb_hosts = scalar @host;
+}
+
+
 # 
 # Build the receiver string
 
 # 
 # Build the receiver string
 
-my $receivers;    # strings containing sender argument describing all receivers.
+my @receivers;    # strings containing sender argument describing all receivers.
 
 my $it_host=0;    # iterator
 my $it_port=4000; # iterator, in case we have so much processes to add that we must change it
 
 for (my $i=0; $i<$nb_hosts; $i++) {
 
 my $it_host=0;    # iterator
 my $it_port=4000; # iterator, in case we have so much processes to add that we must change it
 
 for (my $i=0; $i<$nb_hosts; $i++) {
-  $receivers .= "    <argument value=\"$host[$it_host]:$it_port\"/>\n";
+  push (@receivers, "$host[$it_host]:$it_port");
   $it_host ++;
   if ($it_host == scalar @host) {
     $it_host=0;
     $it_port++;
   }
 }
   $it_host ++;
   if ($it_host == scalar @host) {
     $it_host=0;
     $it_port++;
   }
 }
-$receivers .= "    <argument value=\"$size_msg\"/>\n";
 
 #
 # and now, really generate the file. Receiver first.
 
 #
 # and now, really generate the file. Receiver first.
@@ -65,41 +69,37 @@ print "<?xml version='1.0'?>\n";
 print "<!DOCTYPE platform_description SYSTEM \"surfxml.dtd\">\n";
 print "<platform_description version=\"1\">\n\n";
 
 print "<!DOCTYPE platform_description SYSTEM \"surfxml.dtd\">\n";
 print "<platform_description version=\"1\">\n\n";
 
-# reset iterators
-$it_port=4000;
-$it_host=0;
-
-for (my $i=0; $i<$nb_hosts; $i++) {
-  print "  <process host=\"".$host[$it_host]."\" function=\"receiver\">\n";
-  print "    <argument value=\"$it_port\"/><argument value=\"".(length($source)?1:$nb_hosts)."\"/>\n";
-  print "  </process>\n\n";
-    
-  $it_host ++;
-  if ($it_host == scalar @host) {
-    $it_host=0;
-    $it_port++;
-  }
+for my $r (@receivers) {
+    my ($h, $p) = split(':', $r);
+    print "  <process host=\"".$h."\" function=\"receiver\">\n";
+    print "    <argument value=\"$p\"/><argument value=\"".(length($source)?1:$nb_hosts)."\"/>\n";
+    print "  </process>\n\n";
 }
 
 #
 # Here come the sender(s)
 
 }
 
 #
 # Here come the sender(s)
 
-# reset iterators
-$it_port=4000;
-$it_host=0;
-
-for (my $i=0; $i<$nb_hosts; $i++) {
-  if (!length($source) || $source == $i) {
-      print "  <process host=\"".$host[$it_host]."\" function=\"sender\">\n";
-      print $receivers;
-      print "  </process>\n";
-  }
-    
-  $it_host ++;
-  if ($it_host == scalar @host) {
-    $it_host=0;
-    $it_port++;
-  }
+if(length($source)) {
+    print "  <process host=\"".$host[$source % (scalar @host)].
+       "\" function=\"sender\">\n";
+    for my $r (@receivers) {
+       print "    <argument value=\"$r\"/>\n"; 
+    }
+    print "    <argument value=\"$size_msg\"/>\n"; 
+    print "  </process>\n";
+} else {
+    my $i = 0; 
+    for my $r (@receivers) {
+       my ($h, $p) = split(":", $r); 
+        print "  <process host=\"".$h."\" function=\"sender\">\n";
+        for (my $j = 0; $j < $nb_hosts; $j++) {
+           my $r2 = $receivers[($i + $j) % ($nb_hosts)]; 
+           print "    <argument value=\"$r2\"/>\n"; 
+        }
+        print "    <argument value=\"$size_msg\"/>\n"; 
+        print "  </process>\n";
+        $i++;
+    }
 }
 
 print "</platform_description>\n";
 }
 
 print "</platform_description>\n";