Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Well, actually, yes, top_srcdir is supposed to be a relative path. But since it's...
[simgrid.git] / teshsuite / simdag / network / test_reinit_costs.c
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include "simdag/simdag.h"
5
6 /*
7  * SimDag
8  * Computation tests
9  * Copyright (C) 2007 
10  * Sascha Hunold, Frederic Suter
11  */
12
13 /*
14  * This test checks if the reinitialization of
15  * surf works properly. 
16  * 1 test: empty task, reinit, empty task
17  * 2 test: comm cost task, reinit, empty task
18  * 
19  * output should be:
20  * 0
21  * 1.5
22  */
23
24 static SD_task_t create_empty_cost_root() {
25         double no_cost[] = { 0.0 };
26         SD_task_t root;
27
28         root = SD_task_create("Root", NULL, 1.0);
29         SD_task_schedule(root, 1, SD_workstation_get_list(), no_cost, no_cost, -1.0);
30
31         return root;
32 }
33
34 static void zero_cost_test(int *argc, char *argv[]) {
35         double time;
36         SD_task_t task;
37         
38         SD_init(argc, argv);
39         SD_create_environment(argv[1]);
40         
41         task = create_empty_cost_root();
42         SD_simulate(-1.0);
43         SD_task_destroy(task);
44         
45         SD_application_reinit();
46         
47         task = create_empty_cost_root();
48         SD_simulate(-1.0);
49         SD_task_destroy(task);
50         
51         SD_simulate(-1.0);
52         
53         time = SD_get_clock();
54         printf("%g\n", time);
55         fflush(stdout);
56         
57         SD_exit();
58 }
59
60 static SD_task_t create_root_with_costs() {
61         double comp_cost[] = { 0.0, 0.0 };
62         double comm_cost[] = { 0.0, 1.0, 0.0, 0.0 };
63         SD_task_t root;
64
65         root = SD_task_create("Root", NULL, 1.0);
66         SD_task_schedule(root, 2, SD_workstation_get_list(), comp_cost, comm_cost,
67                         -1.0);  
68         
69         return root;
70 }
71
72 static void zero_cost_test2(int *argc, char *argv[]) {
73         double time;
74         SD_task_t task;
75         
76         SD_init(argc, argv);
77         SD_create_environment(argv[1]);
78         
79         task = create_root_with_costs();
80         SD_simulate(-1.0);
81         SD_task_destroy(task);
82         
83         SD_application_reinit();
84         
85         task = create_empty_cost_root();
86         SD_simulate(-1.0);
87         SD_task_destroy(task);
88         
89         SD_simulate(-1.0);
90         
91         time = SD_get_clock();
92         printf("%g\n", time);
93         fflush(stdout);
94         
95         SD_exit();
96 }
97
98 int main(int argc, char **argv) {
99
100   zero_cost_test(&argc, argv);
101
102   zero_cost_test2(&argc, argv);
103
104   return 0;
105 }
106