diff --git a/pycuda/gpuarray.py b/pycuda/gpuarray.py index 97630e3bdeb572e2d881deeea840d1ff1bce3cc0..a1a3f3f34848f9e1ca7eb7b9da2b31098cb0cb65 100644 --- a/pycuda/gpuarray.py +++ b/pycuda/gpuarray.py @@ -627,6 +627,10 @@ class GPUArray: def fill(self, value, stream=None): """fills the array with the specified value""" + if not self.flags.forc: + raise RuntimeError( + "only contiguous arrays may be used as arguments to this operation") + func = elementwise.get_fill_kernel(self.dtype) func.prepared_async_call( self._grid, self._block, stream, value, self.gpudata, self.mem_size @@ -650,8 +654,7 @@ class GPUArray: ): if not self.flags.forc: raise RuntimeError( - "only contiguous arrays may " "be used as arguments to this operation" - ) + "only contiguous arrays may be used as arguments to this operation") if self.dtype == np.float64 and allow_double_hack: if channels != 1: diff --git a/test/test_gpuarray.py b/test/test_gpuarray.py index fb6a20fcffc6943bf814d8a2fb0d421ba17cb8f9..fc7b67366c509089fd3a26b4e3c183fde1ca9269 100644 --- a/test/test_gpuarray.py +++ b/test/test_gpuarray.py @@ -1192,6 +1192,9 @@ class TestGPUArray: contig = arr.flags.c_contiguous or arr.flags.f_contiguous + if not contig: + continue + # Output matches order of input. # Non-contiguous becomes C-contiguous new_z = func(arr, order="A")