X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e673f975c63eb812ff26e1598684c2941859132a..eee4fd8a61935c3b7cbefe0768e040eeea1c9336:/examples/simdag/sd_comm_throttling.c diff --git a/examples/simdag/sd_comm_throttling.c b/examples/simdag/sd_comm_throttling.c index a9fb24f1dc..8bbcf9556c 100644 --- a/examples/simdag/sd_comm_throttling.c +++ b/examples/simdag/sd_comm_throttling.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2006, 2007, 2008, 2009, 2010. The SimGrid Team. +/* Copyright (c) 2006-2010, 2012-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 #include -#include "simdag/simdag.h" +#include "simgrid/simdag.h" #include "xbt/ex.h" #include "xbt/log.h" @@ -17,28 +17,23 @@ int main(int argc, char **argv) { unsigned int ctr; const char *platform_file; - const SD_workstation_t *workstations; + const sg_host_t *workstations; SD_task_t task, taskA, taskB, taskC, taskD, taskE; xbt_dynar_t changed_tasks; - SD_workstation_t workstation_list[4]; - /* initialization of SD */ SD_init(&argc, argv); /* xbt_log_control_set("sd.thres=debug"); */ - if (argc < 2) { - XBT_INFO("Usage: %s platform_file", argv[0]); - XBT_INFO("example: %s sd_platform.xml", argv[0]); - exit(1); - } + xbt_assert(argc > 1, "Usage: %s platform_file\n" + "\nExample: %s two_clusters.xml", argv[0], argv[0]); /* creation of the environment */ platform_file = argv[1]; SD_create_environment(platform_file); - workstations = SD_workstation_get_list(); + workstations = sg_host_list(); /* creation of some typed tasks and their dependencies */ /* chain of five tasks, three compute tasks with two data transfers */ @@ -68,14 +63,19 @@ int main(int argc, char **argv) XBT_INFO("Simulation stopped after %.4f seconds", SD_get_clock()); 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)); + SD_task_get_name(task), + SD_task_get_start_time(task), + SD_task_get_finish_time(task)); } /* let throttle the communication for taskD if its parent is SD_DONE */ - if (SD_task_get_state(taskC) == SD_DONE) - SD_task_set_rate(taskD, 0.5); + /* the bandwidth is 1.25e8, the data size is 1e7, and we want to throttle + * the bandwidth by a factor 2. the rate is then 1.25e8/(2*1e7)=6.25 + * Changing the rate is possible before the task execution starts (in SD_RUNNING + * state). + */ + if (SD_task_get_state(taskC) == SD_DONE && SD_task_get_state(taskD) < SD_RUNNING) + SD_task_set_rate(taskD, 6.25); } XBT_DEBUG("Destroying tasks...");