From 47418069ee9cb5ae4e5f14d86d9c93dfbec04d03 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 29 Feb 2016 17:30:00 +0100 Subject: [PATCH] some extra cleanups in simdag examples --- examples/simdag/dax/dax_test.c | 1 - examples/simdag/dot/dot_test.c | 1 - examples/simdag/goal/goal_test.c | 6 ---- examples/simdag/io/sd_io.c | 6 ++-- examples/simdag/properties/sd_prop.c | 15 +++----- examples/simdag/scheduling/minmin_test.c | 4 --- examples/simdag/sd_avail.c | 20 +++++------ examples/simdag/sd_comm_throttling.c | 18 ++++------ examples/simdag/sd_fail.c | 9 ++--- examples/simdag/sd_test.c | 44 ++++++++++-------------- examples/simdag/sd_test2.c | 33 ++++++------------ examples/simdag/sd_typed_tasks_test.c | 24 ++++++------- 12 files changed, 65 insertions(+), 116 deletions(-) diff --git a/examples/simdag/dax/dax_test.c b/examples/simdag/dax/dax_test.c index 3954c6b592..b7b2a7b96e 100644 --- a/examples/simdag/dax/dax_test.c +++ b/examples/simdag/dax/dax_test.c @@ -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 #include "simgrid/simdag.h" #include "xbt/log.h" #include diff --git a/examples/simdag/dot/dot_test.c b/examples/simdag/dot/dot_test.c index 37f825cde6..1cad6219ea 100644 --- a/examples/simdag/dot/dot_test.c +++ b/examples/simdag/dot/dot_test.c @@ -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 #include "simgrid/simdag.h" #include "xbt/log.h" #include diff --git a/examples/simdag/goal/goal_test.c b/examples/simdag/goal/goal_test.c index e44ceea289..23d774c50c 100644 --- a/examples/simdag/goal/goal_test.c +++ b/examples/simdag/goal/goal_test.c @@ -11,12 +11,8 @@ /* 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 -#include #include "simgrid/simdag.h" #include "xbt/log.h" -#include "xbt/ex.h" -#include #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(); diff --git a/examples/simdag/io/sd_io.c b/examples/simdag/io/sd_io.c index ed6897b4ac..a04c20b909 100644 --- a/examples/simdag/io/sd_io.c +++ b/examples/simdag/io/sd_io.c @@ -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 -#include #include #include "simgrid/simdag.h" -#include "xbt/log.h" -#include "xbt/ex.h" #ifdef HAVE_JEDULE #include "simgrid/jedule/jedule_sd_binding.h" diff --git a/examples/simdag/sd_avail.c b/examples/simdag/sd_avail.c index 653562eea5..f966a04741 100644 --- a/examples/simdag/sd_avail.c +++ b/examples/simdag/sd_avail.c @@ -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); diff --git a/examples/simdag/sd_comm_throttling.c b/examples/simdag/sd_comm_throttling.c index 99a6605c9e..fef44bca18 100644 --- a/examples/simdag/sd_comm_throttling.c +++ b/examples/simdag/sd_comm_throttling.c @@ -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 #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); diff --git a/examples/simdag/sd_fail.c b/examples/simdag/sd_fail.c index 7620ea337c..0bec7da11e 100644 --- a/examples/simdag/sd_fail.c +++ b/examples/simdag/sd_fail.c @@ -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); diff --git a/examples/simdag/sd_test.c b/examples/simdag/sd_test.c index 0c9d0654ef..02bbd3870b 100644 --- a/examples/simdag/sd_test.c +++ b/examples/simdag/sd_test.c @@ -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)); diff --git a/examples/simdag/sd_test2.c b/examples/simdag/sd_test2.c index 9904631218..6514f38eb3 100644 --- a/examples/simdag/sd_test2.c +++ b/examples/simdag/sd_test2.c @@ -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); diff --git a/examples/simdag/sd_typed_tasks_test.c b/examples/simdag/sd_typed_tasks_test.c index cd248090e3..f8421b2227 100644 --- a/examples/simdag/sd_typed_tasks_test.c +++ b/examples/simdag/sd_typed_tasks_test.c @@ -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); -- 2.20.1