From 4ee1372b3ce9d16913f9ce7984ba9ef63870267e Mon Sep 17 00:00:00 2001
From: Ben Cumming <bcumming@cscs.ch>
Date: Thu, 23 May 2019 09:29:53 +0200
Subject: [PATCH] fix spurious compile time assertionsin GPU matrix solver
 (#752)

---
 arbor/algorithms.hpp                     | 9 +++++----
 arbor/backends/gpu/forest.cpp            | 1 +
 arbor/backends/gpu/matrix_state_fine.hpp | 3 ---
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arbor/algorithms.hpp b/arbor/algorithms.hpp
index a2ec968a..ec4b2dc4 100644
--- a/arbor/algorithms.hpp
+++ b/arbor/algorithms.hpp
@@ -96,9 +96,10 @@ bool is_strictly_monotonic_decreasing(C const& c)
     );
 }
 
-// check if c[0] == 0 and c[i] < 0 holds for i != 0
-// this means that children of a node always have larger indices than their
-// parent
+// Check if c[0] == 0 and c[i] < 0 holds for i != 0
+// Also handle the valid case of c[0]==value_type(-1)
+// This means that children of a node always have larger indices than their
+// parent.
 template <
     typename C,
     typename = typename std::enable_if<std::is_integral<typename C::value_type>::value>
@@ -115,7 +116,7 @@ bool is_minimal_degree(C const& c)
     }
 
     using value_type = typename C::value_type;
-    if (c[0] != value_type(0)) {
+    if (!(c[0]==value_type(0) || c[0]==value_type(-1))) {
         return false;
     }
     auto i = value_type(1);
diff --git a/arbor/backends/gpu/forest.cpp b/arbor/backends/gpu/forest.cpp
index 6650b92c..09a200a6 100644
--- a/arbor/backends/gpu/forest.cpp
+++ b/arbor/backends/gpu/forest.cpp
@@ -1,4 +1,5 @@
 #include "backends/gpu/forest.hpp"
+#include "tree.hpp"
 #include "util/span.hpp"
 
 namespace arb {
diff --git a/arbor/backends/gpu/matrix_state_fine.hpp b/arbor/backends/gpu/matrix_state_fine.hpp
index 87ebf2ae..6790c1e8 100644
--- a/arbor/backends/gpu/matrix_state_fine.hpp
+++ b/arbor/backends/gpu/matrix_state_fine.hpp
@@ -149,9 +149,6 @@ public:
 
         max_branches_per_level = 128;
 
-        // for now we have single cell per cell group
-        arb_assert(cell_cv_divs.size()==2);
-
         num_cells = cell_cv_divs.size()-1;
 
         forest trees(p, cell_cv_divs);
-- 
GitLab