diff --git a/doc/source/array.rst b/doc/source/array.rst index 460eeba9f0d4f4e980e7412a030a58b9cc1a3423..8aac8592f4f561f644697e56d4fea065007114cc 100644 --- a/doc/source/array.rst +++ b/doc/source/array.rst @@ -151,11 +151,6 @@ The :class:`Array` Class The number of meaningful entries in the array. Can also be computed by multiplying up the numbers in :attr:`shape`. - .. attribute :: mem_size - - The total number of entries, including padding, that are present in - the array. - .. attribute :: nbytes The size of the entire array in bytes. Computed as :attr:`size` times diff --git a/pyopencl/array.py b/pyopencl/array.py index 7652a0877ad63a9d029d109b8a8260dc1277aa52..4a7c6a79029a0127af18194535e85b25476e4b51 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -173,7 +173,7 @@ def elwise_kernel_runner(kernel_getter): actual_args.append(arg.data) else: actual_args.append(arg) - actual_args.append(repr_ary.mem_size) + actual_args.append(repr_ary.size) return knl(queue, gs, ls, *actual_args) @@ -279,6 +279,7 @@ class Array(object): dtype.itemsize, shape) else: raise ValueError("invalid order: %s" % order) + else: # FIXME: We should possibly perform some plausibility # checking on 'strides' here. @@ -292,7 +293,7 @@ class Array(object): self.dtype = dtype self.strides = strides - self.mem_size = self.size = s + self.size = s self.nbytes = self.dtype.itemsize * self.size self.allocator = allocator @@ -315,6 +316,12 @@ class Array(object): def flags(self): return _ArrayFlags(self) + @property + def mem_size(self): + from warnings import warn + warn("Array.mem_size is deprecated. Use Array.size", + DeprecationWarning, stacklevel=2) + def _new_with_changes(self, data, shape=None, dtype=None, strides=None, queue=None, base=None): if shape is None: @@ -339,7 +346,9 @@ class Array(object): #@memoize_method FIXME: reenable def get_sizes(self, queue, kernel_specific_max_wg_size=None): - return splay(queue, self.mem_size, + if not self.flags.forc: + raise NotImplementedError("cannot operate on non-contiguous array") + return splay(queue, self.size, kernel_specific_max_wg_size=kernel_specific_max_wg_size) def set(self, ary, queue=None, async=False): @@ -829,6 +838,19 @@ class Array(object): # }}} +def as_strided(ary, shape=None, strides=None): + """Make an :class:`Array` from the given array with the given + shape and strides. + """ + + # undocumented for the moment + + shape = shape or ary.shape + strides = strides or ary.strides + + return Array(ary.queue, shape, ary.dtype, allocator=ary.allocator, + base=ary.base, data=ary.data, strides=strides) + # }}} # {{{ creation helpers diff --git a/pyopencl/compyte b/pyopencl/compyte index 53318d27b76a7a070b8576c59d48c872371bc5f2..024cb8b653c7831699a1dbf0f26585fe309ff05b 160000 --- a/pyopencl/compyte +++ b/pyopencl/compyte @@ -1 +1 @@ -Subproject commit 53318d27b76a7a070b8576c59d48c872371bc5f2 +Subproject commit 024cb8b653c7831699a1dbf0f26585fe309ff05b diff --git a/pyopencl/elementwise.py b/pyopencl/elementwise.py index 52318be382d973085ab300313e4e5ce76b79ecdd..75baa22eb7763a3c76fabdb3a59c0ff828f31dee 100644 --- a/pyopencl/elementwise.py +++ b/pyopencl/elementwise.py @@ -260,7 +260,7 @@ class ElementwiseKernel: abs(range_.stop - range_.start)//step, max_wg_size) else: - invocation_args.append(repr_vec.mem_size) + invocation_args.append(repr_vec.size) gs, ls = repr_vec.get_sizes(queue, max_wg_size) kernel.set_args(*invocation_args)