A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
model-checker : extend MC_ignore mechanism for global variables in libsimgrid
[simgrid.git]
/
src
/
simdag
/
sd_dotloader.c
diff --git
a/src/simdag/sd_dotloader.c
b/src/simdag/sd_dotloader.c
index d1900ad60668361bccea0eb61974f5a6b8907bf4..9402eaa366ca732f01246db2e530e8c6b5473b0b 100644
(file)
--- a/
src/simdag/sd_dotloader.c
+++ b/
src/simdag/sd_dotloader.c
@@
-20,6
+20,11
@@
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_dotparse, sd, "Parsing DOT files");
#include <graphviz/cgraph.h>
#elif HAVE_AGRAPH_H
#include <graphviz/agraph.h>
#include <graphviz/cgraph.h>
#elif HAVE_AGRAPH_H
#include <graphviz/agraph.h>
+#define agnxtnode(dot, node) agnxtnode(node)
+#define agfstin(dot, node) agfstin(node)
+#define agnxtin(dot, edge) agnxtin(edge)
+#define agfstout(dot, node) agfstout(node)
+#define agnxtout(dot, edge) agnxtout(edge)
#endif
void dot_add_task(Agnode_t * dag_node);
#endif
void dot_add_task(Agnode_t * dag_node);
@@
-29,20
+34,20
@@
xbt_dynar_t SD_dotload_generic(const char * filename);
static double dot_parse_double(const char *string)
{
static double dot_parse_double(const char *string)
{
-
if (string == NULL)
-
return -1;
-
double value = -1;
-
char *err;
-
-
//ret = sscanf(string, "%lg", &value);
-
errno = 0;
-
value = strtod(string,&err);
-
if(errno)
-
{
-
XBT_WARN("Failed to convert string to double: %s\n",strerror(errno));
-
return -1;
-
}
-
return value;
+ if (string == NULL)
+ return -1;
+ double value = -1;
+ char *err;
+
+ //ret = sscanf(string, "%lg", &value);
+ errno = 0;
+ value = strtod(string,&err);
+ if(errno)
+ {
+ XBT_WARN("Failed to convert string to double: %s\n",strerror(errno));
+ return -1;
+ }
+ return value;
}
}
@@
-84,6
+89,12
@@
static void dot_task_free(void *task)
SD_task_destroy(t);
}
SD_task_destroy(t);
}
+static void dot_task_p_free(void *task)
+{
+ SD_task_t *t = task;
+ SD_task_destroy(*t);
+}
+
static void TRACE_sd_dotloader (SD_task_t task, const char *category)
{
if (category){
static void TRACE_sd_dotloader (SD_task_t task, const char *category)
{
if (category){
@@
-160,7
+171,7
@@
xbt_dynar_t SD_dotload_generic(const char * filename)
FILE *in_file = fopen(filename, "r");
dag_dot = agread(in_file, NIL(Agdisc_t *));
FILE *in_file = fopen(filename, "r");
dag_dot = agread(in_file, NIL(Agdisc_t *));
- result = xbt_dynar_new(sizeof(SD_task_t), dot_task_free);
+ result = xbt_dynar_new(sizeof(SD_task_t), dot_task_
p_
free);
files = xbt_dict_new_homogeneous(&dot_task_free);
jobs = xbt_dict_new_homogeneous(NULL);
computers = xbt_dict_new_homogeneous(NULL);
files = xbt_dict_new_homogeneous(&dot_task_free);
jobs = xbt_dict_new_homogeneous(NULL);
computers = xbt_dict_new_homogeneous(NULL);
@@
-174,15
+185,8
@@
xbt_dynar_t SD_dotload_generic(const char * filename)
xbt_dict_set(jobs, "end", end_task, NULL);
Agnode_t *dag_node = NULL;
xbt_dict_set(jobs, "end", end_task, NULL);
Agnode_t *dag_node = NULL;
- for (dag_node = agfstnode(dag_dot); dag_node;
-#ifdef HAVE_CGRAPH_H
- dag_node = agnxtnode(dag_dot, dag_node)
-#elif HAVE_AGRAPH_H
- dag_node = agnxtnode(dag_node)
-#endif
- ) {
-
- dot_add_task(dag_node);
+ for (dag_node = agfstnode(dag_dot); dag_node; dag_node = agnxtnode(dag_dot, dag_node)) {
+ dot_add_task(dag_node);
}
agclose(dag_dot);
xbt_dict_free(&jobs);
}
agclose(dag_dot);
xbt_dict_free(&jobs);
@@
-239,18
+243,13
@@
xbt_dynar_t SD_dotload_generic(const char * filename)
/* Free previous copy of the files */
xbt_dict_free(&files);
fclose(in_file);
/* Free previous copy of the files */
xbt_dict_free(&files);
fclose(in_file);
- if(acyclic_graph_detail(result))
- return result;
- else {
- unsigned int cpt;
+ if (!acyclic_graph_detail(result)) {
XBT_ERROR("The DOT described in %s is not a DAG. It contains a cycle.",
basename((char*)filename));
XBT_ERROR("The DOT described in %s is not a DAG. It contains a cycle.",
basename((char*)filename));
- xbt_dynar_foreach(result, cpt, file)
- SD_task_destroy(file);
- xbt_dynar_free_container(&result);
+ xbt_dynar_free(&result);
+ /* (result == NULL) here */
}
}
- free(dag_dot);
- return NULL;
+ return result;
}
/* dot_add_task create a sd_task and all transfers required for this
}
/* dot_add_task create a sd_task and all transfers required for this
@@
-277,26
+276,15
@@
void dot_add_task(Agnode_t * dag_node)
Agedge_t *e;
int count = 0;
Agedge_t *e;
int count = 0;
-#ifdef HAVE_CGRAPH_H
- for (e = agfstin(dag_dot, dag_node); e; e = agnxtin(dag_dot, e))
-#elif HAVE_AGRAPH_H
- for (e = agfstin(dag_node); e; e = agnxtin(e))
-#endif
- {
- dot_add_input_dependencies(current_job, e);
- count++;
+ for (e = agfstin(dag_dot, dag_node); e; e = agnxtin(dag_dot, e)) {
+ dot_add_input_dependencies(current_job, e);
+ count++;
}
if (count == 0 && current_job != root_task) {
SD_task_dependency_add(NULL, NULL, root_task, current_job);
}
count = 0;
}
if (count == 0 && current_job != root_task) {
SD_task_dependency_add(NULL, NULL, root_task, current_job);
}
count = 0;
-#ifdef HAVE_CGRAPH_H
- for (e = agfstout(dag_dot, dag_node); e; e = agnxtout(dag_dot, e))
-#elif HAVE_AGRAPH_H
- for (e = agfstout(dag_node); e; e = agnxtout(e))
-#endif
- {
-
+ for (e = agfstout(dag_dot, dag_node); e; e = agnxtout(dag_dot, e)) {
dot_add_output_dependencies(current_job, e);
count++;
}
dot_add_output_dependencies(current_job, e);
count++;
}