Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cmakelists cleanup
[simgrid.git] / teshsuite / simdag / basic6.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/asserts.h"
11 #include "xbt/log.h"
12
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic6, sd, "SimDag test basic6");
14 /* test scheduling 2 tasks at the same time without artificial dependencies */
15
16 /* Basic SimDag Test 6
17  * Scenario:
18  *   - Schedule two parallel tasks concurrently on a P2P platform
19  *   - Hosts computes 1B per second
20  * Computing power is shared between tasks.
21  * Simulated time should be:
22  *          1/(1/2) = 2 seconds
23  */
24
25 int main(int argc, char **argv)
26 {
27   double comm_cost[] = { 0.0, 0.0, 0.0, 0.0 };
28   double comp_cost[] = { 1.0 };
29   SD_task_t taskA, taskB;
30   xbt_dynar_t ret;
31
32   SD_init(&argc, argv);
33   SD_create_environment(argv[1]);
34
35   taskA = SD_task_create("Task A", NULL, 1.0);
36   taskB = SD_task_create("Task B", NULL, 1.0);
37
38   SD_task_schedule(taskA, 1, SD_workstation_get_list(), comp_cost,
39                    comm_cost, -1.0);
40   SD_task_schedule(taskB, 1, SD_workstation_get_list(), comp_cost,
41                    comm_cost, -1.0);
42
43   ret = SD_simulate(-1.0);
44   xbt_assert(xbt_dynar_length(ret) == 2,
45       "I was expecting the terminaison of 2 tasks, but I got %lu instead",
46       xbt_dynar_length(ret));
47   xbt_dynar_free(&ret);
48   SD_task_destroy(taskA);
49   SD_task_destroy(taskB);
50
51   XBT_INFO("Simulation time: %f", SD_get_clock());
52
53   SD_exit();
54   return 0;
55 }