1 /* Copyright (c) 2013-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
12 #include <simgrid/simdag.h>
17 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging for the current example");
19 static int name_compare_hosts(const void *n1, const void *n2)
22 sg_host_get_name(*(sg_host_t *) n1),
23 sg_host_get_name(*(sg_host_t *) n2)
27 static void scheduleDAX(xbt_dynar_t dax)
32 const sg_host_t *ws_list = sg_host_list();
33 int totalHosts = sg_host_count();
34 qsort((void *) ws_list, totalHosts, sizeof(sg_host_t), name_compare_hosts);
37 xbt_dynar_foreach(dax, cursor, task) {
38 if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
39 if (!strcmp(SD_task_get_name(task), "end")
40 || !strcmp(SD_task_get_name(task), "root")) {
41 XBT_INFO("Scheduling %s to node: %s", SD_task_get_name(task),
42 sg_host_get_name(ws_list[0]));
43 SD_task_schedulel(task, 1, ws_list[0]);
45 XBT_INFO("Scheduling %s to node: %s", SD_task_get_name(task),
46 sg_host_get_name(ws_list[(cursor) % totalHosts]));
47 SD_task_schedulel(task, 1, ws_list[(cursor) % totalHosts]);
53 static xbt_dynar_t initDynamicThrottling(int argc, char *argv[])
57 "Error on parameters.\n"
58 "Usage: %s <XML platform file> <DAX file>\n", argv[0]);
60 FILE *testFile = fopen(argv[1], "r");
61 xbt_assert(testFile, "Cannot open platform file %s.\n", argv[1]);
62 testFile = fopen(argv[2], "r");
63 xbt_assert(testFile, "Cannot open DAX file %s.\n", argv[2]);
65 SD_create_environment(argv[1]);
66 xbt_dynar_t dax = SD_daxload(argv[2]);
69 XBT_INFO("Scheduling DAX...");
71 XBT_INFO("DAX scheduled");
73 XBT_INFO("Simulation done.");
78 int main(int argc, char *argv[])
81 /* Start process... */
82 xbt_dynar_t dax = initDynamicThrottling(argc, argv);
85 while (!xbt_dynar_is_empty(dax)) {
86 SD_task_t task = xbt_dynar_pop_as(dax, SD_task_t);
87 SD_task_destroy(task);