-/* simple test trying to load a DAX file. */
+/* simple test trying to load a DOT file. */
-/* Copyright (c) 2009, 2010. The SimGrid Team.
+/* Copyright (c) 20010. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
XBT_LOG_NEW_DEFAULT_CATEGORY(test,
"Logging specific to this SimDag example");
-static int name_compare_hosts(const void *n1, const void *n2)
-{
- char name1[80], name2[80];
- strcpy(name1, SD_workstation_get_name(*((SD_workstation_t *) n1)));
- strcpy(name2, SD_workstation_get_name(*((SD_workstation_t *) n2)));
-
- return strcmp(name1, name2);
-}
-
int main(int argc, char **argv) {
xbt_dynar_t dot, changed;
unsigned int cursor;
/* Check our arguments */
if (argc < 3) {
INFO1("Usage: %s platform_file dot_file [trace_file]", argv[0]);
- INFO1("example: %s ../sd_platform.xml Montage_50.xml Montage_50.mytrace", argv[0]);
+ INFO1("example: %s ../2clusters.xml dag.dot dag.mytrace", argv[0]);
exit(1);
}
char *tracefilename;
/* creation of the environment */
SD_create_environment(argv[1]);
- /* load the DAX file */
+ /* load the DOT file */
dot=SD_dotload(argv[2]);
/* Display all the tasks */
/* Schedule them all on the first workstation */
INFO0("------------------- Schedule tasks ---------------------------");
const SD_workstation_t *ws_list = SD_workstation_get_list();
- int totalHosts = SD_workstation_get_number();
- qsort((void *) ws_list, totalHosts, sizeof(SD_workstation_t),
- name_compare_hosts);
int count = SD_workstation_get_number();
xbt_dynar_foreach(dot,cursor,task) {
#undef CLEANUP
#include <graphviz/cgraph.h>
-static double parse_double(const char *string) {
+static double dot_parse_double(const char *string) {
if (string == NULL) return -10;
int ret = 0;
double value;
WARN1("%s is not a double", string);
return value;
}
-static int parse_int(const char *string) {
+static int dot_parse_int(const char *string) {
if (string == NULL) return -10;
int ret = 0;
int value;
SD_task_t t=task;
SD_task_destroy(t);
}
-void Start_dot_job(Agnode_t *dag_node) ;
-void input_edge(SD_task_t current_job, Agedge_t *edge) ;
-void output_edge(SD_task_t current_job, Agedge_t *edge) ;
+void dot_add_task(Agnode_t *dag_node) ;
+void dot_add_input_dependencies(SD_task_t current_job, Agedge_t *edge) ;
+void dot_add_output_dependencies(SD_task_t current_job, Agedge_t *edge) ;
-/** @brief loads a DAX file describing a DAG
+/** @brief loads a DOT file describing a DAG
*
- * See https://confluence.pegasus.isi.edu/display/pegasus/WorkflowGenerator
+ * See http://www.graphviz.org/doc/info/lang.html
* for more details.
+ * To obtain information about transfers and tasks, two attributes are
+ * required : size on task (execution time in Flop) and size on edge
+ * (the amount of data transfer in bit).
+ * if they aren't here, there choose to be equal to zero.
*/
xbt_dynar_t SD_dotload(const char*filename){
FILE* in_file = fopen(filename,"r");
Agnode_t *dag_node = NULL;
for (dag_node = agfstnode(dag_dot); dag_node; dag_node = agnxtnode(dag_dot,dag_node)){
- Start_dot_job(dag_node);
+ dot_add_task(dag_node);
}
agclose(dag_dot);
xbt_dict_free(&jobs);
/* Free previous copy of the files */
xbt_dict_free(&files);
- //INFO2("result : %lld, dot : %lld",result,*dot);
return result;
}
-void Start_dot_job(Agnode_t *dag_node) {
+/* dot_add_task create a sd_task and all transfers required for this
+ * task. The execution time of the task is given by the attribute size.
+ * The unit of size is the Flop.*/
+void dot_add_task(Agnode_t *dag_node) {
char *name = agnameof(dag_node);
- double runtime = parse_double(agget(dag_node,(char*)"size"));
- long performer = (long)parse_int((char *) agget(dag_node,(char*)"performer"));
+ double runtime = dot_parse_double(agget(dag_node,(char*)"size"));
+ long performer = (long)dot_parse_int((char *) agget(dag_node,(char*)"performer"));
INFO3("See <job id=%s runtime=%s %.0f>",name,agget(dag_node,(char*)"size"),runtime);
SD_task_t current_job = SD_task_create_comp_seq(name,(void*)performer,runtime);
xbt_dict_set(jobs,name,current_job,NULL);
Agedge_t *e;
int count = 0;
for (e = agfstin(dag_dot,dag_node); e; e = agnxtin(dag_dot,e)) {
- input_edge(current_job,e);
+ dot_add_input_dependencies(current_job,e);
count++;
}
if (count==0){
}
count = 0;
for (e = agfstout(dag_dot,dag_node); e; e = agnxtout(dag_dot,e)) {
- output_edge(current_job,e);
+ dot_add_output_dependencies(current_job,e);
count++;
}
if (count==0){
}
}
-void input_edge(SD_task_t current_job, Agedge_t *edge) {
+/* dot_add_output_dependencies create the dependencies between a task
+ * and a transfers. This is given by the edges in the dot file.
+ * The amount of data transfers is given by the attribute size on the
+ * edge. */
+void dot_add_input_dependencies(SD_task_t current_job, Agedge_t *edge) {
SD_task_t file;
char name[80];
sprintf(name ,"%s->%s",agnameof(agtail(edge)) ,agnameof(aghead(edge)));
- double size = parse_double(agget(edge,(char*)"size"));
- //int sender = parse_int(agget(edge,(char*)"sender"));
- //int reciever = parse_int(agget(edge,(char*)"reciever"));
+ double size = dot_parse_double(agget(edge,(char*)"size"));
+ //int sender = dot_parse_int(agget(edge,(char*)"sender"));
+ //int reciever = dot_parse_int(agget(edge,(char*)"reciever"));
file = xbt_dict_get_or_null(files,name);
if (file==NULL) {
SD_task_dependency_add(NULL,NULL,file,current_job);
}
-void output_edge(SD_task_t current_job, Agedge_t *edge) {
+/* dot_add_output_dependencies create the dependencies between a
+ * transfers and a task. This is given by the edges in the dot file.
+ * The amount of data transfers is given by the attribute size on the
+ * edge. */
+void dot_add_output_dependencies(SD_task_t current_job, Agedge_t *edge) {
SD_task_t file;
char name[80];
sprintf(name ,"%s->%s",agnameof(agtail(edge)) ,agnameof(aghead(edge)));
- double size = parse_double(agget(edge,(char*)"size"));
- //int sender = parse_int(agget(edge,(char*)"sender"));
- //int reciever = parse_int(agget(edge,(char*)"reciever"));
+ double size = dot_parse_double(agget(edge,(char*)"size"));
+ //int sender = dot_parse_int(agget(edge,(char*)"sender"));
+ //int reciever = dot_parse_int(agget(edge,(char*)"reciever"));
//INFO2("See <uses file=%s %s>",A_dot__uses_file,(is_input?"in":"out"));
file = xbt_dict_get_or_null(files,name);