Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New XBT module: file
[simgrid.git] / examples / simdag / simdag_trace.c
index 3ec3954..cc2eabb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2006-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -6,7 +6,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include "simdag/simdag.h"
+#include "simgrid/simdag.h"
 #include "xbt/ex.h"
 #include "xbt/log.h"
 
@@ -27,16 +27,14 @@ int main(int argc, char **argv)
   double rate = -1.0;
   SD_workstation_t w1, w2;
 
-  /* initialisation of SD */
+  /* SD initialization */
   SD_init(&argc, argv);
 
-  TRACE_start ();
-
   /*  xbt_log_control_set("sd.thres=debug"); */
 
   if (argc < 2) {
-    INFO1("Usage: %s platform_file", argv[0]);
-    INFO1("example: %s sd_platform.xml", argv[0]);
+    XBT_INFO("Usage: %s platform_file", argv[0]);
+    XBT_INFO("example: %s sd_platform.xml", argv[0]);
     exit(1);
   }
 
@@ -51,7 +49,7 @@ int main(int argc, char **argv)
   for (i = 0; i < 2; i++) {
     SD_workstation_set_access_mode(workstations[i],
                                    SD_WORKSTATION_SEQUENTIAL_ACCESS);
-    INFO2("Access mode of %s is %s",
+    XBT_INFO("Access mode of %s is %s",
           SD_workstation_get_name(workstations[i]),
           (SD_workstation_get_access_mode(workstations[i]) ==
            SD_WORKSTATION_SEQUENTIAL_ACCESS) ? "sequential" : "shared");
@@ -94,48 +92,48 @@ int main(int argc, char **argv)
                    &(computation_amount[1]), SD_SCHED_NO_COST, rate);
 
   /* let's launch the simulation! */
-  while (xbt_dynar_length(changed_tasks = SD_simulate(-1.0)) > 0) {
+  while (!xbt_dynar_is_empty(changed_tasks = SD_simulate(-1.0))) {
     for (i = 0; i < 2; i++) {
       task = SD_workstation_get_current_task(workstations[i]);
       if (task)
         kind = SD_task_get_kind(task);
       else {
-        INFO1("There is no task running on %s",
+        XBT_INFO("There is no task running on %s",
               SD_workstation_get_name(workstations[i]));
         continue;
       }
 
       switch (kind) {
       case SD_TASK_COMP_SEQ:
-        INFO2("%s is currently running on %s (SD_TASK_COMP_SEQ)",
+        XBT_INFO("%s is currently running on %s (SD_TASK_COMP_SEQ)",
               SD_task_get_name(task),
               SD_workstation_get_name(workstations[i]));
         break;
       case SD_TASK_COMM_E2E:
-        INFO2("%s is currently running on %s (SD_TASK_COMM_E2E)",
+        XBT_INFO("%s is currently running on %s (SD_TASK_COMM_E2E)",
               SD_task_get_name(task),
               SD_workstation_get_name(workstations[i]));
         break;
       case SD_TASK_NOT_TYPED:
-        INFO1("Task running on %s has no type",
+        XBT_INFO("Task running on %s has no type",
               SD_workstation_get_name(workstations[i]));
         break;
       default:
-        ERROR0("Shouldn't be here");
+        XBT_ERROR("Shouldn't be here");
       }
     }
     xbt_dynar_free_container(&changed_tasks);
   }
+  xbt_dynar_free_container(&changed_tasks);
 
-  DEBUG0("Destroying tasks...");
+  XBT_DEBUG("Destroying tasks...");
 
   SD_task_destroy(taskA);
   SD_task_destroy(taskB);
   SD_task_destroy(taskC);
 
-  DEBUG0("Tasks destroyed. Exiting SimDag...");
+  XBT_DEBUG("Tasks destroyed. Exiting SimDag...");
 
   SD_exit();
-  TRACE_end();
   return 0;
 }