Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix compilation with tracing and new network_element_t
[simgrid.git] / examples / gras / all2all / all2all.c
index 823cfe5..7872303 100644 (file)
@@ -1,6 +1,7 @@
 /* ALL2ALL - all2all of GRAS features                                       */
 
-/* Copyright (c) 2006 Ahmed Harbaoui. All rights reserved.                  */
+/* Copyright (c) 2006, 2007, 2009, 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
 
  /* This program is free software; you can redistribute it and/or modify it
   * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -30,8 +31,8 @@ int receiver(int argc, char *argv[])
   int todo;                     /* amount of messages I should get */
   char *data;                   /* message content */
 
-  gras_socket_t mysock;         /* socket on which other people contact me */
-  gras_socket_t expeditor;      /* to notice who wrote me */
+  xbt_socket_t mysock;         /* socket on which other people contact me */
+  xbt_socket_t expeditor;      /* to notice who wrote me */
 
   /* Init the GRAS infrastructure and declare my globals */
   gras_init(&argc, argv);
@@ -41,23 +42,23 @@ int receiver(int argc, char *argv[])
   todo = atoi(argv[2]);
 
   /* Register the known messages */
-  gras_msgtype_declare("data", gras_datadesc_by_name("string"));
+  gras_msgtype_declare("data", xbt_datadesc_by_name("string"));
 
   /* Create my master socket */
   mysock = gras_socket_server(myport);
 
   /* Get the data */
-  INFO2("Listening on port %d (expecting %d messages)",
-        gras_socket_my_port(mysock), todo);
+  XBT_INFO("Listening on port %d (expecting %d messages)",
+        xbt_socket_my_port(mysock), todo);
   while (todo > 0) {
     gras_msg_wait(60 /* wait up to one minute */ ,
                   "data", &expeditor, &data);
     todo--;
     free(data);
 
-    INFO3("Got Data from %s:%d (still %d to go)",
-          gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor),
-          todo);
+    XBT_INFO("Got Data from %s:%d (still %d to go)",
+          xbt_socket_peer_name(expeditor),
+          xbt_socket_peer_port(expeditor), todo);
 
   }
 
@@ -81,11 +82,12 @@ int sender(int argc, char *argv[])
   xbt_peer_t h;                 /* iterator */
   int connected = 0;
 
-  gras_socket_t peer = NULL;    /* socket to node */
+  volatile xbt_socket_t peer = NULL;    /* socket to node */
 
 
   /* xbt_dynar for peers */
-  xbt_dynar_t peers = xbt_dynar_new(sizeof(xbt_peer_t), &xbt_peer_free_voidp);
+  xbt_dynar_t peers =
+      xbt_dynar_new(sizeof(xbt_peer_t), &xbt_peer_free_voidp);
 
   /* Init the GRAS infrastructure and declare my globals */
   gras_init(&argc, argv);
@@ -102,10 +104,10 @@ int sender(int argc, char *argv[])
   memset(data, 32, datasize);
   data[datasize] = '\0';
 
-  INFO0("Launch current node");
+  XBT_INFO("Launch current node");
 
   /* Register the known messages */
-  gras_msgtype_declare("data", gras_datadesc_by_name("string"));
+  gras_msgtype_declare("data", xbt_datadesc_by_name("string"));
 
 
   /* write to the receivers */
@@ -127,9 +129,9 @@ int sender(int argc, char *argv[])
     }
     gras_msg_send(peer, "data", &data);
     if (gras_if_SG()) {
-      INFO2("  Sent Data from %s to %s", gras_os_myname(), h->name);
+      XBT_INFO("  Sent Data from %s to %s", gras_os_myname(), h->name);
     } else {
-      INFO0("  Sent Data");
+      XBT_INFO("  Sent Data");
     }
 
     gras_socket_close(peer);