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 SD_workstation_t workstation_list[1];
24 /* initialization of SD */
27 /* creation of the environment */
28 SD_create_environment("./faulty_host.xml");
30 /* creation of a single task that will poorly fail when the workstation
32 XBT_INFO("First test: COMP_SEQ task");
33 task = SD_task_create_comp_seq("Poor task", NULL, 2e10);
34 SD_task_watch(task, SD_FAILED);
35 SD_task_watch(task, SD_DONE);
37 XBT_INFO("Schedule task '%s' on workstation 'Faulty Host'",
38 SD_task_get_name(task));
40 SD_task_schedulel(task, 1, SD_workstation_get_by_name("Faulty Host"));
42 ret = SD_simulate(-1.0);
47 XBT_INFO("Task '%s' has failed. %.f flops remain to be done",
48 SD_task_get_name(task),
49 SD_task_get_remaining_amount(task));
51 XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'",
52 SD_task_get_name(task));
53 SD_task_unschedule(task);
54 SD_task_schedulel(task, 1, SD_workstation_get_by_name("Safe Host"));
56 XBT_INFO("Run the simulation again");
57 ret = SD_simulate(-1.0);
61 XBT_INFO("Task '%s' start time: %f, finish time: %f",
62 SD_task_get_name(task),
63 SD_task_get_start_time(task),
64 SD_task_get_finish_time(task));
66 SD_task_destroy(task);
69 XBT_INFO("Second test: NON TYPED task");
71 task = SD_task_create("Poor parallel task", NULL, 2e10);
72 SD_task_watch(task, SD_FAILED);
73 SD_task_watch(task, SD_DONE);
75 computation_amount[0] = 2e10;
77 XBT_INFO("Schedule task '%s' on workstation 'Faulty Host'",
78 SD_task_get_name(task));
80 workstation_list[0] = SD_workstation_get_by_name("Faulty Host");
81 SD_task_schedule(task, 1, workstation_list,
82 computation_amount, communication_amount,-1);
84 ret = SD_simulate(-1.0);
89 XBT_INFO("Task '%s' has failed. %.f flops remain to be done",
90 SD_task_get_name(task),
91 SD_task_get_remaining_amount(task));
93 XBT_INFO("let's unschedule task '%s' and reschedule it on the 'Safe Host'",
94 SD_task_get_name(task));
95 SD_task_unschedule(task);
97 workstation_list[0] = SD_workstation_get_by_name("Safe Host");
99 SD_task_schedule(task, 1, workstation_list,
100 computation_amount, communication_amount,-1);
102 XBT_INFO("Run the simulation again");
103 ret = SD_simulate(-1.0);
104 xbt_dynar_free(&ret);
107 XBT_INFO("Task '%s' start time: %f, finish time: %f",
108 SD_task_get_name(task),
109 SD_task_get_start_time(task),
110 SD_task_get_finish_time(task));
112 SD_task_destroy(task);