Revert "add reduce_only option to prefix_sum_ops"
authorJacob Lifshay <programmerjake@gmail.com>
Fri, 22 Apr 2022 22:01:09 +0000 (15:01 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Fri, 22 Apr 2022 22:01:09 +0000 (15:01 -0700)
it doesn't work when the element count isn't a power-of-2

This reverts commit c4357f7839c612a9c560a2bda14c34af6adee87b.

src/nmutil/prefix_sum.py

index a1ffe85ec5c096f18494663b16beded21cef3a28..4aa89b2a3239fd3edf55792f236b30b3e486f60a 100644 (file)
@@ -25,7 +25,7 @@ class Op:
     """row in the prefix-sum diagram"""
 
 
-def prefix_sum_ops(item_count, *, work_efficient=False, reduce_only=False):
+def prefix_sum_ops(item_count, *, work_efficient=False):
     """ Get the associative operations needed to compute a parallel prefix-sum
     of `item_count` items.
 
@@ -45,9 +45,6 @@ def prefix_sum_ops(item_count, *, work_efficient=False, reduce_only=False):
         True if the algorithm used should be work-efficient -- has a larger
         depth (about twice as large) but does only `O(N)` operations total
         instead of `O(N*log(N))`.
-    reduce_only: bool
-        True if the work-efficient algorithm should stop after the initial
-        tree-reduction step.
     Returns: Iterable[Op]
         output associative operations.
     """
@@ -64,7 +61,7 @@ def prefix_sum_ops(item_count, *, work_efficient=False, reduce_only=False):
             yield Op(out=i, lhs=i - dist, rhs=i, row=row)
         dist <<= 1
         row += 1
-    if work_efficient and not reduce_only:
+    if work_efficient:
         # express all output items in terms of the computed partial sums.
         dist >>= 1
         while dist >= 1: