From a248e67a0b7532cdc8aa2450bb93105ed74db7a1 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Thu, 18 Aug 2011 12:17:00 -0500 Subject: [PATCH] Add allocator kwarg to arange(). --- doc/source/array.rst | 5 ++++- pyopencl/array.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/source/array.rst b/doc/source/array.rst index ed84bc8c..48525e96 100644 --- a/doc/source/array.rst +++ b/doc/source/array.rst @@ -171,7 +171,7 @@ Constructing :class:`Array` Instances Make a new, zero-initialized :class:`Array` having the same properties as *other_ary*. -.. function:: arange(queue, start, stop, step, dtype=None) +.. function:: arange(queue, start, stop, step, dtype=None, allocator=None) Create a :class:`Array` filled with numbers spaced `step` apart, starting from `start` and ending at `stop`. @@ -186,6 +186,9 @@ Constructing :class:`Array` Instances .. versionchanged:: 2011.1 *context* argument was deprecated. + .. versionchanged:: 2011.2 + *allocator* keyword argument was added. + .. function:: take(a, indices, out=None, queue=None) Return the :class:`Array` ``[a[indices[0]], ..., a[indices[n]]]``. diff --git a/pyopencl/array.py b/pyopencl/array.py index 8581ffdc..b66b9169 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -733,6 +733,7 @@ def _arange(queue, *args, **kwargs): inf.stop = None inf.step = None inf.dtype = None + inf.allocator = None if isinstance(args[-1], np.dtype): dtype = args[-1] @@ -754,7 +755,7 @@ def _arange(queue, *args, **kwargs): else: raise ValueError, "too many arguments" - admissible_names = ["start", "stop", "step", "dtype"] + admissible_names = ["start", "stop", "step", "dtype", "allocator"] for k, v in kwargs.iteritems(): if k in admissible_names: if getattr(inf, k) is None: @@ -785,7 +786,7 @@ def _arange(queue, *args, **kwargs): from math import ceil size = int(ceil((stop-start)/step)) - result = Array(queue, (size,), dtype) + result = Array(queue, (size,), dtype, allocator=inf.allocator) _arange_knl(result, start, step, queue=queue) return result -- GitLab