-/* Copyright (c) 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2009-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include "simdag/simdag.h"
#include "xbt/misc.h"
#include "xbt/log.h"
+#include <libgen.h>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_daxparse, sd, "Parsing DAX files");
static void dax_parse_error(char *msg)
{
fprintf(stderr, "Parse error on line %d: %s\n", dax_lineno, msg);
- abort();
+ xbt_abort();
}
static double dax_parse_double(const char *string)
return value;
}
-static int dax_parse_int(const char *string)
-{
- int ret = 0;
- int value;
-
- ret = sscanf(string, "%d", &value);
- if (ret != 1)
- dax_parse_error(bprintf("%s is not an integer", string));
- return value;
-}
-
/* Ensure that transfer tasks have unique names even though a file is used
* several times */
static SD_task_t current_job;
static SD_task_t root_task, end_task;
-static void dump_res()
-{
- unsigned int cursor;
- SD_task_t task;
- xbt_dynar_foreach(result, cursor, task) {
- XBT_INFO("Task %u", cursor);
- SD_task_dump(task);
- }
-}
-
static void dax_task_free(void *task)
{
SD_task_t t = task;
xbt_dynar_push(result, &root_task);
end_task = SD_task_create_comp_seq("end", NULL, 0);
- _XBT_GNUC_UNUSED int res;
- res = dax_lex();
- xbt_assert(!res, "Parse error in %s: %s", filename,
- dax__parse_err_msg());
+ int res = dax_lex();
+ if (res != 0)
+ xbt_die("Parse error in %s: %s", filename, dax__parse_err_msg());
dax__delete_buffer(input_buffer);
fclose(in_file);
dax_lex_destroy();
const char *category = depafter->src->category;
if (category){
TRACE_category (category);
- SD_task_set_category (newfile, category);
+ TRACE_sd_set_task_category(newfile, category);
}
}
#endif
const char *category = depbefore->src->category;
if (category){
TRACE_category (category);
- SD_task_set_category (newfile, category);
+ TRACE_sd_set_task_category(newfile, category);
}
}
#endif
const char *category = depbefore->src->category;
if (category){
TRACE_category (category);
- SD_task_set_category (newfile, category);
+ TRACE_sd_set_task_category(newfile, category);
}
}
#endif
xbt_dynar_foreach(result, cpt, file) {
if (SD_task_get_kind(file) == SD_TASK_COMM_E2E) {
uniq_transfer_task_name(file);
+ } else if (SD_task_get_kind(file) == SD_TASK_COMP_SEQ){
+ /* If some tasks do not take files as input, connect them to the root, if
+ * they don't produce files, connect them to the end node.
+ */
+ if ((file != root_task) && xbt_dynar_is_empty(file->tasks_before)) {
+ SD_task_dependency_add(NULL, NULL, root_task, file);
+ }
+ if ((file != end_task) && xbt_dynar_is_empty(file->tasks_after)) {
+ SD_task_dependency_add(NULL, NULL, file, end_task);
+ }
}
}
- acyclic_graph_detail(result);
- return result;
+ if (!acyclic_graph_detail(result)){
+ XBT_ERROR("The DAX 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);
+ return NULL;
+ } else {
+ return result;
+ }
}
void STag_dax__adag(void)
char *category = A_dax__job_name;
if (category){
TRACE_category (category);
- SD_task_set_category(current_job, category);
+ TRACE_sd_set_task_category(current_job, category);
}
#endif
xbt_dict_set(jobs, A_dax__job_id, current_job, NULL);