From 72e1d770f237b80d4093d05f6a0cb6854aafdd52 Mon Sep 17 00:00:00 2001 From: "Peter W. Draper" <p.w.draper@durham.ac.uk> Date: Mon, 19 Aug 2019 15:26:13 +0100 Subject: [PATCH] Add counter for number of times task failed to lock --- src/scheduler.c | 2 ++ src/task.c | 17 ++++++++++++----- src/task.h | 3 +++ tools/task_plots/analyse_tasks.py | 2 +- tools/task_plots/plot_tasks.py | 2 +- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index fe9fb9a208..cb55aff8ff 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1083,6 +1083,7 @@ struct task *scheduler_addtask(struct scheduler *s, enum task_types type, #ifdef SWIFT_DEBUG_TASKS t->rid = -1; t->qtic = 0; + t->nr_locks = 0; #endif t->tic = 0; t->toc = 0; @@ -1583,6 +1584,7 @@ void scheduler_start(struct scheduler *s) { #ifdef SWIFT_DEBUG_TASKS s->tasks[i].rid = -1; s->tasks[i].qtic = 0; + s->tasks[i].nr_locks = 0; #endif } diff --git a/src/task.c b/src/task.c index 4a10e37ef4..d62772ee64 100644 --- a/src/task.c +++ b/src/task.c @@ -535,6 +535,11 @@ int task_lock(struct task *t) { MPI_Status stat; #endif +#ifdef SWIFT_DEBUG_TASKS + /* One more attempt to lock this. */ + t->nr_locks++; +#endif + switch (type) { /* Communication task? */ @@ -918,7 +923,7 @@ void task_dump_all(struct engine *e, int step) { /* Add some information to help with the plots and conversion of ticks to * seconds. */ - fprintf(file_thread, " %03d 0 0 0 0 %lld %lld %lld %lld %lld 0 0 0 %lld\n", + fprintf(file_thread, " %03d 0 0 0 0 %lld %lld %lld %lld %lld 0 0 0 0 %lld\n", engine_rank, (long long int)e->tic_step, (long long int)e->toc_step, e->updates, e->g_updates, e->s_updates, cpufreq); @@ -926,12 +931,13 @@ void task_dump_all(struct engine *e, int step) { for (int l = 0; l < e->sched.nr_tasks; l++) { if (!e->sched.tasks[l].implicit && e->sched.tasks[l].toc != 0) { fprintf( - file_thread, " %03i %i %i %i %i %lli %lli %lli %i %i %i %i %lli %i\n", + file_thread, " %03i %i %i %i %i %lli %lli %lli %zd %i %i %i %i %lli %i\n", engine_rank, e->sched.tasks[l].rid, e->sched.tasks[l].type, e->sched.tasks[l].subtype, (e->sched.tasks[l].cj == NULL), (long long int)e->sched.tasks[l].tic, (long long int)e->sched.tasks[l].toc, (long long int)e->sched.tasks[l].qtic, + e->sched.tasks[l].nr_locks, (e->sched.tasks[l].ci != NULL) ? e->sched.tasks[l].ci->hydro.count : 0, (e->sched.tasks[l].cj != NULL) ? e->sched.tasks[l].cj->hydro.count @@ -960,19 +966,20 @@ void task_dump_all(struct engine *e, int step) { /* Add some information to help with the plots and conversion of ticks to * seconds. */ - fprintf(file_thread, " %d %d %d %d %lld %lld %d %lld %lld %lld %d %lld\n", + fprintf(file_thread, " %d %d %d %d %lld %lld %d %d %lld %lld %lld %d %lld\n", -2, -1, -1, 1, (unsigned long long)e->tic_step, - (unsigned long long)e->toc_step, 0, e->updates, e->g_updates, + (unsigned long long)e->toc_step, 0, 0, e->updates, e->g_updates, e->s_updates, 0, cpufreq); for (int l = 0; l < e->sched.nr_tasks; l++) { if (!e->sched.tasks[l].implicit && e->sched.tasks[l].toc != 0) { fprintf( - file_thread, " %i %i %i %i %lli %lli %lli %i %i %i %i %i\n", + file_thread, " %i %i %i %i %lli %lli %lli %zi %i %i %i %i %i\n", e->sched.tasks[l].rid, e->sched.tasks[l].type, e->sched.tasks[l].subtype, (e->sched.tasks[l].cj == NULL), (unsigned long long)e->sched.tasks[l].tic, (unsigned long long)e->sched.tasks[l].toc, (unsigned long long)e->sched.tasks[l].qtic, + e->sched.tasks[l].nr_locks, (e->sched.tasks[l].ci == NULL) ? 0 : e->sched.tasks[l].ci->hydro.count, (e->sched.tasks[l].cj == NULL) ? 0 diff --git a/src/task.h b/src/task.h index 9a188e578d..75bd5fbecc 100644 --- a/src/task.h +++ b/src/task.h @@ -220,6 +220,9 @@ struct task { /*! Time when task was queued. */ ticks qtic; + + /* How many attempts to lock task. */ + size_t nr_locks; #endif /*! Start and end time of this task */ diff --git a/tools/task_plots/analyse_tasks.py b/tools/task_plots/analyse_tasks.py index 0a7382fc57..9935834ead 100755 --- a/tools/task_plots/analyse_tasks.py +++ b/tools/task_plots/analyse_tasks.py @@ -163,7 +163,7 @@ full_step = data[0, :] # Do we have an MPI file? full_step = data[0, :] -if full_step.size == 14: +if full_step.size == 15: print("# MPI mode") mpimode = True nranks = int(max(data[:, 0])) + 1 diff --git a/tools/task_plots/plot_tasks.py b/tools/task_plots/plot_tasks.py index 571d6a0763..dc91941879 100755 --- a/tools/task_plots/plot_tasks.py +++ b/tools/task_plots/plot_tasks.py @@ -366,7 +366,7 @@ data = pl.loadtxt(infile) # Do we have an MPI file? full_step = data[0, :] -if full_step.size == 14: +if full_step.size == 15: print("# MPI mode") mpimode = True if ranks == None: -- GitLab