From 60761ff2d2b0fcc53003e423b0abe3c5f4f30dcf Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Fri, 27 Jul 2012 00:35:30 -0400 Subject: [PATCH] Test, fix scan index preservation property. --- pyopencl/scan.py | 2 +- test/test_array.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pyopencl/scan.py b/pyopencl/scan.py index 5ad6903f..efd2a1ae 100644 --- a/pyopencl/scan.py +++ b/pyopencl/scan.py @@ -312,7 +312,7 @@ void ${name_prefix}_scan_intervals( } else %endif - sum = SCAN_EXPR(tmp, sum); + sum = SCAN_EXPR(sum, tmp); ldata[k][LID_0] = sum; } diff --git a/test/test_array.py b/test/test_array.py index 7198ff38..44bdeb31 100644 --- a/test/test_array.py +++ b/test/test_array.py @@ -908,6 +908,28 @@ def test_unique(ctx_factory): assert (a_unique_dev.get()[:count_unique_dev] == a_unique_host).all() +@pytools.test.mark_test.opencl +def test_index_preservation(ctx_factory): + context = ctx_factory() + queue = cl.CommandQueue(context) + + for n in scan_test_counts: + + from pyopencl.scan import GenericScanKernel + knl = GenericScanKernel( + context, np.int32, + arguments="__global int *out", + input_expr="i", + scan_expr="b", neutral="0", + output_statement=""" + out[i] = item; + """) + + out = cl_array.empty(queue, n, dtype=np.int32) + knl(out) + + assert (out.get() == np.arange(n)).all() + @pytools.test.mark_test.opencl def test_segmented_scan(ctx_factory): context = ctx_factory() -- GitLab