Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
some extra cleanups in simdag examples
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 29 Feb 2016 16:30:00 +0000 (17:30 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 29 Feb 2016 16:30:00 +0000 (17:30 +0100)
12 files changed:
examples/simdag/dax/dax_test.c
examples/simdag/dot/dot_test.c
examples/simdag/goal/goal_test.c
examples/simdag/io/sd_io.c
examples/simdag/properties/sd_prop.c
examples/simdag/scheduling/minmin_test.c
examples/simdag/sd_avail.c
examples/simdag/sd_comm_throttling.c
examples/simdag/sd_fail.c
examples/simdag/sd_test.c
examples/simdag/sd_test2.c
examples/simdag/sd_typed_tasks_test.c

index 3954c6b..b7b2a7b 100644 (file)
@@ -6,7 +6,6 @@
 /* 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. */
 
-#include <stdio.h>
 #include "simgrid/simdag.h"
 #include "xbt/log.h"
 #include <string.h>
index 37f825c..1cad621 100644 (file)
@@ -6,7 +6,6 @@
 /* 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. */
 
-#include <stdio.h>
 #include "simgrid/simdag.h"
 #include "xbt/log.h"
 #include <string.h>
index e44ceea..23d774c 100644 (file)
 /* 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. */
 
-#include <stdlib.h>
-#include <stdio.h>
 #include "simgrid/simdag.h"
 #include "xbt/log.h"
-#include "xbt/ex.h"
-#include <string.h>
 #include "xbt/xbt_os_time.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(goal, "The GOAL loader into SimDag");
@@ -25,7 +21,6 @@ typedef struct {
   int i, j, k;
 } s_bcast_task_t,*bcast_task_t;
 
-
 const sg_host_t* ws_list;
 int count = 0;
 
@@ -55,7 +50,6 @@ static void send_one(int from, int to) {
   SD_task_watch(task,SD_DONE);
 }
 
-
 int main(int argc, char **argv) {
   xbt_os_timer_t timer = xbt_os_timer_new();
 
index ed6897b..a04c20b 100644 (file)
@@ -12,8 +12,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(sd_io, "Logging specific to this SimDag example");
 int main(int argc, char **argv)
 {
   unsigned int ctr;
-  const sg_host_t *workstations;
-  int total_nworkstations;
   xbt_dict_t current_storage_list;
   char *mount_name;
   char *storage_name;
@@ -23,8 +21,8 @@ int main(int argc, char **argv)
   /* Set the workstation model to default, as storage is not supported by the ptask_L07 model yet. */
   SD_config("host/model", "default");
   SD_create_environment(argv[1]);
-  workstations = sg_host_list();
-  total_nworkstations = sg_host_count();
+  const sg_host_t *workstations = sg_host_list();
+  int total_nworkstations = sg_host_count();
 
   for (ctr=0; ctr<total_nworkstations;ctr++){
     current_storage_list = sg_host_get_mounted_storage_list(workstations[ctr]);
index cc82514..040e55b 100644 (file)
@@ -5,16 +5,11 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/simdag.h"
-#include "xbt/log.h"
-#include "xbt/dict.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Property test");
 
 int main(int argc, char **argv)
 {
-  sg_host_t h1, h2;
-  const char *name1, *name2;
-  xbt_dict_t props;
   xbt_dict_cursor_t cursor = NULL;
   char *key, *data;
   char noexist[] = "NoProp";
@@ -28,14 +23,14 @@ int main(int argc, char **argv)
   SD_create_environment(argv[1]);
 
   /* init of platform elements */
-  h1 = sg_host_by_name("host1");
-  h2 = sg_host_by_name("host2");
-  name1 = sg_host_get_name(h1);
-  name2 = sg_host_get_name(h2);
+  sg_host_t h1 = sg_host_by_name("host1");
+  sg_host_t h2 = sg_host_by_name("host2");
+  const char *name1 = sg_host_get_name(h1);
+  const char *name2 = sg_host_get_name(h2);
 
   /* Get the property list of 'host1' */
   XBT_INFO("Property list for host %s", name1);
-  props = sg_host_get_properties(h1);
+  xbt_dict_t props = sg_host_get_properties(h1);
 
   /* Trying to set a new property */
   xbt_dict_set(props, "NewProp", strdup("newValue"), xbt_free_f);
index 6ac0f78..37b8f79 100644 (file)
@@ -5,12 +5,8 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* simple test to schedule a DAX file with the Min-Min algorithm.           */
-#include <stdlib.h>
-#include <stdio.h>
 #include <string.h>
 #include "simgrid/simdag.h"
-#include "xbt/log.h"
-#include "xbt/ex.h"
 
 #ifdef HAVE_JEDULE
 #include "simgrid/jedule/jedule_sd_binding.h"
index 653562e..f966a04 100644 (file)
@@ -5,7 +5,6 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/simdag.h"
-#include "xbt/log.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_avail, "Logging specific to this SimDag example");
 
@@ -41,21 +40,20 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(sd_avail, "Logging specific to this SimDag example"
 int main(int argc, char **argv)
 {
   unsigned int ctr;
-  const sg_host_t *hosts;
-  SD_task_t t1, c1, t2, c2, t3, c3, t4, task;
+  SD_task_t task;
   xbt_dynar_t changed_tasks;
 
   SD_init(&argc, argv);
   SD_create_environment(argv[1]);
-  hosts = sg_host_list();
+  const sg_host_t *hosts = sg_host_list();
 
-  t1 = SD_task_create_comp_seq("t1", NULL, 25000000);
-  c1 = SD_task_create_comm_e2e("c1", NULL, 125000000);
-  t2 = SD_task_create_comp_seq("t2", NULL, 25000000);
-  c2 = SD_task_create_comm_e2e("c2", NULL, 62500000);
-  t3 = SD_task_create_comp_seq("t3", NULL, 25000000);
-  c3 = SD_task_create_comm_e2e("c3", NULL, 31250000);
-  t4 = SD_task_create_comp_seq("t4", NULL, 25000000);
+  SD_task_t t1 = SD_task_create_comp_seq("t1", NULL, 25000000);
+  SD_task_t c1 = SD_task_create_comm_e2e("c1", NULL, 125000000);
+  SD_task_t t2 = SD_task_create_comp_seq("t2", NULL, 25000000);
+  SD_task_t c2 = SD_task_create_comm_e2e("c2", NULL, 62500000);
+  SD_task_t t3 = SD_task_create_comp_seq("t3", NULL, 25000000);
+  SD_task_t c3 = SD_task_create_comm_e2e("c3", NULL, 31250000);
+  SD_task_t t4 = SD_task_create_comp_seq("t4", NULL, 25000000);
 
   /* Add dependencies: t1->c1->t2->c2->t3 */
   SD_task_dependency_add(NULL, NULL, t1, c1);
index 99a6605..fef44bc 100644 (file)
@@ -4,34 +4,30 @@
 /* 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. */
 
-#include <stdio.h>
 #include "simgrid/simdag.h"
-#include "xbt/log.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_comm_throttling, "Logging specific to this SimDag example");
 
 int main(int argc, char **argv)
 {
   unsigned int ctr;
-  const sg_host_t *hosts;
-  SD_task_t task, taskA, taskB, taskC, taskD, taskE;
+  SD_task_t task;
   xbt_dynar_t changed_tasks;
 
   SD_init(&argc, argv);
   xbt_assert(argc > 1, "Usage: %s platform_file\n\nExample: %s two_clusters.xml", argv[0], argv[0]);
 
-  /* creation of the environment */
   SD_create_environment(argv[1]);
 
-  hosts = sg_host_list();
+  const sg_host_t *hosts = sg_host_list();
 
   /* creation of some typed tasks and their dependencies */
   /* chain of five tasks, three compute tasks with two data transfers in between */
-  taskA = SD_task_create_comp_seq("Task A", NULL, 5e9);
-  taskB = SD_task_create_comm_e2e("Task B", NULL, 1e7);
-  taskC = SD_task_create_comp_seq("Task C", NULL, 5e9);
-  taskD = SD_task_create_comm_e2e("Task D", NULL, 1e7);
-  taskE = SD_task_create_comp_seq("Task E", NULL, 5e9);
+  SD_task_t taskA = SD_task_create_comp_seq("Task A", NULL, 5e9);
+  SD_task_t taskB = SD_task_create_comm_e2e("Task B", NULL, 1e7);
+  SD_task_t taskC = SD_task_create_comp_seq("Task C", NULL, 5e9);
+  SD_task_t taskD = SD_task_create_comm_e2e("Task D", NULL, 1e7);
+  SD_task_t taskE = SD_task_create_comp_seq("Task E", NULL, 5e9);
 
   SD_task_dependency_add(NULL, NULL, taskA, taskB);
   SD_task_dependency_add(NULL, NULL, taskB, taskC);
index 7620ea3..0bec7da 100644 (file)
@@ -5,13 +5,11 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/simdag.h"
-#include "xbt/log.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_fail, "Logging specific to this SimDag example");
 
 int main(int argc, char **argv)
 {
-  SD_task_t task;
   double computation_amount[1];
   double communication_amount[2] = { 0 };
   sg_host_t hosts[1];
@@ -21,11 +19,10 @@ int main(int argc, char **argv)
 
   /* creation of the environment */
   SD_create_environment(argv[1]);
-  /* creation of a single task that will poorly fail when the workstation
-   * will stop */
+
+  /* creation of a single task that will poorly fail when the workstation will stop */
   XBT_INFO("First test: COMP_SEQ task");
-  task = SD_task_create_comp_seq("Poor task", NULL, 2e10);
+  SD_task_t task = SD_task_create_comp_seq("Poor task", NULL, 2e10);
   SD_task_watch(task, SD_FAILED);
   SD_task_watch(task, SD_DONE);
 
index 0c9d065..02bbd38 100644 (file)
@@ -12,15 +12,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test, "Logging specific to this SimDag example")
 
 int main(int argc, char **argv)
 {
-  int i;
   unsigned int ctr;
-  const sg_host_t *hosts;
-  const char *name1, *name2;
-  double comp_amount1, comp_amount2;
-  double comm_amount12, comm_amount21;
-  const SD_link_t *route;
-  int route_size;
-  SD_task_t task, taskA, taskB, taskC, taskD, checkB, checkD;
+  SD_task_t checkB, checkD;
   xbt_dynar_t changed_tasks;
   xbt_ex_t ex;
   const int host_count = 2;
@@ -28,7 +21,6 @@ int main(int argc, char **argv)
   double computation_amount[2];
   double communication_amount[4] = { 0 };
   double rate = -1.0;
-  sg_host_t h1, h2;
 
   /* initialization of SD */
   SD_init(&argc, argv);
@@ -37,22 +29,22 @@ int main(int argc, char **argv)
   SD_create_environment(argv[1]);
 
   /* test the estimation functions */
-  hosts = sg_host_list();
-  h1 = hosts[0];
-  h2 = hosts[1];
-  name1 = sg_host_get_name(h1);
-  name2 = sg_host_get_name(h2);
-  comp_amount1 = 2000000;
-  comp_amount2 = 1000000;
-  comm_amount12 = 2000000;
-  comm_amount21 = 3000000;
+  const sg_host_t *hosts = sg_host_list();
+  sg_host_t h1 = hosts[0];
+  sg_host_t h2 = hosts[1];
+  const char *name1 = sg_host_get_name(h1);
+  const char *name2 = sg_host_get_name(h2);
+  double comp_amount1 = 2000000;
+  double comp_amount2 = 1000000;
+  double comm_amount12 = 2000000;
+  double comm_amount21 = 3000000;
   XBT_INFO("Computation time for %f flops on %s: %f", comp_amount1, name1, comp_amount1/sg_host_speed(h1));
   XBT_INFO("Computation time for %f flops on %s: %f", comp_amount2, name2, comp_amount2/sg_host_speed(h2));
 
   XBT_INFO("Route between %s and %s:", name1, name2);
-  route = SD_route_get_list(h1, h2);
-  route_size = SD_route_get_size(h1, h2);
-  for (i = 0; i < route_size; i++) {
+  const SD_link_t *route = SD_route_get_list(h1, h2);
+  int route_size = SD_route_get_size(h1, h2);
+  for (int i = 0; i < route_size; i++) {
     XBT_INFO("   Link %s: latency = %f, bandwidth = %f", sg_link_name(route[i]), sg_link_latency(route[i]),
              sg_link_bandwidth(route[i]));
   }
@@ -63,10 +55,10 @@ int main(int argc, char **argv)
         SD_route_get_latency(h2, h1) + comm_amount21 / SD_route_get_bandwidth(h2, h1));
 
   /* creation of the tasks and their dependencies */
-  taskA = SD_task_create("Task A", NULL, 10.0);
-  taskB = SD_task_create("Task B", NULL, 40.0);
-  taskC = SD_task_create("Task C", NULL, 30.0);
-  taskD = SD_task_create("Task D", NULL, 60.0);
+  SD_task_t taskA = SD_task_create("Task A", NULL, 10.0);
+  SD_task_t taskB = SD_task_create("Task B", NULL, 40.0);
+  SD_task_t taskC = SD_task_create("Task C", NULL, 30.0);
+  SD_task_t taskD = SD_task_create("Task D", NULL, 60.0);
 
   /* try to attach and retrieve user data to a task */
   SD_task_set_data(taskA, (void*) &comp_amount1);
@@ -136,7 +128,7 @@ int main(int argc, char **argv)
   communication_amount[2] = comm_amount21;
 
   /* estimated time */
-  task = taskD;
+  SD_task_t task = taskD;
   XBT_INFO("Estimated time for '%s': %f", SD_task_get_name(task), SD_task_get_execution_time(task, host_count,
            host_list, computation_amount, communication_amount));
 
index 9904631..6514f38 100644 (file)
@@ -19,17 +19,6 @@ static int nameCompareHosts(const void *n1, const void *n2)
 int main(int argc, char **argv)
 {
   int i, j;
-  int n_hosts;
-  const sg_host_t *hosts;
-  SD_task_t taskInit;
-  SD_task_t PtoPComm1;
-  SD_task_t PtoPComm2;
-  SD_task_t ParComp_wocomm;
-  SD_task_t IntraRedist;
-  SD_task_t ParComp_wcomm1;
-  SD_task_t InterRedist;
-  SD_task_t taskFinal;
-  SD_task_t ParComp_wcomm2;
   sg_host_t PtoPcomm1_hosts[2];
   sg_host_t PtoPcomm2_hosts[2];
   double PtoPcomm1_table[] = { 0, 12500000, 0, 0 };     /* 100Mb */
@@ -56,22 +45,22 @@ int main(int argc, char **argv)
   SD_create_environment(argv[1]);
 
   /* getting platform infos */
-  n_hosts = sg_host_count();
-  hosts = sg_host_list();
+  int n_hosts = sg_host_count();
+  const sg_host_t *hosts = sg_host_list();
 
   /* sorting hosts by hostname */
   qsort((void *) hosts, n_hosts, sizeof(sg_host_t), nameCompareHosts);
 
   /* creation of the tasks */
-  taskInit = SD_task_create("Initial", NULL, 1.0);
-  PtoPComm1 = SD_task_create("PtoP Comm 1", NULL, 1.0);
-  PtoPComm2 = SD_task_create("PtoP Comm 2", NULL, 1.0);
-  ParComp_wocomm = SD_task_create("Par Comp without comm", NULL, 1.0);
-  IntraRedist = SD_task_create("intra redist", NULL, 1.0);
-  ParComp_wcomm1 = SD_task_create("Par Comp with comm 1", NULL, 1.0);
-  InterRedist = SD_task_create("inter redist", NULL, 1.0);
-  taskFinal = SD_task_create("Final", NULL, 1.0);
-  ParComp_wcomm2 = SD_task_create("Par Comp with comm 2", NULL, 1.0);
+  SD_task_t taskInit = SD_task_create("Initial", NULL, 1.0);
+  SD_task_t PtoPComm1 = SD_task_create("PtoP Comm 1", NULL, 1.0);
+  SD_task_t PtoPComm2 = SD_task_create("PtoP Comm 2", NULL, 1.0);
+  SD_task_t ParComp_wocomm = SD_task_create("Par Comp without comm", NULL, 1.0);
+  SD_task_t IntraRedist = SD_task_create("intra redist", NULL, 1.0);
+  SD_task_t ParComp_wcomm1 = SD_task_create("Par Comp with comm 1", NULL, 1.0);
+  SD_task_t InterRedist = SD_task_create("inter redist", NULL, 1.0);
+  SD_task_t taskFinal = SD_task_create("Final", NULL, 1.0);
+  SD_task_t ParComp_wcomm2 = SD_task_create("Par Comp with comm 2", NULL, 1.0);
 
   /* creation of the dependencies */
   SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm1);
index cd24809..f8421b2 100644 (file)
@@ -11,11 +11,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(sd_typed_tasks_test, "Logging specific to this SimD
 
 int main(int argc, char **argv)
 {
-  int i;
   unsigned int ctr;
-  const sg_host_t *hosts;
-  SD_task_t task, seq_comp1, e2e_comm, seq_comp2;
-  SD_task_t par_comp1, redist, par_comp2, par_comp3;
+  SD_task_t task;
   xbt_dynar_t changed_tasks;
 
   double computation_amount[4];
@@ -27,17 +24,16 @@ 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]);
 
-  hosts = sg_host_list();
+  const sg_host_t *hosts = sg_host_list();
 
   /* creation of some typed tasks and their dependencies */
-  seq_comp1 = SD_task_create_comp_seq("Seq. comp. 1", NULL, 1e9);
-  e2e_comm = SD_task_create_comm_e2e("E2E comm.", NULL, 1e7);
-  seq_comp2 = SD_task_create_comp_seq("Seq. comp 2.", NULL, 1e9);
-  par_comp1 = SD_task_create_comp_par_amdahl("Par. Comp. 1", NULL, 1e9, 0.2);
-  redist = SD_task_create_comm_par_mxn_1d_block("MxN redist", NULL, 1.2e8);
-  par_comp2 = SD_task_create_comp_par_amdahl("Par. Comp. 2", NULL, 3e8, 0.5);
-
-  par_comp3 = SD_task_create("Par. Comp. 3", NULL, 1e9);
+  SD_task_t seq_comp1 = SD_task_create_comp_seq("Seq. comp. 1", NULL, 1e9);
+  SD_task_t e2e_comm = SD_task_create_comm_e2e("E2E comm.", NULL, 1e7);
+  SD_task_t seq_comp2 = SD_task_create_comp_seq("Seq. comp 2.", NULL, 1e9);
+  SD_task_t par_comp1 = SD_task_create_comp_par_amdahl("Par. Comp. 1", NULL, 1e9, 0.2);
+  SD_task_t redist = SD_task_create_comm_par_mxn_1d_block("MxN redist", NULL, 1.2e8);
+  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);
@@ -59,7 +55,7 @@ int main(int argc, char **argv)
   SD_task_schedulev(par_comp2, 3, hosts);
   SD_task_schedulev(par_comp1, 4, hosts);
 
-  for (i=0;i<4;i++){
+  for (int i=0;i<4;i++){
     host_list[i]=hosts[i+4];
     /* Apply Amdahl's law manually assuming a 20% serial part */
     computation_amount[i]=(0.2 + (1 - 0.2)/4) * SD_task_get_amount(par_comp3);