1 /* simple test trying to load a DAX file. */
3 /* Copyright (c) 2009 Da SimGrid Team. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #include "simdag/simdag.h"
15 XBT_LOG_NEW_DEFAULT_CATEGORY(test,
16 "Logging specific to this SimDag example");
19 int main(int argc, char **argv) {
24 /* initialisation of SD */
27 /* Check our arguments */
29 INFO1("Usage: %s platform_file dax_file", argv[0]);
30 INFO1("example: %s ../sd_platform.xml Montage_50.xml", argv[0]);
34 /* creation of the environment */
35 SD_create_environment(argv[1]);
37 /* load the DAX file */
38 dax=SD_daxload(argv[2]);
40 /* Display all the tasks */
41 INFO0("------------------- Display all tasks of the loaded DAG ---------------------------");
42 xbt_dynar_foreach(dax,cursor,task) {
46 FILE *dotout = fopen("dax.dot","w");
47 fprintf(dotout,"digraph A {\n");
48 xbt_dynar_foreach(dax,cursor,task) {
49 SD_task_dotty(task,dotout);
51 fprintf(dotout,"}\n");
54 /* Schedule them all on the first workstation */
55 INFO0("------------------- Schedule tasks ---------------------------");
56 const SD_workstation_t *ws_list = SD_workstation_get_list();
57 int count = SD_workstation_get_number();
58 xbt_dynar_foreach(dax,cursor,task) {
59 if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
60 if (!strcmp(SD_task_get_name(task),"end"))
61 SD_task_schedulel(task,1,ws_list[0]);
63 SD_task_schedulel(task,1,ws_list[cursor%count]);
67 INFO0("------------------- Run the schedule ---------------------------");
69 INFO0("------------------- Produce the trace file---------------------------");
70 char *last=strrchr(argv[2],'.');
72 char *filename=bprintf("%.*s.trace",last==NULL?strlen(argv[2]):last-argv[2],argv[2]);
73 INFO1("Producing the trace of the run into %s",filename);
74 FILE*out = fopen(filename,"w");
75 xbt_assert1(out,"Cannot write to %s",filename);
78 xbt_dynar_foreach(dax,cursor,task) {
79 int kind = SD_task_get_kind(task);
80 SD_workstation_t *wsl = SD_task_get_workstation_list(task);
82 case SD_TASK_COMP_SEQ:
83 fprintf(out,"[%f] %s compute %f # %s\n",SD_task_get_start_time(task),
84 SD_workstation_get_name(wsl[0]),SD_task_get_amount(task),
85 SD_task_get_name(task));
87 case SD_TASK_COMM_E2E:
88 fprintf(out,"[%f] %s send %s %f # %s\n",SD_task_get_start_time(task),
89 SD_workstation_get_name(wsl[0]),SD_workstation_get_name(wsl[1]),
90 SD_task_get_amount(task), SD_task_get_name(task));
91 fprintf(out,"[%f] %s recv %s %f # %s\n",SD_task_get_start_time(task),
92 SD_workstation_get_name(wsl[1]),SD_workstation_get_name(wsl[0]),
93 SD_task_get_amount(task), SD_task_get_name(task));
96 xbt_die(bprintf("Task %s is of unknown kind %d",SD_task_get_name(task),SD_task_get_kind(task)));