Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Modify the all2all to support all data Message Size
authoramad206 <amad206@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 23 Jun 2006 12:58:52 +0000 (12:58 +0000)
committeramad206 <amad206@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 23 Jun 2006 12:58:52 +0000 (12:58 +0000)
and make_deployment to add a massage size in deployment files

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2426 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/gras/all2all/all2all.c
examples/gras/all2all/make_deployment.pl

index d194b62..e2200e4 100644 (file)
@@ -28,7 +28,7 @@ int receiver (int argc,char *argv[]) {
 
   int myport; /* port on which I receive stuff */
   int todo; /* amount of messages I should get */
 
   int myport; /* port on which I receive stuff */
   int todo; /* amount of messages I should get */
-  int data; /* message content */
+  char *data; /* message content */
  
   gras_socket_t mysock;  /* socket on which other people contact me */
   gras_socket_t expeditor;  /* to notice who wrote me */
  
   gras_socket_t mysock;  /* socket on which other people contact me */
   gras_socket_t expeditor;  /* to notice who wrote me */
@@ -44,7 +44,7 @@ int receiver (int argc,char *argv[]) {
   mysock = gras_socket_server(myport);
 
   /* Register the known messages */
   mysock = gras_socket_server(myport);
 
   /* Register the known messages */
-  gras_msgtype_declare("data", gras_datadesc_by_name("int"));
+  gras_msgtype_declare("data", gras_datadesc_by_name("string"));
 
   /* Get the data */
 
 
   /* Get the data */
 
@@ -58,16 +58,16 @@ int receiver (int argc,char *argv[]) {
                   &data);
      todo--;
      
                   &data);
      todo--;
      
-     INFO4("Got Data(%d) from %s:%d (still %d to go)",
-          data, 
+     INFO3("Got Data from %s:%d (still %d to go)",
+         /* data,*/
           gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor),
           todo);
 
   }
           gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor),
           todo);
 
   }
-   
+
   /* Free the allocated resources, and shut GRAS down */
   gras_socket_close(mysock);
   /* Free the allocated resources, and shut GRAS down */
   gras_socket_close(mysock);
-     
+
   gras_exit();
   return 0;
 } /* end_of_receiver */
   gras_exit();
   return 0;
 } /* end_of_receiver */
@@ -79,11 +79,12 @@ int receiver (int argc,char *argv[]) {
 int sender (int argc,char *argv[]) {
 
   int i; /* iterator */
 int sender (int argc,char *argv[]) {
 
   int i; /* iterator */
-  int data; /* data exchanged */
+  char *data; /* data exchanged */
+  int datasize; /* size of message */
   xbt_host_t h; /* iterator */
   
   gras_socket_t peer;  /* socket to node */
   xbt_host_t h; /* iterator */
   
   gras_socket_t peer;  /* socket to node */
+  
  
   /* xbt_dynar for hosts */
   xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&xbt_host_free_voidp);
  
   /* xbt_dynar for hosts */
   xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&xbt_host_free_voidp);
@@ -92,27 +93,33 @@ int sender (int argc,char *argv[]) {
   gras_init(&argc,argv);
  
   /* Get the node location from argc/argv */
   gras_init(&argc,argv);
  
   /* Get the node location from argc/argv */
-  for (i=1; i<argc; i++){
+  for (i=1; i<argc-1; i++){
     xbt_host_t host = xbt_host_from_string(argv[i]);
     xbt_dynar_push(hosts,&host);
   }
     xbt_host_t host = xbt_host_from_string(argv[i]);
     xbt_dynar_push(hosts,&host);
   }
+  
+  datasize=atoi(argv[argc-1]);
+  
+  data=(char *) malloc(datasize+1);  // allocation of datasize octets
+  memset(data, 32, datasize);
+  data[datasize] = '\0';
 
   INFO0("Launch current node");
 
   /* Register the known messages */
 
   INFO0("Launch current node");
 
   /* Register the known messages */
-  gras_msgtype_declare("data", gras_datadesc_by_name("int"));
+  gras_msgtype_declare("data", gras_datadesc_by_name("string"));
+
 
   /* Wait for receivers to startup */
   gras_os_sleep(1);
 
   /* write 'em */
 
   /* Wait for receivers to startup */
   gras_os_sleep(1);
 
   /* write 'em */
-  data =1000;
   xbt_dynar_foreach(hosts,i,h) {
      
      peer = gras_socket_client(h->name,h->port);
      gras_msg_send(peer,gras_msgtype_by_name("data"),&data);
   xbt_dynar_foreach(hosts,i,h) {
      
      peer = gras_socket_client(h->name,h->port);
      gras_msg_send(peer,gras_msgtype_by_name("data"),&data);
-     INFO3("  Sent Data (%d) from %s to %s",
-          data,gras_os_myname(),h->name);
+     INFO2("  Sent Data from %s to %s",
+          /*data,*/gras_os_myname(),h->name);
      gras_socket_close(peer);
   }
 
      gras_socket_close(peer);
   }
 
index b3f2d67..1e4bf68 100755 (executable)
@@ -4,14 +4,16 @@ use strict;
 
 sub usage {
     print STDERR <<EOH
 
 sub usage {
     print STDERR <<EOH
-Usage: all2all_make_deployment.pl platform_file.xml nb_host (bcast source?)
+Usage: all2all_make_deployment.pl platform_file.xml nb_host size_msg (bcast source?)
   
 This script generates a deployment file for the all2all program. It takes 
 a SimGrid platform file as first argument and the number of wanted peers as 
 second argument. If the amount of peers exceeds the amount of available 
 hosts in the deployment file, several peers will be placed on the same host.
   
 This script generates a deployment file for the all2all program. It takes 
 a SimGrid platform file as first argument and the number of wanted peers as 
 second argument. If the amount of peers exceeds the amount of available 
 hosts in the deployment file, several peers will be placed on the same host.
-      
-If a third argument is passed, this is the source of the broadcast
+
+The third argument is a size of the message to send ( octets )  
+
+If a fourth argument is passed, this is the source of the broadcast
 (given as a number between 0 and nb_host-1).
 EOH
       ;
 (given as a number between 0 and nb_host-1).
 EOH
       ;
@@ -20,6 +22,7 @@ EOH
 
 my $input    = shift @ARGV || usage();
 my $nb_hosts = shift @ARGV || usage();
 
 my $input    = shift @ARGV || usage();
 my $nb_hosts = shift @ARGV || usage();
+my $size_msg = shift @ARGV || usage();
 my $source   = shift || "";
 
 my @host;
 my $source   = shift || "";
 
 my @host;
@@ -53,6 +56,7 @@ for (my $i=0; $i<$nb_hosts; $i++) {
     $it_port++;
   }
 }
     $it_port++;
   }
 }
+$receivers .= "    <argument value=\"$size_msg\"/>\n";
 
 #
 # and now, really generate the file. Receiver first.
 
 #
 # and now, really generate the file. Receiver first.