From f77733b794cf288616ef9a7b6e63f4aa8b9e4cb9 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Tue, 12 Jan 2016 00:04:09 +0000 Subject: [PATCH] Status before debuggin session --- examples/main.c | 2 +- src/engine.c | 2 -- src/runner.c | 25 +------------------------ src/runner_iact_legacy.h | 10 ++++------ src/scheduler.c | 12 ++++++++++-- src/task.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/task.h | 1 + 7 files changed, 57 insertions(+), 35 deletions(-) diff --git a/examples/main.c b/examples/main.c index e385f173d4..b01ace5900 100644 --- a/examples/main.c +++ b/examples/main.c @@ -397,7 +397,7 @@ int main(int argc, char *argv[]) { /* Take a step. */ engine_step(&e); - if (j == 5) break; + if (j == 1) break; if (with_outputs && j % 100 == 0) { diff --git a/src/engine.c b/src/engine.c index 42fce5dbbe..830cf6e9c9 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2009,8 +2009,6 @@ if ( e->nodeID == 0 ) scheduler_print_tasks(&e->sched, "tasks_after.dat"); - error("done step"); - TIMER_TOC(timer_runners); TIMER_TOC2(timer_step); diff --git a/src/runner.c b/src/runner.c index 54f3dab561..77e50c8779 100644 --- a/src/runner.c +++ b/src/runner.c @@ -1193,30 +1193,7 @@ void *runner_main(void *data) { space_split(e->s, t->ci); break; case task_type_rewait: - - - - for (struct task *t2 = (struct task *)t->ci; - t2 != (struct task *)t->cj; t2++) { - if(store == NULL && t2->type==task_type_pair && t2->subtype==task_subtype_density) { - message("\n"); - message("Checking task %s-%s address: %p", taskID_names[t2->type], subtaskID_names[t2->subtype], t2); - store = t2; - } - for (int k = 0; k < t2->nr_unlock_tasks; k++) { - if(t2->type == task_type_sort && t2->flags == 0) continue; - atomic_inc(&t2->unlock_tasks[k]->wait); - - struct task *t3=t2->unlock_tasks[k]; - if (t3 == store) { - message("Unlocked by task %s-%s address: %p" , taskID_names[t2->type], subtaskID_names[t2->subtype], t2); - } - - } - } - - - + task_do_rewait(t); break; default: error("Unknown task type."); diff --git a/src/runner_iact_legacy.h b/src/runner_iact_legacy.h index 79157e9284..bd868b63bb 100644 --- a/src/runner_iact_legacy.h +++ b/src/runner_iact_legacy.h @@ -26,9 +26,8 @@ #include "part.h" #include "vector.h" -/* #define PRINT_PARTS \ */ -/* void; */ -/*if (pi->id == 1000) { \ +#define PRINT_PARTS \ +if (pi->id == 1000) { \ message( \ "pi->id=%lld pi->h=%f pi->N_ngb=%f pi->rho=%f pi->t_beg=%f pi->t_end=%f pos=[%f %f %f]", \ pi->id, pi->h, pi->density.wcount, pi->rho, pi->t_begin, pi->t_end, pi->x[0], pi->x[1], pi->x[2]); \ @@ -39,7 +38,6 @@ pj->id, pj->h, pj->density.wcount, pj->rho, pj->t_begin, pj->t_end, pj->x[0], pj->x[1], pj->x[2]); \ }\ fflush(stdout); -*/ /** @@ -74,7 +72,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_density( float dv[3], curlvr[3]; int k; - //PRINT_PARTS; + PRINT_PARTS; /* Get the masses. */ mi = pi->mass; @@ -250,7 +248,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_density( float dv[3], curlvr[3]; int k; - //PRINT_PARTS; + PRINT_PARTS; /* Get the masses. */ mj = pj->mass; diff --git a/src/scheduler.c b/src/scheduler.c index 341a681ddc..084b8f3626 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -983,13 +983,21 @@ void scheduler_start(struct scheduler *s, unsigned int mask) { ? s->size - s->nr_tasks : s->nr_queues; - const int waiting_old = - s->waiting; // Remember that engine_launch may fiddle with this value. + /* Remember that engine_launch may fiddle with this value. */ + const int waiting_old = s->waiting; + + /* We are going to use the task structure in a modified way to pass information + to the task. Don't do this at home ! + - ci and cj will give the range of tasks to which the waits will be applied + - the flags will be used to transfer the mask + - the rest is unused. + */ for (int k = 0; k < num_rewait_tasks; k++) { rewait_tasks[k].type = task_type_rewait; rewait_tasks[k].ci = (struct cell *)&s->tasks[k * nr_tasks / s->nr_queues]; rewait_tasks[k].cj = (struct cell *)&s->tasks[(k + 1) * nr_tasks / s->nr_queues]; + rewait_tasks[k].flags = s->mask; rewait_tasks[k].skip = 0; rewait_tasks[k].wait = 0; rewait_tasks[k].rid = -1; diff --git a/src/task.c b/src/task.c index b65bfd21fd..afb93720fc 100644 --- a/src/task.c +++ b/src/task.c @@ -41,6 +41,8 @@ #include "error.h" #include "lock.h" +struct task *store; + /* Task type names. */ const char *taskID_names[task_type_count] = { "none", "sort", "self", "pair", "sub", "init", @@ -267,3 +269,41 @@ void task_print_mask(unsigned int mask) { printf(" %s=%s", taskID_names[k], (mask & (1 << k)) ? "yes" : "no"); printf(" ]\n"); } + + +void task_do_rewait(struct task *t) { + + const unsigned int mask = t->flags; + + for (struct task *t2 = (struct task *)t->ci; t2 != (struct task *)t->cj; t2++) { + + if( t2->skip ) continue; + + /* Skip tasks not in the mask */ + if( !((1<<t2->type) & mask) ) continue; + + /* Skip sort tasks that have already been performed */ + if(t2->type == task_type_sort && t2->flags == 0) continue; + + if(store == NULL && t2->type==task_type_pair && t2->subtype==task_subtype_density) { + message("\n"); + message("Checking task %s-%s address: %p", taskID_names[t2->type], subtaskID_names[t2->subtype], t2); + store = t2; + } + + for (int k = 0; k < t2->nr_unlock_tasks; k++) { + + struct task *t3=t2->unlock_tasks[k]; + + atomic_inc(&t3->wait); + + if (t3 == store) { + message("Unlocked by task %s-%s address: %p" , taskID_names[t2->type], subtaskID_names[t2->subtype], t2); + } + + } + } + + + +} diff --git a/src/task.h b/src/task.h index fbeed3a7a4..8f633a640e 100644 --- a/src/task.h +++ b/src/task.h @@ -95,5 +95,6 @@ void task_addunlock(struct task *ta, struct task *tb); void task_unlock(struct task *t); int task_lock(struct task *t); void task_print_mask(unsigned int mask); +void task_do_rewait(struct task *t); #endif /* SWIFT_TASK_H */ -- GitLab