7 #include "mixtesim_prototypes.h"
8 #include "list_scheduling.h"
10 #include "simdag/simdag.h"
13 XBT_LOG_NEW_DEFAULT_CATEGORY(mixtesim,
14 "Logging specific to this SimDag example");
16 /* static int createSimgridResources(); */
17 static int createSimgridTasks();
20 /*extern Link local_link;*/
22 int main(int argc, char **argv) {
25 SD_task_t *changed_tasks;
28 /* xbt_log_control_set("sd.thres=debug"); */
29 /* xbt_log_control_set("sd_kernel.thres=debug"); */
30 /* xbt_log_control_set("surf_kernel.thres=debug"); */
31 /* xbt_log_control_set("mixtesim.thres=debug"); */
35 printf("Usage: %s xml_platform_file dagfile ", argv[0]);
36 printf("example: %s gridfile.xml dagfile", argv[0]);
40 /* initialisation of SD */
43 /* creation of the environment */
44 platform_file = argv[1];
45 SD_create_environment(platform_file);
48 dag = parseDAGFile(argv[2]);
51 allocateNodeAttributes(dag);
52 allocateHostAttributes();
54 /* create Simgrid objects */
55 createSimgridObjects();
59 /* not recommanded with big DAGs! */
62 changed_tasks = SD_simulate(-1.0);
63 INFO0("Tasks whose state has changed:");
65 while(changed_tasks[i] != NULL) {
66 switch (SD_task_get_state(changed_tasks[i])) {
68 INFO1("%s is scheduled.", SD_task_get_name(changed_tasks[i]));
71 INFO1("%s is ready.", SD_task_get_name(changed_tasks[i]));
74 INFO1("%s is running.", SD_task_get_name(changed_tasks[i]));
77 INFO1("%s is done.", SD_task_get_name(changed_tasks[i]));
80 INFO1("%s is failed.", SD_task_get_name(changed_tasks[i]));
83 INFO1("Unknown status for %s", SD_task_get_name(changed_tasks[i]));
89 INFO1("Total: %d", i);
91 /* clear some memory */
92 freeNodeAttributes(dag);
102 * createSimgridObjects()
104 int createSimgridObjects()
106 /* Create resources */
107 /* if (createSimgridResources() == -1) */
111 if (createSimgridTasks() == -1)
118 * createSimgridResources()
120 /* static int createSimgridResources() */
123 /* char buffer[32]; */
124 /* SG_Resource *sg_TCPlinks; */
125 /* SG_Resource fast_link; */
127 /* /\* The almost infinetely fast TCP link *\/ */
128 /* fast_link = SG_newTCPLink("infinetly_fast_TCPlink", */
130 /* 0.0, EPSILON, NULL, */
132 /* SG_TCP_SHARED,NULL); */
134 /* sg_TCPlinks = (SG_Resource*) calloc (2, sizeof(SG_Resource)); */
135 /* sg_TCPlinks[0] = fast_link; */
136 /* sg_TCPlinks[1] = NULL; */
138 /* /\* And the almost infinetely fast TCP route *\/ */
139 /* local_link = newLink(); */
140 /* local_link->sg_link = */
141 /* SG_newTCPRoute ("infinitely_fast_route", sg_TCPlinks, NULL); */
142 /* free(sg_TCPlinks); */
144 /* /\* Create hosts *\/ */
145 /* for (i=0;i<grid->nb_hosts;i++) { */
146 /* if (createSimgridHost(grid->hosts[i]) == -1) */
150 /* /\* Create TCP links *\/ */
151 /* for (i=0;i<grid->nb_links;i++) { */
152 /* if (createSimgridLink(grid->links[i]) == -1) */
156 /* /\* Create TCP routes *\/ */
157 /* grid->routes=(SG_Resource**)calloc(grid->nb_hosts,sizeof(SG_Resource*)); */
159 /* for (i=0;i<grid->nb_hosts;i++) { */
160 /* grid->routes[i]=(SG_Resource *)calloc(grid->nb_hosts,sizeof(SG_Resource)); */
161 /* for (j=0;j<grid->nb_hosts;j++) { */
162 /* sprintf(buffer,"route#%d-%d",i,j); */
164 /* if (grid->hosts[i]->cluster == grid->hosts[j]->cluster) { */
165 /* /\* Intra cluster route *\/ */
166 /* /\* src - switch - dest*\/ */
167 /* sg_TCPlinks = (SG_Resource*) calloc (4, sizeof(SG_Resource)); */
168 /* sg_TCPlinks[0] = grid->connections[i][j][0]->sg_link; */
169 /* sg_TCPlinks[1] = grid->connections[i][j][1]->sg_link; */
170 /* sg_TCPlinks[2] = grid->connections[i][j][2]->sg_link; */
171 /* sg_TCPlinks[3] = NULL; */
173 /* /\* Inter cluster route *\/ */
174 /* /\* src - switch - gateway - backbone - gateway - switch - dest*\/ */
175 /* sg_TCPlinks = (SG_Resource*) calloc (8, sizeof(SG_Resource)); */
176 /* sg_TCPlinks[0] = grid->connections[i][j][0]->sg_link; */
177 /* sg_TCPlinks[1] = grid->connections[i][j][1]->sg_link; */
178 /* sg_TCPlinks[2] = grid->connections[i][j][2]->sg_link; */
179 /* sg_TCPlinks[3] = grid->connections[i][j][3]->sg_link; */
180 /* sg_TCPlinks[4] = grid->connections[i][j][4]->sg_link; */
181 /* sg_TCPlinks[5] = grid->connections[i][j][5]->sg_link; */
182 /* sg_TCPlinks[6] = grid->connections[i][j][6]->sg_link; */
183 /* sg_TCPlinks[7] = NULL; */
185 /* grid->routes[i][j] = SG_newTCPRoute (buffer, sg_TCPlinks, NULL); */
186 /* free(sg_TCPlinks); */
188 /* /\*Self communication => no route *\/ */
189 /* grid->routes[i][j] = NULL; */
196 /* static int createSimgridHost(Host h) */
198 /* char buffer[32]; */
199 /* char *filename; */
203 /* sprintf(buffer,"host#%d",h->global_index); */
205 /* if (parseTraceSpec(h->cpu_trace,&filename,&offset,&value) == -1) { */
206 /* fprintf(stderr,"Syntax error: host#%d\n",h->global_index); */
210 /* h->sg_host = SG_newHost(buffer,h->rel_speed, */
211 /* h->mode, filename,offset,value, */
212 /* NULL, NULL, 0, h); */
213 /* free(filename); */
219 /* * createSimgridLink() */
222 /* static int createSimgridLink(Link l) */
224 /* char buffer[32]; */
225 /* char *filename1,*filename2; */
226 /* double offset1,offset2; */
227 /* double value1,value2; */
229 /* sprintf(buffer,"link#%d",l->global_index); */
231 /* if ((parseTraceSpec(l->latency_trace,&filename1,&offset1,&value1) == -1) || */
232 /* (parseTraceSpec(l->bandwidth_trace,&filename2,&offset2,&value2) == -1)) { */
233 /* fprintf(stderr,"Syntax error: link#%d\n",l->global_index); */
238 /* if (l->mode == SG_TIME_SLICED) { */
239 /* l->sg_link=SG_newTCPLink (buffer, */
240 /* filename1, offset1, value1, */
241 /* filename2, offset2, value2, */
242 /* SG_TCP_SHARED,NULL); */
245 /* if (l->mode == SG_FAT_PIPE) { */
246 /* l->sg_link=SG_newTCPLink (buffer, */
247 /* filename1, offset1, value1, */
248 /* filename2, offset2, value2, */
249 /* SG_TCP_BACKBONE,NULL); */
252 /* free(filename1); */
253 /* free(filename2); */
259 * createSimgridTasks()
262 static int createSimgridTasks()
268 /* Creating the tasks */
269 for (i=0;i<dag->nb_nodes;i++) {
270 node = dag->nodes[i];
271 sprintf(buffer,"node#%d",node->global_index);
272 node->sd_task = SD_task_create(buffer, node, 1.0);
275 /* Set the dependencies */
276 for (i=0;i<dag->nb_nodes;i++) {
277 node = dag->nodes[i];
278 for (j=0;j<node->nb_parents;j++) {
279 SD_task_dependency_add(NULL, NULL, node->parents[j]->sd_task, node->sd_task);
289 /* static int parseTraceSpec(char* spec,char**filename, */
290 /* double *offset, double *value) */
294 /* tmp = strchr(spec,':'); */
296 /* fprintf(stderr,"Parse error: missing ':' in trace specification\n"); */
300 /* *filename=NULL; */
304 /* if (tmp == spec) { /\* FIXED *\/ */
305 /* if (!*(tmp+1)) { */
306 /* fprintf(stderr,"Parse error: invalid value specification\n"); */
309 /* *value = atof(tmp+1); */
310 /* if (*value < 0.0) { */
311 /* fprintf(stderr,"Error: invalid value\n"); */
319 /* *filename=strdup(spec); */
320 /* if (!*(tmp+1)) { */
321 /* fprintf(stderr,"Parse error: invalid offset specification\n"); */
324 /* *offset = atof(tmp+1); */
325 /* if (*offset < 0.0) { */
326 /* fprintf(stderr,"Error: invalid offset\n"); */