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();
61 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]));
90 /* clear some memory */
91 freeNodeAttributes(dag);
101 * createSimgridObjects()
103 int createSimgridObjects()
105 /* Create resources */
106 /* if (createSimgridResources() == -1) */
110 if (createSimgridTasks() == -1)
117 * createSimgridResources()
119 /* static int createSimgridResources() */
122 /* char buffer[32]; */
123 /* SG_Resource *sg_TCPlinks; */
124 /* SG_Resource fast_link; */
126 /* /\* The almost infinetely fast TCP link *\/ */
127 /* fast_link = SG_newTCPLink("infinetly_fast_TCPlink", */
129 /* 0.0, EPSILON, NULL, */
131 /* SG_TCP_SHARED,NULL); */
133 /* sg_TCPlinks = (SG_Resource*) calloc (2, sizeof(SG_Resource)); */
134 /* sg_TCPlinks[0] = fast_link; */
135 /* sg_TCPlinks[1] = NULL; */
137 /* /\* And the almost infinetely fast TCP route *\/ */
138 /* local_link = newLink(); */
139 /* local_link->sg_link = */
140 /* SG_newTCPRoute ("infinitely_fast_route", sg_TCPlinks, NULL); */
141 /* free(sg_TCPlinks); */
143 /* /\* Create hosts *\/ */
144 /* for (i=0;i<grid->nb_hosts;i++) { */
145 /* if (createSimgridHost(grid->hosts[i]) == -1) */
149 /* /\* Create TCP links *\/ */
150 /* for (i=0;i<grid->nb_links;i++) { */
151 /* if (createSimgridLink(grid->links[i]) == -1) */
155 /* /\* Create TCP routes *\/ */
156 /* grid->routes=(SG_Resource**)calloc(grid->nb_hosts,sizeof(SG_Resource*)); */
158 /* for (i=0;i<grid->nb_hosts;i++) { */
159 /* grid->routes[i]=(SG_Resource *)calloc(grid->nb_hosts,sizeof(SG_Resource)); */
160 /* for (j=0;j<grid->nb_hosts;j++) { */
161 /* sprintf(buffer,"route#%d-%d",i,j); */
163 /* if (grid->hosts[i]->cluster == grid->hosts[j]->cluster) { */
164 /* /\* Intra cluster route *\/ */
165 /* /\* src - switch - dest*\/ */
166 /* sg_TCPlinks = (SG_Resource*) calloc (4, sizeof(SG_Resource)); */
167 /* sg_TCPlinks[0] = grid->connections[i][j][0]->sg_link; */
168 /* sg_TCPlinks[1] = grid->connections[i][j][1]->sg_link; */
169 /* sg_TCPlinks[2] = grid->connections[i][j][2]->sg_link; */
170 /* sg_TCPlinks[3] = NULL; */
172 /* /\* Inter cluster route *\/ */
173 /* /\* src - switch - gateway - backbone - gateway - switch - dest*\/ */
174 /* sg_TCPlinks = (SG_Resource*) calloc (8, sizeof(SG_Resource)); */
175 /* sg_TCPlinks[0] = grid->connections[i][j][0]->sg_link; */
176 /* sg_TCPlinks[1] = grid->connections[i][j][1]->sg_link; */
177 /* sg_TCPlinks[2] = grid->connections[i][j][2]->sg_link; */
178 /* sg_TCPlinks[3] = grid->connections[i][j][3]->sg_link; */
179 /* sg_TCPlinks[4] = grid->connections[i][j][4]->sg_link; */
180 /* sg_TCPlinks[5] = grid->connections[i][j][5]->sg_link; */
181 /* sg_TCPlinks[6] = grid->connections[i][j][6]->sg_link; */
182 /* sg_TCPlinks[7] = NULL; */
184 /* grid->routes[i][j] = SG_newTCPRoute (buffer, sg_TCPlinks, NULL); */
185 /* free(sg_TCPlinks); */
187 /* /\*Self communication => no route *\/ */
188 /* grid->routes[i][j] = NULL; */
195 /* static int createSimgridHost(Host h) */
197 /* char buffer[32]; */
198 /* char *filename; */
202 /* sprintf(buffer,"host#%d",h->global_index); */
204 /* if (parseTraceSpec(h->cpu_trace,&filename,&offset,&value) == -1) { */
205 /* fprintf(stderr,"Syntax error: host#%d\n",h->global_index); */
209 /* h->sg_host = SG_newHost(buffer,h->rel_speed, */
210 /* h->mode, filename,offset,value, */
211 /* NULL, NULL, 0, h); */
212 /* free(filename); */
218 /* * createSimgridLink() */
221 /* static int createSimgridLink(Link l) */
223 /* char buffer[32]; */
224 /* char *filename1,*filename2; */
225 /* double offset1,offset2; */
226 /* double value1,value2; */
228 /* sprintf(buffer,"link#%d",l->global_index); */
230 /* if ((parseTraceSpec(l->latency_trace,&filename1,&offset1,&value1) == -1) || */
231 /* (parseTraceSpec(l->bandwidth_trace,&filename2,&offset2,&value2) == -1)) { */
232 /* fprintf(stderr,"Syntax error: link#%d\n",l->global_index); */
237 /* if (l->mode == SG_TIME_SLICED) { */
238 /* l->sg_link=SG_newTCPLink (buffer, */
239 /* filename1, offset1, value1, */
240 /* filename2, offset2, value2, */
241 /* SG_TCP_SHARED,NULL); */
244 /* if (l->mode == SG_FAT_PIPE) { */
245 /* l->sg_link=SG_newTCPLink (buffer, */
246 /* filename1, offset1, value1, */
247 /* filename2, offset2, value2, */
248 /* SG_TCP_BACKBONE,NULL); */
251 /* free(filename1); */
252 /* free(filename2); */
258 * createSimgridTasks()
261 static int createSimgridTasks()
267 /* Creating the tasks */
268 for (i=0;i<dag->nb_nodes;i++) {
269 node = dag->nodes[i];
270 sprintf(buffer,"node#%d",node->global_index);
271 node->sd_task = SD_task_create(buffer, node, 1.0);
274 /* Set the dependencies */
275 for (i=0;i<dag->nb_nodes;i++) {
276 node = dag->nodes[i];
277 for (j=0;j<node->nb_parents;j++) {
278 SD_task_dependency_add(NULL, NULL, node->parents[j]->sd_task, node->sd_task);
288 /* static int parseTraceSpec(char* spec,char**filename, */
289 /* double *offset, double *value) */
293 /* tmp = strchr(spec,':'); */
295 /* fprintf(stderr,"Parse error: missing ':' in trace specification\n"); */
299 /* *filename=NULL; */
303 /* if (tmp == spec) { /\* FIXED *\/ */
304 /* if (!*(tmp+1)) { */
305 /* fprintf(stderr,"Parse error: invalid value specification\n"); */
308 /* *value = atof(tmp+1); */
309 /* if (*value < 0.0) { */
310 /* fprintf(stderr,"Error: invalid value\n"); */
318 /* *filename=strdup(spec); */
319 /* if (!*(tmp+1)) { */
320 /* fprintf(stderr,"Parse error: invalid offset specification\n"); */
323 /* *offset = atof(tmp+1); */
324 /* if (*offset < 0.0) { */
325 /* fprintf(stderr,"Error: invalid offset\n"); */