diff --git a/src/scheduler.c b/src/scheduler.c index fe9fb9a208ac6a1a0d816c9c42d921f697d0b345..cb55aff8ffce895c0d75bca41f0857b317d01157 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 4a10e37ef432ec7be997e064b92d66ec5add3bd7..d62772ee64c4dff769b5ee7c1206ec893d8468cc 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 9a188e578d2e0d03c9d37af7ab54994abee2f4ac..75bd5fbecc58870920349c0458208dc64a0638da 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 0a7382fc5787cfcb0e870e0b63d717b167ca9843..9935834ead564bb479ec36b9f66794b1a98aee61 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 571d6a07630b3e9ec5c80e78bdd9f506a597b90d..dc91941879b549d2899bc7c4537a6b6b976b85f7 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: