Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups in teshsuite/simdag/platforms, don't ask why
[simgrid.git] / teshsuite / simdag / incomplete / incomplete.c
1 /* Copyright (c) 2007-2012, 2014-2015. 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 "simgrid/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
30   const sg_host_t *workstation;
31
32   double communication_amount1 = 1e9;
33   double no_cost = 0.0;
34
35   /* initialization of SD */
36   SD_init(&argc, argv);
37
38   /* creation of the environment */
39   SD_create_environment(argv[1]);
40
41   /* creation of the tasks and their dependencies */
42   taskInit = SD_task_create("Init", NULL, 1.0);
43   taskA = SD_task_create("Task A", NULL, 1.0);
44   taskB = SD_task_create("Task B", NULL, 1.0);
45   taskC = SD_task_create("Task C", NULL, 1.0);
46   taskD = SD_task_create("Task D", NULL, 1.0);
47
48
49   /* scheduling parameters */
50
51   workstation = sg_host_list();
52
53   SD_task_dependency_add(NULL, NULL, taskInit, taskA);
54   SD_task_dependency_add(NULL, NULL, taskInit, taskB);
55   SD_task_dependency_add(NULL, NULL, taskC, taskD);
56
57   /* let's launch the simulation! */
58   SD_task_schedule(taskInit, 1, sg_host_list(), &no_cost,
59                    &no_cost, -1.0);
60   SD_task_schedule(taskA, 1, &workstation[0], &no_cost,
61                      &communication_amount1, -1.0);
62   SD_task_schedule(taskD, 1, &workstation[0], &no_cost,
63                      &communication_amount1, -1.0);
64
65
66   SD_simulate(-1.);
67   SD_task_destroy(taskA);
68   SD_task_destroy(taskB);
69   SD_task_destroy(taskC);
70   SD_task_destroy(taskD);
71   SD_task_destroy(taskInit);
72
73   XBT_INFO("Simulation time: %f", SD_get_clock());
74
75   SD_exit();
76   return 0;
77 }