From e00fb2f45a1cdbb643abb594e03ef4c28632b255 Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <gonnet@google.com>
Date: Thu, 2 Jun 2016 22:51:07 +0200
Subject: [PATCH] made engine_count_and_link_tasks parallel with the
 threadpool, required some minor fixes.

---
 src/engine.c     | 1 -
 src/scheduler.c  | 3 ---
 src/task.c       | 2 +-
 src/threadpool.c | 4 +---
 4 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index 7b2d490570..665b32a0c4 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -1456,7 +1456,6 @@ void engine_maketasks(struct engine *e) {
      of its super-cell. */
   threadpool_map(&e->threadpool, engine_make_extra_hydroloop_tasks_mapper,
                  sched->tasks, sched->nr_tasks, sizeof(struct task), e);
-  // engine_make_extra_hydroloop_tasks(e);
 
   /* Add the communication tasks if MPI is being used. */
   if (e->policy & engine_policy_mpi) {
diff --git a/src/scheduler.c b/src/scheduler.c
index 75b3e19627..9ee41c928d 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -729,15 +729,12 @@ void scheduler_set_unlocks(struct scheduler *s) {
   offsets[0] = 0;
   for (int k = 1; k < s->nr_tasks; k++)
     offsets[k] = offsets[k - 1] + counts[k - 1];
-  for (int k = 0; k < s->nr_tasks; k++)
-    for (int j = offsets[k]; j < offsets[k + 1]; j++) s->unlock_ind[j] = k;
 
   /* Set the unlocks in the tasks. */
   for (int k = 0; k < s->nr_tasks; k++) {
     struct task *t = &s->tasks[k];
     t->nr_unlock_tasks = counts[k];
     t->unlock_tasks = &s->unlocks[offsets[k]];
-    for (int j = offsets[k]; j < offsets[k + 1]; j++) s->unlock_ind[j] = k;
   }
 
   /* Verify that there are no duplicate unlocks. */
diff --git a/src/task.c b/src/task.c
index f7a04454b7..c8f69681c8 100644
--- a/src/task.c
+++ b/src/task.c
@@ -49,7 +49,7 @@
 const char *taskID_names[task_type_count] = {
     "none",    "sort",    "self",      "pair",          "sub",       "init",
     "ghost",   "drift",   "kick",      "send",          "recv",      "grav_pp",
-    "grav_mm", "grav_up", "grav_down", "grav_external", "comm_root "};
+    "grav_mm", "grav_up", "grav_down", "grav_external", "comm_root"};
 
 const char *subtaskID_names[task_type_count] = {"none",  "density",
                                                 "force", "grav"};
diff --git a/src/threadpool.c b/src/threadpool.c
index 72a33639db..691678718e 100644
--- a/src/threadpool.c
+++ b/src/threadpool.c
@@ -50,9 +50,7 @@ void *threadpool_runner(void *data) {
 
     /* Wait for a signal. */
     pthread_mutex_lock(&tp->thread_mutex);
-    do {
-      pthread_cond_wait(&tp->thread_cond, &tp->thread_mutex);
-    } while (tp->map_function == NULL);
+    pthread_cond_wait(&tp->thread_cond, &tp->thread_mutex);
     pthread_mutex_unlock(&tp->thread_mutex);
 
     /* The index of the mapping task we will work on next. */
-- 
GitLab