From b37e7b35207fa3acfe3d1b0bbe4390b70e395b3e Mon Sep 17 00:00:00 2001 From: quintin Date: Wed, 7 Jul 2010 07:39:32 +0000 Subject: [PATCH] Delete the dependencies with stdio in simdag.h. Correction and add of comments. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7983 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/simdag/dot/dot_test.c | 20 +++--------- include/simdag/simdag.h | 2 -- src/simdag/sd_dotloader.c | 58 +++++++++++++++++++++------------- src/simdag/sd_task.c | 4 +-- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/examples/simdag/dot/dot_test.c b/examples/simdag/dot/dot_test.c index c54aece092..b59334be41 100644 --- a/examples/simdag/dot/dot_test.c +++ b/examples/simdag/dot/dot_test.c @@ -1,6 +1,6 @@ -/* 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 @@ -16,15 +16,6 @@ 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; @@ -36,7 +27,7 @@ int main(int argc, char **argv) { /* 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; @@ -51,7 +42,7 @@ int main(int argc, char **argv) { /* 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 */ @@ -71,9 +62,6 @@ int main(int argc, char **argv) { /* 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) { diff --git a/include/simdag/simdag.h b/include/simdag/simdag.h index a95d27b0d3..2c73a3d080 100644 --- a/include/simdag/simdag.h +++ b/include/simdag/simdag.h @@ -7,7 +7,6 @@ #ifndef SIMDAG_SIMDAG_H #define SIMDAG_SIMDAG_H -#include #include "simdag/datatypes.h" #include "xbt/misc.h" #include "xbt/dynar.h" @@ -147,7 +146,6 @@ XBT_PUBLIC(int) SD_task_get_workstation_count(SD_task_t task); XBT_PUBLIC(SD_workstation_t*) SD_task_get_workstation_list(SD_task_t task); XBT_PUBLIC(void) SD_task_destroy(SD_task_t task); XBT_PUBLIC(void) SD_task_dump(SD_task_t task); -XBT_PUBLIC(void) SD_task_dotty(SD_task_t task,void* out_FILE); XBT_PUBLIC(SD_task_t) SD_task_create_comp_seq(const char*name,void *data,double amount); XBT_PUBLIC(SD_task_t) SD_task_create_comm_e2e(const char*name,void *data,double amount); diff --git a/src/simdag/sd_dotloader.c b/src/simdag/sd_dotloader.c index 13e1b7c949..d6bb08b95a 100644 --- a/src/simdag/sd_dotloader.c +++ b/src/simdag/sd_dotloader.c @@ -14,7 +14,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_dotparse, sd,"Parsing DOT files"); #undef CLEANUP #include -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; @@ -24,7 +24,7 @@ static double parse_double(const char *string) { 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; @@ -54,14 +54,18 @@ static void dot_task_free(void*task){ 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"); @@ -87,7 +91,7 @@ xbt_dynar_t SD_dotload_FILE(FILE* in_file){ 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); @@ -140,14 +144,16 @@ xbt_dynar_t SD_dotload_FILE(FILE* in_file){ /* 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 ",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); @@ -155,7 +161,7 @@ void Start_dot_job(Agnode_t *dag_node) { 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){ @@ -177,7 +183,7 @@ void Start_dot_job(Agnode_t *dag_node) { } 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){ @@ -203,14 +209,18 @@ void Start_dot_job(Agnode_t *dag_node) { } } -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) { @@ -225,13 +235,17 @@ void input_edge(SD_task_t current_job, Agedge_t *edge) { 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 ",A_dot__uses_file,(is_input?"in":"out")); file = xbt_dict_get_or_null(files,name); diff --git a/src/simdag/sd_task.c b/src/simdag/sd_task.c index 0b0c4cb673..80fa27eda8 100644 --- a/src/simdag/sd_task.c +++ b/src/simdag/sd_task.c @@ -1338,9 +1338,9 @@ void SD_task_schedulev(SD_task_t task, int count, const SD_workstation_t*list) { SD_task_t after = dep->dst; if (after->kind == SD_TASK_COMM_E2E) { after->workstation_list[0] = task->workstation_list[0]; - //J-N : Why did you comment on these line (this comment add a bug I think)? + //J-N : Why did you comment on these line (this comment add a bug I think)? if (after->workstation_list[1] && (__SD_task_is_not_scheduled(after) || - __SD_task_is_schedulable(after))) { + __SD_task_is_schedulable(after))) { SD_task_do_schedule(after); VERB4("Auto-Schedule comm task %s between %s -> %s. It costs %.f bytes", SD_task_get_name(after), -- 2.20.1