diff --git a/pyopencl/array.py b/pyopencl/array.py index 38eabdb31d129f6f681cbdd3b4c9477d85f8ac25..981e5f245e08ff55c3f9ab23fa02ccef697810fa 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -151,6 +151,9 @@ def elwise_kernel_runner(kernel_getter): actual_args = [] for arg in args: if isinstance(arg, Array): + if not arg.flags.forc: + raise RuntimeError("only contiguous arrays may " + "be used as arguments to this operation") actual_args.append(arg.data) else: actual_args.append(arg) diff --git a/pyopencl/elementwise.py b/pyopencl/elementwise.py index 6bcdc004e8ad7d4e3368d02d58228599d94b1ced..8e77fb80023bd0c4d913674eae610d29358a6e29 100644 --- a/pyopencl/elementwise.py +++ b/pyopencl/elementwise.py @@ -142,6 +142,10 @@ class ElementwiseKernel: invocation_args = [] for arg, arg_descr in zip(args, self.arguments): if isinstance(arg_descr, VectorArg): + if not arg.flags.forc: + raise RuntimeError("ElementwiseKernel cannot " + "deal with non-contiguous arrays") + vectors.append(arg) invocation_args.append(arg.data) else: diff --git a/pyopencl/reduction.py b/pyopencl/reduction.py index 11d2e4102f427f3ec105e8bc0796d013b12d13f5..31e29b93c5fde985afa8c984b527d2cfa6613c28 100644 --- a/pyopencl/reduction.py +++ b/pyopencl/reduction.py @@ -291,6 +291,10 @@ class ReductionKernel: from pyopencl.tools import VectorArg for arg, arg_tp in zip(args, stage_inf.arg_types): if isinstance(arg_tp, VectorArg): + if not arg.flags.forc: + raise RuntimeError("ReductionKernel cannot " + "deal with non-contiguous arrays") + vectors.append(arg) invocation_args.append(arg.data) else: diff --git a/pyopencl/scan.py b/pyopencl/scan.py index ee6f74fe64c389ac70480aba40e5edbec868bb4d..24d14569e6611b53edc4e9fe8d52192f31d16423 100644 --- a/pyopencl/scan.py +++ b/pyopencl/scan.py @@ -442,6 +442,10 @@ if _CL_MODE: if input_ary.shape != output_ary.shape: raise ValueError("input and output must have the same shape") + if not input_ary.flags.forc: + raise RuntimeError("ScanKernel cannot " + "deal with non-contiguous arrays") + n, = input_ary.shape if not n: @@ -542,6 +546,10 @@ else: if input_ary.shape != output_ary.shape: raise ValueError("input and output must have the same shape") + if not input_ary.flags.forc: + raise RuntimeError("ScanKernel cannot " + "deal with non-contiguous arrays") + n, = input_ary.shape if not n: