5 #include "simdag/simdag.h"
8 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test,
9 "Logging specific to this SimDag example");
11 static int nameCompareHosts(const void *n1, const void *n2)
13 return strcmp(SD_workstation_get_name(*((SD_workstation_t *)n1)),
14 SD_workstation_get_name(*((SD_workstation_t *)n2)));
17 int main(int argc, char **argv) {
19 SD_task_t *changed_tasks;
21 /* initialisation of SD */
24 /* creation of the environment */
25 SD_create_environment(argv[1]);
27 /* getting platform infos */
28 int n_hosts = SD_workstation_get_number();
29 const SD_workstation_t * hosts= SD_workstation_get_list();
31 /* sorting hosts by hostname */
32 qsort((void *)hosts,n_hosts,
33 sizeof(SD_workstation_t),nameCompareHosts);
35 /* creation of the tasks */
36 SD_task_t taskInit = SD_task_create("Initial",NULL,1.0);
37 SD_task_t PtoPComm1 = SD_task_create("PtoP Comm 1", NULL, 1.0);
38 SD_task_t PtoPComm2 = SD_task_create("PtoP Comm 2", NULL, 1.0);
39 SD_task_t ParComp_wocomm = SD_task_create("Par Comp without comm", NULL, 1.0);
40 SD_task_t IntraRedist = SD_task_create("intra redist", NULL, 1.0);
41 SD_task_t ParComp_wcomm1 = SD_task_create("Par Comp with comm 1", NULL, 1.0);
42 SD_task_t InterRedist = SD_task_create("inter redist", NULL, 1.0);
43 SD_task_t taskFinal = SD_task_create("Final",NULL,1.0);
44 SD_task_t ParComp_wcomm2 = SD_task_create("Par Comp with comm 2", NULL, 1.0);
46 /* creation of the dependencies */
47 SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm1);
48 SD_task_dependency_add(NULL, NULL, taskInit, PtoPComm2);
49 SD_task_dependency_add(NULL, NULL, PtoPComm1, ParComp_wocomm);
50 SD_task_dependency_add(NULL, NULL, ParComp_wocomm, IntraRedist);
51 SD_task_dependency_add(NULL, NULL, IntraRedist, ParComp_wcomm1);
52 SD_task_dependency_add(NULL, NULL, ParComp_wcomm1, InterRedist);
53 SD_task_dependency_add(NULL, NULL, InterRedist, ParComp_wcomm2);
54 SD_task_dependency_add(NULL, NULL, ParComp_wcomm2, taskFinal);
55 SD_task_dependency_add(NULL, NULL, PtoPComm2, taskFinal);
57 /* scheduling parameters */
59 const double no_cost[] = {1.0, 1.0};
61 /* large point-to-point communication (0.1 sec duration) */
62 double PtoPcomm1_table[] = { 0, 12500000, 0, 0 }; /* 100Mb */
63 SD_workstation_t PtoPcomm1_hosts[] = {hosts[0],hosts[1]};
65 /* small point-to-point communication (0.01 sec duration) */
66 double PtoPcomm2_table[] = { 0, 1250000, 0, 0 }; /* 10Mb */
67 SD_workstation_t PtoPcomm2_hosts[] = {hosts[0],hosts[2]};
69 /* parallel task without intra communications (1 sec duration) */
70 double ParComp_wocomm_cost[] = {1e+9,1e+9,1e+9,1e+9,1e+9}; /* 1 Gflop per Proc */
71 double *ParComp_wocomm_table = (double*) calloc (25, sizeof(double));
72 SD_workstation_t ParComp_wocomm_hosts[5];
74 ParComp_wocomm_hosts[i]=hosts[i];
77 /* redistribution within a cluster (small latencies) */
78 /* each host send (4*2.5Mb =) 10Mb */
79 /* bandwidth is shared between 5 flows (0.05sec duration) */
80 double *IntraRedist_cost = (double*) calloc (5, sizeof(double));
81 double *IntraRedist_table = (double*) calloc (25, sizeof(double));
85 IntraRedist_table[i*5+j] = 0.;
87 IntraRedist_table[i*5+j] = 312500.; /* 2.5Mb */
91 SD_workstation_t IntraRedist_hosts[5];
93 IntraRedist_hosts[i]=hosts[i];
96 /* parallel task with intra communications */
97 /* Computation domination (1 sec duration) */
98 double ParComp_wcomm1_cost[] = {1e+9,1e+9,1e+9,1e+9,1e+9}; /* 1 Gflop per Proc */
99 double *ParComp_wcomm1_table = (double*) calloc (25, sizeof(double));
100 SD_workstation_t ParComp_wcomm1_hosts[5];
102 ParComp_wcomm1_hosts[i]=hosts[i];
108 ParComp_wcomm1_table[i*5+j] = 0.;
110 ParComp_wcomm1_table[i*5+j] = 312500.; /* 2.5Mb */
114 /* inter cluster redistribution (big latency on the backbone) */
115 /* (0.5sec duration without latency impact)*/
116 double *InterRedist_cost = (double*) calloc (10, sizeof(double));
117 double *InterRedist_table = (double*) calloc (100, sizeof(double));
119 InterRedist_table[i*10+i+5] = 1250000.; /* 10Mb */
122 /* parallel task with intra communications */
123 /* Communication domination (0.1 sec duration) */
124 double ParComp_wcomm2_cost[] = {1e+8,1e+8,1e+8,1e+8,1e+8}; /* 1 Gflop per Proc (0.02sec duration) */
125 double *ParComp_wcomm2_table = (double*) calloc (25, sizeof(double));
126 SD_workstation_t ParComp_wcomm2_hosts[5];
128 ParComp_wcomm2_hosts[i]=hosts[i+5];
134 ParComp_wcomm2_table[i*5+j] = 0.;
136 ParComp_wcomm2_table[i*5+j] = 625000.; /* 5Mb */
140 /* Sequential task */
141 double final_cost = 5e+9;
143 /* scheduling the tasks */
144 SD_task_schedule(taskInit, 1, hosts, no_cost, no_cost, -1.0);
145 SD_task_schedule(PtoPComm1, 2, PtoPcomm1_hosts, no_cost, PtoPcomm1_table, -1.0);
146 SD_task_schedule(PtoPComm2, 2, PtoPcomm2_hosts, no_cost, PtoPcomm2_table, -1.0);
147 SD_task_schedule(ParComp_wocomm, 5, ParComp_wocomm_hosts, ParComp_wocomm_cost, ParComp_wocomm_table, -1.0);
148 SD_task_schedule(IntraRedist, 5, IntraRedist_hosts, IntraRedist_cost, IntraRedist_table, -1.0);
149 SD_task_schedule(ParComp_wcomm1, 5, ParComp_wcomm1_hosts, ParComp_wcomm1_cost, ParComp_wcomm1_table, -1.0);
150 SD_task_schedule(InterRedist, 10, hosts, InterRedist_cost, InterRedist_table, -1.0);
151 SD_task_schedule(ParComp_wcomm2, 5, ParComp_wcomm2_hosts, ParComp_wcomm2_cost, ParComp_wcomm2_table, -1.0);
152 SD_task_schedule(taskFinal, 1, &(hosts[9]), &final_cost, no_cost, -1.0);
154 /* let's launch the simulation! */
155 changed_tasks = SD_simulate(-1.0);
159 free(ParComp_wocomm_table);
160 free(IntraRedist_cost);
161 free(IntraRedist_table);
162 free(ParComp_wcomm1_table);
163 free(InterRedist_cost);
164 free(InterRedist_table);
165 free(ParComp_wcomm2_table);
167 SD_task_destroy(taskInit);
168 SD_task_destroy(PtoPComm1);
169 SD_task_destroy(PtoPComm2);
170 SD_task_destroy(ParComp_wocomm);
171 SD_task_destroy(IntraRedist);
172 SD_task_destroy(ParComp_wcomm1);
173 SD_task_destroy(InterRedist);
174 SD_task_destroy(ParComp_wcomm2);
175 SD_task_destroy(taskFinal);