Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : remove obsolete example
[simgrid.git] / teshsuite / simdag / incomplete.c
1 /* Copyright (c) 2007-2012. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "simdag/simdag.h"
10 #include "xbt/log.h"
11
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(incomplete, sd, "SimDag incomplete test");
13
14 /* SimDag Incomplete Test
15  * Scenario:
16  *   - Create a bunch of tasks
17  *   - schedule only a subset of them (init, A and D)
18  *   - run the simulation
19  *   - Verify that we detect which tasks are not scheduled and show their state.
20  * The scheduled task A sends 1GB. Simulation time should be
21  *          1e9/1.25e8 + 1e-4 = 8.0001 seconds
22  * Task D is scheduled but depends on unscheduled task C.
23  */
24 int main(int argc, char **argv)
25 {
26
27   SD_task_t taskInit;
28   SD_task_t taskA, taskB, taskC, taskD;
29   xbt_dynar_t ret;
30
31   const SD_workstation_t *workstation;
32
33   double communication_amount1 = 1e9;
34   double no_cost = 0.0;
35
36   /* initialization of SD */
37   SD_init(&argc, argv);
38
39   /* creation of the environment */
40   SD_create_environment(argv[1]);
41
42   /* creation of the tasks and their dependencies */
43   taskInit = SD_task_create("Init", NULL, 1.0);
44   taskA = SD_task_create("Task A", NULL, 1.0);
45   taskB = SD_task_create("Task B", NULL, 1.0);
46   taskC = SD_task_create("Task C", NULL, 1.0);
47   taskD = SD_task_create("Task D", NULL, 1.0);
48
49
50   /* scheduling parameters */
51
52   workstation = SD_workstation_get_list();
53
54   SD_task_dependency_add(NULL, NULL, taskInit, taskA);
55   SD_task_dependency_add(NULL, NULL, taskInit, taskB);
56   SD_task_dependency_add(NULL, NULL, taskC, taskD);
57
58   /* let's launch the simulation! */
59   SD_task_schedule(taskInit, 1, SD_workstation_get_list(), &no_cost,
60                    &no_cost, -1.0);
61   SD_task_schedule(taskA, 1, &workstation[0], &no_cost,
62                      &communication_amount1, -1.0);
63   SD_task_schedule(taskD, 1, &workstation[0], &no_cost,
64                      &communication_amount1, -1.0);
65
66
67   ret = SD_simulate(-1.);
68   xbt_dynar_free(&ret);
69   SD_task_destroy(taskA);
70   SD_task_destroy(taskB);
71   SD_task_destroy(taskC);
72   SD_task_destroy(taskD);
73   SD_task_destroy(taskInit);
74
75   XBT_INFO("Simulation time: %f", SD_get_clock());
76
77   SD_exit();
78   return 0;
79 }