5 #include "simdag/simdag.h"
8 #include "xbt/sysdep.h" /* calloc, printf */
10 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test,
11 "Logging specific to this SimDag example");
13 static int nameCompareHosts(const void *n1, const void *n2)
15 return strcmp(SD_workstation_get_name(*((SD_workstation_t *) n1)),
16 SD_workstation_get_name(*((SD_workstation_t *) n2)));
19 int main(int argc, char **argv)
22 SD_task_t *changed_tasks;
24 const SD_workstation_t *hosts;
28 SD_task_t ParComp_wocomm;
29 SD_task_t IntraRedist;
30 SD_task_t ParComp_wcomm1;
31 SD_task_t InterRedist;
33 SD_task_t ParComp_wcomm2;
34 SD_workstation_t PtoPcomm1_hosts[2];
35 SD_workstation_t PtoPcomm2_hosts[2];
36 double PtoPcomm1_table[] = { 0, 12500000, 0, 0 }; /* 100Mb */
37 double PtoPcomm2_table[] = { 0, 1250000, 0, 0 }; /* 10Mb */
38 double ParComp_wocomm_cost[] = { 1e+9, 1e+9, 1e+9, 1e+9, 1e+9 }; /* 1 Gflop per Proc */
39 double *ParComp_wocomm_table;
40 SD_workstation_t ParComp_wocomm_hosts[5];
41 double *IntraRedist_cost;
42 double *IntraRedist_table;
43 SD_workstation_t IntraRedist_hosts[5];
44 double ParComp_wcomm1_cost[] = { 1e+9, 1e+9, 1e+9, 1e+9, 1e+9 }; /* 1 Gflop per Proc */
45 double *ParComp_wcomm1_table;
46 SD_workstation_t ParComp_wcomm1_hosts[5];
47 double *InterRedist_cost;
48 double *InterRedist_table;
49 double ParComp_wcomm2_cost[] = { 1e+8, 1e+8, 1e+8, 1e+8, 1e+8 }; /* 1 Gflop per Proc (0.02sec duration) */
50 SD_workstation_t ParComp_wcomm2_hosts[5];
51 double final_cost = 5e+9;
52 double *ParComp_wcomm2_table;
54 /* initialisation of SD */
57 /* creation of the environment */
58 SD_create_environment(argv[1]);
60 /* getting platform infos */
61 n_hosts = SD_workstation_get_number();
62 hosts = SD_workstation_get_list();
64 /* sorting hosts by hostname */
65 qsort((void *) hosts, n_hosts, sizeof(SD_workstation_t), nameCompareHosts);
67 /* creation of the tasks */
68 taskInit = SD_task_create("Initial", NULL, 1.0);
69 PtoPComm1 = SD_task_create("PtoP Comm 1", NULL, 1.0);
70 PtoPComm2 = SD_task_create("PtoP Comm 2", NULL, 1.0);
71 ParComp_wocomm = SD_task_create("Par Comp without comm", NULL, 1.0);
72 IntraRedist = SD_task_create("intra redist", NULL, 1.0);
73 ParComp_wcomm1 = SD_task_create("Par Comp with comm 1", NULL, 1.0);
74 InterRedist = SD_task_create("inter redist", NULL, 1.0);
75 taskFinal = SD_task_create("Final", NULL, 1.0);
76 ParComp_wcomm2 = SD_task_create("Par Comp with comm 2", NULL, 1.0);
79 /* creation of the dependencies */
80 SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm1);
81 SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm2);
82 SD_task_dependency_add(NULL, NULL, PtoPComm1, ParComp_wocomm);
83 SD_task_dependency_add(NULL, NULL, ParComp_wocomm, IntraRedist);
84 SD_task_dependency_add(NULL, NULL, IntraRedist, ParComp_wcomm1);
85 SD_task_dependency_add(NULL, NULL, ParComp_wcomm1, InterRedist);
86 SD_task_dependency_add(NULL, NULL, InterRedist, ParComp_wcomm2);
87 SD_task_dependency_add(NULL, NULL, ParComp_wcomm2, taskFinal);
88 SD_task_dependency_add(NULL, NULL, PtoPComm2, taskFinal);
91 /* scheduling parameters */
93 /* large point-to-point communication (0.1 sec duration) */
94 PtoPcomm1_hosts[0] = hosts[0];
95 PtoPcomm1_hosts[1] = hosts[1];
97 /* small point-to-point communication (0.01 sec duration) */
98 PtoPcomm2_hosts[0] = hosts[0];
99 PtoPcomm2_hosts[1] = hosts[2];
101 /* parallel task without intra communications (1 sec duration) */
102 ParComp_wocomm_table = xbt_new0(double, 25);
104 for (i = 0; i < 5; i++) {
105 ParComp_wocomm_hosts[i] = hosts[i];
108 /* redistribution within a cluster (small latencies) */
109 /* each host send (4*2.5Mb =) 10Mb */
110 /* bandwidth is shared between 5 flows (0.05sec duration) */
111 IntraRedist_cost = xbt_new0(double, 5);
112 IntraRedist_table = xbt_new0(double, 25);
113 for (i = 0; i < 5; i++) {
114 for (j = 0; j < 5; j++) {
116 IntraRedist_table[i * 5 + j] = 0.;
118 IntraRedist_table[i * 5 + j] = 312500.; /* 2.5Mb */
122 for (i = 0; i < 5; i++) {
123 IntraRedist_hosts[i] = hosts[i];
126 /* parallel task with intra communications */
127 /* Computation domination (1 sec duration) */
128 ParComp_wcomm1_table = xbt_new0(double, 25);
130 for (i = 0; i < 5; i++) {
131 ParComp_wcomm1_hosts[i] = hosts[i];
134 for (i = 0; i < 5; i++) {
135 for (j = 0; j < 5; j++) {
137 ParComp_wcomm1_table[i * 5 + j] = 0.;
139 ParComp_wcomm1_table[i * 5 + j] = 312500.; /* 2.5Mb */
143 /* inter cluster redistribution (big latency on the backbone) */
144 /* (0.5sec duration without latency impact) */
145 InterRedist_cost = xbt_new0(double, 10);
146 InterRedist_table = xbt_new0(double, 100);
147 for (i = 0; i < 5; i++) {
148 InterRedist_table[i * 10 + i + 5] = 1250000.; /* 10Mb */
151 /* parallel task with intra communications */
152 /* Communication domination (0.1 sec duration) */
154 ParComp_wcomm2_table = xbt_new0(double, 25);
156 for (i = 0; i < 5; i++) {
157 ParComp_wcomm2_hosts[i] = hosts[i + 5];
160 for (i = 0; i < 5; i++) {
161 for (j = 0; j < 5; j++) {
163 ParComp_wcomm2_table[i * 5 + j] = 0.;
165 ParComp_wcomm2_table[i * 5 + j] = 625000.; /* 5Mb */
169 /* Sequential task */
172 /* scheduling the tasks */
173 SD_task_schedule(taskInit, 1, hosts, SD_SCHED_NO_COST, SD_SCHED_NO_COST, -1.0);
174 SD_task_schedule(PtoPComm1, 2, PtoPcomm1_hosts, SD_SCHED_NO_COST, PtoPcomm1_table,
176 SD_task_schedule(PtoPComm2, 2, PtoPcomm2_hosts, SD_SCHED_NO_COST, PtoPcomm2_table,
178 SD_task_schedule(ParComp_wocomm, 5, ParComp_wocomm_hosts,
179 ParComp_wocomm_cost, ParComp_wocomm_table, -1.0);
180 SD_task_schedule(IntraRedist, 5, IntraRedist_hosts, IntraRedist_cost,
181 IntraRedist_table, -1.0);
182 SD_task_schedule(ParComp_wcomm1, 5, ParComp_wcomm1_hosts,
183 ParComp_wcomm1_cost, ParComp_wcomm1_table, -1.0);
184 SD_task_schedule(InterRedist, 10, hosts, InterRedist_cost,
185 InterRedist_table, -1.0);
186 SD_task_schedule(ParComp_wcomm2, 5, ParComp_wcomm2_hosts,
187 ParComp_wcomm2_cost, ParComp_wcomm2_table, -1.0);
188 SD_task_schedule(taskFinal, 1, &(hosts[9]), &final_cost, SD_SCHED_NO_COST, -1.0);
190 /* let's launch the simulation! */
191 changed_tasks = SD_simulate(-1.0);
195 free(ParComp_wocomm_table);
196 free(IntraRedist_cost);
197 free(IntraRedist_table);
198 free(ParComp_wcomm1_table);
199 free(InterRedist_cost);
200 free(InterRedist_table);
201 free(ParComp_wcomm2_table);
203 SD_task_destroy(taskInit);
204 SD_task_destroy(PtoPComm1);
205 SD_task_destroy(PtoPComm2);
206 SD_task_destroy(ParComp_wocomm);
207 SD_task_destroy(IntraRedist);
208 SD_task_destroy(ParComp_wcomm1);
209 SD_task_destroy(InterRedist);
210 SD_task_destroy(ParComp_wcomm2);
211 SD_task_destroy(taskFinal);