Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
activate fortran attr tests
[simgrid.git] / teshsuite / simdag / basic3 / basic3.c
1 /* Copyright (c) 2007-2018. 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 "simgrid/simdag.h"
8 #include "xbt/log.h"
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic3, sd, "SimDag test basic3");
11
12 /* Basic SimDag Test 3
13  * Scenario:
14  *   - Create a chain of tasks (Init, A, Fin)
15  * Verify that the tasks are actually simulated in the right order.
16  */
17 int main(int argc, char **argv)
18 {
19   /* scheduling parameters */
20   double no_cost[] = { 0.0, 0.0, 0.0, 0.0 };
21
22   /* initialization of SD */
23   SD_init(&argc, argv);
24
25   /* creation of the environment */
26   SD_create_environment(argv[1]);
27
28   /* creation of the tasks and their dependencies */
29   SD_task_t taskInit = SD_task_create("Task Init", NULL, 1.0);
30   SD_task_t taskA = SD_task_create("Task A", NULL, 1.0);
31   SD_task_t taskFin = SD_task_create("Task Fin", NULL, 1.0);
32
33   SD_task_dependency_add(taskInit, taskA);
34   SD_task_dependency_add(taskA, taskFin);
35
36   sg_host_t *hosts = sg_host_list();
37   SD_task_schedule(taskInit, 1, hosts, no_cost, no_cost, -1.0);
38   SD_task_schedule(taskA, 2, hosts, no_cost, no_cost, -1.0);
39   SD_task_schedule(taskFin, 1, hosts, no_cost, no_cost, -1.0);
40   xbt_free(hosts);
41
42   /* let's launch the simulation! */
43   SD_simulate(-1.0);
44   SD_task_destroy(taskInit);
45   SD_task_destroy(taskA);
46   SD_task_destroy(taskFin);
47
48   XBT_INFO("Simulation time: %f", SD_get_clock());
49
50   return 0;
51 }