Commit 1e597100 authored by lhausamm's avatar lhausamm
Browse files

Formating

parent 7866ffb8
...@@ -2640,10 +2640,8 @@ void engine_maketasks(struct engine *e) { ...@@ -2640,10 +2640,8 @@ void engine_maketasks(struct engine *e) {
/* Set the tasks age. */ /* Set the tasks age. */
e->tasks_age = 0; e->tasks_age = 0;
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (e->ti_current == 0) if (e->ti_current == 0) scheduler_write_dependency(sched);
scheduler_write_dependency(sched);
#endif #endif
if (e->verbose) if (e->verbose)
......
...@@ -110,26 +110,24 @@ void scheduler_addunlock(struct scheduler *s, struct task *ta, ...@@ -110,26 +110,24 @@ void scheduler_addunlock(struct scheduler *s, struct task *ta,
s->unlocks[ind] = tb; s->unlocks[ind] = tb;
s->unlock_ind[ind] = ta - s->tasks; s->unlock_ind[ind] = ta - s->tasks;
atomic_inc(&s->completed_unlock_writes); atomic_inc(&s->completed_unlock_writes);
} }
void scheduler_write_dependency(struct scheduler *s) { void scheduler_write_dependency(struct scheduler *s) {
#ifdef WITH_MPI #ifdef WITH_MPI
if (engine_rank != 0) if (engine_rank != 0) return;
return;
#endif #endif
message("Writing dependencies"); message("Writing dependencies");
char filename[200] = "dependency_graph.dot"; char filename[200] = "dependency_graph.dot";
char tmp[200]; /* text to write */ char tmp[200]; /* text to write */
char *line = NULL; /* buff for reading line */ char *line = NULL; /* buff for reading line */
size_t len = 0; size_t len = 0;
ssize_t read; ssize_t read;
FILE *f; /* file containing the output */ FILE *f; /* file containing the output */
int test; int test;
int i,j; int i, j;
struct task *ta, *tb; struct task *ta, *tb;
...@@ -143,49 +141,40 @@ void scheduler_write_dependency(struct scheduler *s) { ...@@ -143,49 +141,40 @@ void scheduler_write_dependency(struct scheduler *s) {
fprintf(f, "\t node[nodesep=0.15];\n"); fprintf(f, "\t node[nodesep=0.15];\n");
fclose(f); fclose(f);
/* loop over all tasks */ /* loop over all tasks */
for(i=0; i < s->nr_tasks; i++) for (i = 0; i < s->nr_tasks; i++) {
{ ta = &s->tasks[i];
ta = &s->tasks[i];
/* and theirs dependencies */
/* and theirs dependencies */ for (j = 0; j < ta->nr_unlock_tasks; j++) {
for(j=0; j < ta->nr_unlock_tasks; j++) tb = ta->unlock_tasks[j];
{
tb = ta->unlock_tasks[j]; /* construct line */
sprintf(tmp, "\t %s_%s->%s_%s;\n", taskID_names[ta->type],
/* construct line */ subtaskID_names[ta->subtype], taskID_names[tb->type],
sprintf(tmp, "\t %s_%s->%s_%s;\n", subtaskID_names[tb->subtype]);
taskID_names[ta->type],
subtaskID_names[ta->subtype], f = open_and_check_file(filename, "r");
taskID_names[tb->type],
subtaskID_names[tb->subtype] /* check if dependency already written */
); test = 1;
/* loop over all lines */
f = open_and_check_file(filename, "r"); while (test && (read = getline(&line, &len, f)) != -1) {
/* check if line == dependency word */
/* check if dependency already written */ if (strcmp(tmp, line) == 0) test = 0;
test = 1; }
/* loop over all lines */
while (test && (read = getline(&line, &len, f)) != -1) fclose(f);
{
/* check if line == dependency word */ /* Not written yet => write it */
if (strcmp(tmp, line) == 0) if (test) {
test = 0; f = open_and_check_file(filename, "a");
} fprintf(f, tmp);
fclose(f);
fclose(f); }
/* Not written yet => write it */
if (test)
{
f = open_and_check_file(filename, "a");
fprintf(f, tmp);
fclose(f);
}
}
} }
}
f = open_and_check_file(filename, "a"); f = open_and_check_file(filename, "a");
fprintf(f, "}"); fprintf(f, "}");
......
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
#include "../config.h" #include "../config.h"
/* Some standard headers. */ /* Some standard headers. */
#include <errno.h>
#include <math.h> #include <math.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h>
/* This object's header. */ /* This object's header. */
#include "tools.h" #include "tools.h"
...@@ -705,6 +705,7 @@ int compare_particles(struct part a, struct part b, double threshold) { ...@@ -705,6 +705,7 @@ int compare_particles(struct part a, struct part b, double threshold) {
FILE *open_and_check_file(const char *filename, const char *mode) { FILE *open_and_check_file(const char *filename, const char *mode) {
FILE *f = fopen(filename, mode); FILE *f = fopen(filename, mode);
if (f == NULL) if (f == NULL)
error("Unable to open file '%s' in mode %s, error: %i", filename, mode, errno); error("Unable to open file '%s' in mode %s, error: %i", filename, mode,
errno);
return f; return f;
} }
...@@ -54,5 +54,4 @@ int compare_particles(struct part a, struct part b, double threshold); ...@@ -54,5 +54,4 @@ int compare_particles(struct part a, struct part b, double threshold);
FILE *open_and_check_file(const char *filename, const char *mode); FILE *open_and_check_file(const char *filename, const char *mode);
#endif /* SWIFT_TOOL_H */ #endif /* SWIFT_TOOL_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment