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) {
21 SD_task_t *changed_tasks;
23 const SD_workstation_t * hosts;
27 SD_task_t ParComp_wocomm;
28 SD_task_t IntraRedist;
29 SD_task_t ParComp_wcomm1;
30 SD_task_t InterRedist;
32 SD_task_t ParComp_wcomm2;
33 const double no_cost[] = {1.0, 1.0};
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,
66 sizeof(SD_workstation_t),nameCompareHosts);
68 /* creation of the tasks */
69 taskInit = SD_task_create("Initial",NULL,1.0);
70 PtoPComm1 = SD_task_create("PtoP Comm 1", NULL, 1.0);
71 PtoPComm2 = SD_task_create("PtoP Comm 2", NULL, 1.0);
72 ParComp_wocomm = SD_task_create("Par Comp without comm", NULL, 1.0);
73 IntraRedist = SD_task_create("intra redist", NULL, 1.0);
74 ParComp_wcomm1 = SD_task_create("Par Comp with comm 1", NULL, 1.0);
75 InterRedist = SD_task_create("inter redist", NULL, 1.0);
76 taskFinal = SD_task_create("Final",NULL,1.0);
77 ParComp_wcomm2 = SD_task_create("Par Comp with comm 2", NULL, 1.0);
80 /* creation of the dependencies */
81 SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm1);
82 SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm2);
83 SD_task_dependency_add(NULL, NULL, PtoPComm1, ParComp_wocomm);
84 SD_task_dependency_add(NULL, NULL, ParComp_wocomm, IntraRedist);
85 SD_task_dependency_add(NULL, NULL, IntraRedist, ParComp_wcomm1);
86 SD_task_dependency_add(NULL, NULL, ParComp_wcomm1, InterRedist);
87 SD_task_dependency_add(NULL, NULL, InterRedist, ParComp_wcomm2);
88 SD_task_dependency_add(NULL, NULL, ParComp_wcomm2, taskFinal);
89 SD_task_dependency_add(NULL, NULL, PtoPComm2, taskFinal);
92 /* scheduling parameters */
94 /* large point-to-point communication (0.1 sec duration) */
95 PtoPcomm1_hosts[0] = hosts[0];
96 PtoPcomm1_hosts[1] =hosts[1];
98 /* small point-to-point communication (0.01 sec duration) */
99 PtoPcomm2_hosts[0] = hosts[0];
100 PtoPcomm2_hosts[1] = hosts[2];
102 /* parallel task without intra communications (1 sec duration) */
103 ParComp_wocomm_table = xbt_new0(double,25);
106 ParComp_wocomm_hosts[i]=hosts[i];
109 /* redistribution within a cluster (small latencies) */
110 /* each host send (4*2.5Mb =) 10Mb */
111 /* bandwidth is shared between 5 flows (0.05sec duration) */
112 IntraRedist_cost = xbt_new0(double,5);
113 IntraRedist_table = xbt_new0(double,25);
117 IntraRedist_table[i*5+j] = 0.;
119 IntraRedist_table[i*5+j] = 312500.; /* 2.5Mb */
124 IntraRedist_hosts[i]=hosts[i];
127 /* parallel task with intra communications */
128 /* Computation domination (1 sec duration) */
129 ParComp_wcomm1_table = xbt_new0(double,25);
132 ParComp_wcomm1_hosts[i]=hosts[i];
138 ParComp_wcomm1_table[i*5+j] = 0.;
140 ParComp_wcomm1_table[i*5+j] = 312500.; /* 2.5Mb */
144 /* inter cluster redistribution (big latency on the backbone) */
145 /* (0.5sec duration without latency impact)*/
146 InterRedist_cost = xbt_new0(double,10);
147 InterRedist_table = xbt_new0(double,100);
149 InterRedist_table[i*10+i+5] = 1250000.; /* 10Mb */
152 /* parallel task with intra communications */
153 /* Communication domination (0.1 sec duration) */
155 ParComp_wcomm2_table = xbt_new0(double,25);
158 ParComp_wcomm2_hosts[i]=hosts[i+5];
164 ParComp_wcomm2_table[i*5+j] = 0.;
166 ParComp_wcomm2_table[i*5+j] = 625000.; /* 5Mb */
170 /* Sequential task */
173 /* scheduling the tasks */
174 SD_task_schedule(taskInit, 1, hosts, no_cost, no_cost, -1.0);
175 SD_task_schedule(PtoPComm1, 2, PtoPcomm1_hosts, no_cost, PtoPcomm1_table, -1.0);
176 SD_task_schedule(PtoPComm2, 2, PtoPcomm2_hosts, no_cost, PtoPcomm2_table, -1.0);
177 SD_task_schedule(ParComp_wocomm, 5, ParComp_wocomm_hosts, ParComp_wocomm_cost, ParComp_wocomm_table, -1.0);
178 SD_task_schedule(IntraRedist, 5, IntraRedist_hosts, IntraRedist_cost, IntraRedist_table, -1.0);
179 SD_task_schedule(ParComp_wcomm1, 5, ParComp_wcomm1_hosts, ParComp_wcomm1_cost, ParComp_wcomm1_table, -1.0);
180 SD_task_schedule(InterRedist, 10, hosts, InterRedist_cost, InterRedist_table, -1.0);
181 SD_task_schedule(ParComp_wcomm2, 5, ParComp_wcomm2_hosts, ParComp_wcomm2_cost, ParComp_wcomm2_table, -1.0);
182 SD_task_schedule(taskFinal, 1, &(hosts[9]), &final_cost, no_cost, -1.0);
184 /* let's launch the simulation! */
185 changed_tasks = SD_simulate(-1.0);
189 free(ParComp_wocomm_table);
190 free(IntraRedist_cost);
191 free(IntraRedist_table);
192 free(ParComp_wcomm1_table);
193 free(InterRedist_cost);
194 free(InterRedist_table);
195 free(ParComp_wcomm2_table);
197 SD_task_destroy(taskInit);
198 SD_task_destroy(PtoPComm1);
199 SD_task_destroy(PtoPComm2);
200 SD_task_destroy(ParComp_wocomm);
201 SD_task_destroy(IntraRedist);
202 SD_task_destroy(ParComp_wcomm1);
203 SD_task_destroy(InterRedist);
204 SD_task_destroy(ParComp_wcomm2);
205 SD_task_destroy(taskFinal);