1 /* Copyright (c) 2006-2010, 2012-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. */
9 #include "simgrid/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 sg_host_t workstation_list[1];
23 /* initialization of SD */
26 /* creation of the environment */
27 SD_create_environment("./faulty_host.xml");
29 /* creation of a single task that will poorly fail when the workstation
31 XBT_INFO("First test: COMP_SEQ task");
32 task = SD_task_create_comp_seq("Poor task", NULL, 2e10);
33 SD_task_watch(task, SD_FAILED);
34 SD_task_watch(task, SD_DONE);
36 XBT_INFO("Schedule task '%s' on workstation 'Faulty Host'",
37 SD_task_get_name(task));
39 SD_task_schedulel(task, 1, sg_host_by_name("Faulty Host"));
45 XBT_INFO("Task '%s' has failed. %.f flops remain to be done",
46 SD_task_get_name(task),
47 SD_task_get_remaining_amount(task));
49 XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'",
50 SD_task_get_name(task));
51 SD_task_unschedule(task);
52 SD_task_schedulel(task, 1, sg_host_by_name("Safe Host"));
54 XBT_INFO("Run the simulation again");
58 XBT_INFO("Task '%s' start time: %f, finish time: %f",
59 SD_task_get_name(task),
60 SD_task_get_start_time(task),
61 SD_task_get_finish_time(task));
63 SD_task_destroy(task);
66 XBT_INFO("Second test: NON TYPED task");
68 task = SD_task_create("Poor parallel task", NULL, 2e10);
69 SD_task_watch(task, SD_FAILED);
70 SD_task_watch(task, SD_DONE);
72 computation_amount[0] = 2e10;
74 XBT_INFO("Schedule task '%s' on workstation 'Faulty Host'",
75 SD_task_get_name(task));
77 workstation_list[0] = sg_host_by_name("Faulty Host");
78 SD_task_schedule(task, 1, workstation_list,
79 computation_amount, communication_amount,-1);
85 XBT_INFO("Task '%s' has failed. %.f flops remain to be done",
86 SD_task_get_name(task),
87 SD_task_get_remaining_amount(task));
89 XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'",
90 SD_task_get_name(task));
91 SD_task_unschedule(task);
93 workstation_list[0] = sg_host_by_name("Safe Host");
95 SD_task_schedule(task, 1, workstation_list,
96 computation_amount, communication_amount,-1);
98 XBT_INFO("Run the simulation again");
102 XBT_INFO("Task '%s' start time: %f, finish time: %f",
103 SD_task_get_name(task),
104 SD_task_get_start_time(task),
105 SD_task_get_finish_time(task));
107 SD_task_destroy(task);