diff --git a/examples/main.c b/examples/main.c index 1298187d3d547d6c9aee9f9f98dddffe3cc56e93..88fddc955b244ef259f77899d15b9ec5db1680b0 100644 --- a/examples/main.c +++ b/examples/main.c @@ -191,8 +191,7 @@ int main(int argc, char *argv[]) { #ifdef SWIFT_DEBUG_CHECKS strcat(parameters, "x"); #endif - while ((c = getopt(argc, argv, parameters)) != -1) - switch (c) { + while ((c = getopt(argc, argv, parameters)) != -1) switch (c) { case 'a': #if defined(HAVE_SETAFFINITY) && defined(HAVE_LIBNUMA) with_aff = 1; @@ -205,8 +204,8 @@ int main(int argc, char *argv[]) { break; #ifdef SWIFT_DEBUG_CHECKS case 'x': - write_dependencies = 1; - break; + write_dependencies = 1; + break; #endif case 'C': with_cooling = 1; @@ -704,8 +703,7 @@ int main(int argc, char *argv[]) { engine_print_stats(&e); #ifdef SWIFT_DEBUG_CHECKS - if (write_dependencies) - scheduler_write_dependency(&e.sched); + if (write_dependencies) scheduler_write_dependency(&e.sched); #endif /* Legend */ diff --git a/src/scheduler.c b/src/scheduler.c index 744a4a8d73b656981dbd0db3261f66f890c61506..867bb2f1335a2a81c57ece0578d614feaa1f1b48 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -129,7 +129,7 @@ void scheduler_write_dependency(struct scheduler *s) { int nber_relation = 2 * task_type_count * task_subtype_count * max_nber_dep; /* For each type/subtype, a table of 2*max_nber_dep int is available => max_nber_dep task with subtype available - + -1 means that it is not set yet to get the table of max_nber_dep for a task: @@ -138,8 +138,7 @@ void scheduler_write_dependency(struct scheduler *s) { task_subtype */ int *table = malloc(nber_relation * sizeof(int)); - for(i=0; i < nber_relation; i++) - table[i] = -1; + for (i = 0; i < nber_relation; i++) table[i] = -1; message("Writing dependencies"); @@ -156,7 +155,7 @@ void scheduler_write_dependency(struct scheduler *s) { /* loop over all tasks */ for (i = 0; i < s->nr_tasks; i++) { - struct task *ta; + struct task *ta; ta = &s->tasks[i]; /* and theirs dependencies */ @@ -164,62 +163,54 @@ void scheduler_write_dependency(struct scheduler *s) { struct task *tb; tb = ta->unlock_tasks[j]; - - char tmp[200]; /* text to write */ + char tmp[200]; /* text to write */ char ta_name[200]; char tb_name[200]; /* construct line */ if (ta->subtype == task_subtype_none) - sprintf(ta_name, "%s", taskID_names[ta->type]); + sprintf(ta_name, "%s", taskID_names[ta->type]); else - sprintf(ta_name, "\"%s %s\"", - taskID_names[ta->type], - subtaskID_names[ta->subtype]); + sprintf(ta_name, "\"%s %s\"", taskID_names[ta->type], + subtaskID_names[ta->subtype]); if (tb->subtype == task_subtype_none) - sprintf(tb_name, "%s", taskID_names[tb->type]); + sprintf(tb_name, "%s", taskID_names[tb->type]); else - sprintf(tb_name, "\"%s %s\"", - taskID_names[tb->type], - subtaskID_names[tb->subtype]); - - sprintf(tmp, "\t %s->%s;\n", - ta_name, - tb_name); + sprintf(tb_name, "\"%s %s\"", taskID_names[tb->type], + subtaskID_names[tb->subtype]); + + sprintf(tmp, "\t %s->%s;\n", ta_name, tb_name); /* check if dependency already written */ int written = 0; int ind = ta->type * task_subtype_count + ta->subtype; ind *= 2 * max_nber_dep; - + int k = 0; int *cur = &table[ind]; - while (k < max_nber_dep) - { - /* not written yet */ - if (cur[0] == -1) - { - cur[0] = tb->type; - cur[1] = tb->subtype; - break; - } - - /* already written */ - if (cur[0] == tb->type && cur[1] == tb->subtype) - { - written = 1; - break; - } - - k += 1; - cur = &cur[3]; - } + while (k < max_nber_dep) { + /* not written yet */ + if (cur[0] == -1) { + cur[0] = tb->type; + cur[1] = tb->subtype; + break; + } + + /* already written */ + if (cur[0] == tb->type && cur[1] == tb->subtype) { + written = 1; + break; + } + + k += 1; + cur = &cur[3]; + } /* max_nber_dep is too small */ if (k == max_nber_dep) - error("Not enough memory, please increase max_nber_dep"); - + error("Not enough memory, please increase max_nber_dep"); + /* Not written yet => write it */ if (!written) { fprintf(f, tmp);