Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use brand new attibute: symmetrical="YES"
[simgrid.git] / teshsuite / simdag / network / test_reinit_costs.c
1 /* Computation tests                                                        */
2
3 /* Copyright (c) 2007, 2009-2011, 2013-2015. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 #include "simgrid/simdag.h"
13
14 /*
15  * This test checks if the reinitialization of
16  * surf works properly. 
17  * 1 test: empty task, reinit, empty task
18  * 2 test: comm cost task, reinit, empty task
19  * 
20  * output should be:
21  * 0
22  * 1.5
23  */
24
25 static SD_task_t create_empty_cost_root()
26 {
27   double no_cost[] = { 0.0 };
28   SD_task_t root;
29
30   root = SD_task_create("Root", NULL, 1.0);
31   SD_task_schedule(root, 1, sg_host_list(), no_cost, no_cost,
32                    -1.0);
33
34   return root;
35 }
36
37 static void zero_cost_test(int *argc, char *argv[])
38 {
39   double time;
40   SD_task_t task;
41
42   SD_init(argc, argv);
43   SD_create_environment(argv[1]);
44
45   task = create_empty_cost_root();
46   SD_simulate(-1.0);
47   SD_task_destroy(task);
48
49   SD_application_reinit();
50
51   task = create_empty_cost_root();
52   SD_simulate(-1.0);
53   SD_task_destroy(task);
54
55   SD_simulate(-1.0);
56
57   time = SD_get_clock();
58   printf("%g\n", time);
59   fflush(stdout);
60
61   SD_exit();
62 }
63
64 static SD_task_t create_root_with_costs()
65 {
66   double comp_cost[] = { 0.0, 0.0 };
67   double comm_cost[] = { 0.0, 1.0, 0.0, 0.0 };
68   SD_task_t root;
69
70   root = SD_task_create("Root", NULL, 1.0);
71   SD_task_schedule(root, 2, sg_host_list(), comp_cost,
72                    comm_cost, -1.0);
73
74   return root;
75 }
76
77 static void zero_cost_test2(int *argc, char *argv[])
78 {
79   double time;
80   SD_task_t task;
81
82   SD_init(argc, argv);
83   SD_create_environment(argv[1]);
84
85   task = create_root_with_costs();
86   SD_simulate(-1.0);
87   SD_task_destroy(task);
88
89   SD_application_reinit();
90
91   task = create_empty_cost_root();
92   SD_simulate(-1.0);
93   SD_task_destroy(task);
94
95   SD_simulate(-1.0);
96
97   time = SD_get_clock();
98   printf("%g\n", time);
99   fflush(stdout);
100
101   SD_exit();
102 }
103
104 int main(int argc, char **argv)
105 {
106
107   zero_cost_test(&argc, argv);
108
109   zero_cost_test2(&argc, argv);
110
111   return 0;
112 }