1 /* Copyright (c) 2006, 2007, 2008, 2009, 2010. 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. */
9 #include "simdag/simdag.h"
13 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_fail,
14 "Logging specific to this SimDag example");
16 int main(int argc, char **argv)
19 double computation_amount[1];
20 double communication_amount[2] = { 0 };
21 SD_workstation_t workstation_list[1];
22 /* initialization of SD */
25 /* creation of the environment */
26 SD_create_environment("./faulty_host.xml");
28 /* creation of a single task that will poorly fail when the workstation
30 XBT_INFO("First test: COMP_SEQ task");
31 task = SD_task_create_comp_seq("Poor task", NULL, 2e10);
33 XBT_INFO("Schedule task '%s' on workstation 'Faulty Host'",
34 SD_task_get_name(task));
36 SD_task_schedulel(task, 1, SD_workstation_get_by_name("Faulty Host"));
42 XBT_INFO("Task '%s' has failed. %.f flops remain to be done",
43 SD_task_get_name(task),
44 SD_task_get_remaining_amount(task));
46 XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'",
47 SD_task_get_name(task));
48 SD_task_unschedule(task);
49 SD_task_schedulel(task, 1, SD_workstation_get_by_name("Safe Host"));
51 XBT_INFO("Run the simulation again");
55 XBT_INFO("Task '%s' start time: %f, finish time: %f",
56 SD_task_get_name(task),
57 SD_task_get_start_time(task),
58 SD_task_get_finish_time(task));
60 SD_task_destroy(task);
63 XBT_INFO("Second test: NON TYPED task");
65 task = SD_task_create("Poor parallel task", NULL, 2e10);
66 computation_amount[0] = 2e10;
68 XBT_INFO("Schedule task '%s' on workstation 'Faulty Host'",
69 SD_task_get_name(task));
71 workstation_list[0] = SD_workstation_get_by_name("Faulty Host");
72 SD_task_schedule(task, 1, workstation_list,
73 computation_amount, communication_amount,-1);
79 XBT_INFO("Task '%s' has failed. %.f flops remain to be done",
80 SD_task_get_name(task),
81 SD_task_get_remaining_amount(task));
83 XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'",
84 SD_task_get_name(task));
85 SD_task_unschedule(task);
87 workstation_list[0] = SD_workstation_get_by_name("Safe Host");
89 SD_task_schedule(task, 1, workstation_list,
90 computation_amount, communication_amount,-1);
92 XBT_INFO("Run the simulation again");
96 XBT_INFO("Task '%s' start time: %f, finish time: %f",
97 SD_task_get_name(task),
98 SD_task_get_start_time(task),
99 SD_task_get_finish_time(task));
101 SD_task_destroy(task);