Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Delete the dependencies with stdio in simdag.h. Correction and add of comments.
authorquintin <quintin@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 7 Jul 2010 07:39:32 +0000 (07:39 +0000)
committerquintin <quintin@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 7 Jul 2010 07:39:32 +0000 (07:39 +0000)
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
include/simdag/simdag.h
src/simdag/sd_dotloader.c
src/simdag/sd_task.c

index c54aece..b59334b 100644 (file)
@@ -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
 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) {
index a95d27b..2c73a3d 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef SIMDAG_SIMDAG_H
 #define SIMDAG_SIMDAG_H
 
-#include <stdio.h>
 #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);
index 13e1b7c..d6bb08b 100644 (file)
@@ -14,7 +14,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_dotparse, sd,"Parsing DOT files");
 #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;
@@ -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 <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);
@@ -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 <uses file=%s %s>",A_dot__uses_file,(is_input?"in":"out"));
     file = xbt_dict_get_or_null(files,name);
index 0b0c4cb..80fa27e 100644 (file)
@@ -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),