Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / examples / simdag / typed_tasks / sd_typed_tasks.c
index f8421b2..0351004 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2010, 2012-2016. The SimGrid Team.
+/* Copyright (c) 2006-2019. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -13,7 +13,6 @@ int main(int argc, char **argv)
 {
   unsigned int ctr;
   SD_task_t task;
-  xbt_dynar_t changed_tasks;
 
   double computation_amount[4];
   double communication_amount[16] = { 0 };
@@ -24,7 +23,7 @@ int main(int argc, char **argv)
   xbt_assert(argc > 1, "Usage: %s platform_file\n\nExample: %s two_clusters.xml", argv[0], argv[0]);
   SD_create_environment(argv[1]);
 
-  const sg_host_t *hosts = sg_host_list();
+  sg_host_t *hosts = sg_host_list();
 
   /* creation of some typed tasks and their dependencies */
   SD_task_t seq_comp1 = SD_task_create_comp_seq("Seq. comp. 1", NULL, 1e9);
@@ -35,11 +34,11 @@ int main(int argc, char **argv)
   SD_task_t par_comp2 = SD_task_create_comp_par_amdahl("Par. Comp. 2", NULL, 3e8, 0.5);
   SD_task_t par_comp3 = SD_task_create("Par. Comp. 3", NULL, 1e9);
 
-  SD_task_dependency_add(NULL, NULL, seq_comp1, e2e_comm);
-  SD_task_dependency_add(NULL, NULL, e2e_comm, seq_comp2);
+  SD_task_dependency_add(seq_comp1, e2e_comm);
+  SD_task_dependency_add(e2e_comm, seq_comp2);
 
-  SD_task_dependency_add(NULL, NULL, par_comp1, redist);
-  SD_task_dependency_add(NULL, NULL, redist, par_comp2);
+  SD_task_dependency_add(par_comp1, redist);
+  SD_task_dependency_add(redist, par_comp2);
 
   SD_task_schedulel(seq_comp1, 1, hosts[8]);
   SD_task_schedulel(seq_comp2, 1, hosts[9]);
@@ -63,15 +62,17 @@ int main(int argc, char **argv)
 
   SD_task_schedule(par_comp3, 4, host_list, computation_amount, communication_amount, -1);
 
-  changed_tasks = SD_simulate(-1.0);
+  xbt_dynar_t changed_tasks = xbt_dynar_new(sizeof(SD_task_t), NULL);
+  SD_simulate_with_update(-1.0, changed_tasks);
   xbt_dynar_foreach(changed_tasks, ctr, task) {
     XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task),
              SD_task_get_finish_time(task));
   }
 
-  xbt_dynar_foreach(changed_tasks, ctr, task) {
+  xbt_dynar_foreach(changed_tasks, ctr, task)
     SD_task_destroy(task);
-  }
-  SD_exit();
+  xbt_dynar_free_container(&changed_tasks);
+
+  xbt_free(hosts);
   return 0;
 }