From 628c6b27d6864d06b1a0f85ce63942fcbf9c2b7c Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Mon, 28 Jan 2019 13:40:04 +0000
Subject: [PATCH] Fix up code that checks the threadpool results to a serial
 version

---
 src/partition.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/partition.c b/src/partition.c
index 0584fab8df..1dde46dcd4 100644
--- a/src/partition.c
+++ b/src/partition.c
@@ -2094,6 +2094,7 @@ static void check_weights(struct task *tasks, int nr_tasks,
   int nr_cells = mydata->nr_cells;
   int timebins = mydata->timebins;
   int vweights = mydata->vweights;
+  int use_ticks = mydata->use_ticks;
 
   struct cell *cells = mydata->cells;
 
@@ -2118,10 +2119,18 @@ static void check_weights(struct task *tasks, int nr_tasks,
     struct task *t = &tasks[j];
 
     /* Skip un-interesting tasks. */
-    if (t->cost == 0.f) continue;
+    if (t->type == task_type_send || t->type == task_type_recv ||
+        t->type == task_type_logger || t->implicit || t->ci == NULL)
+      continue;
 
-    /* Get the task weight based on costs. */
-    double w = (double)t->cost;
+    /* Get weight for this task. Either based on fixed costs or task timings. */
+    double w = 0.0;
+    if (use_ticks) {
+      w = (double)t->toc - (double)t->tic;
+    } else {
+      w = repartition_costs[t->type][t->subtype];
+    }
+    if (w <= 0.0) continue;
 
     /* Get the top-level cells involved. */
     struct cell *ci, *cj;
-- 
GitLab