diff --git a/doc/array.rst b/doc/array.rst index 25d1a421d5f0f1f2f58298de5d81a66d35242bdf..0b0168b6a571a7bb6d36fa6f7f5dca1f0121e140 100644 --- a/doc/array.rst +++ b/doc/array.rst @@ -276,10 +276,3 @@ Generating Arrays of Random Numbers .. autofunction:: rand .. autofunction:: fill_rand - -GPGPU Algorithms ----------------- - -Bogdan Opanchuk's `reikna `_ offers a -variety of GPU-based algorithms (FFT, RNG, matrix multiplication) designed to work with -:class:`pyopencl.array.Array` objects. diff --git a/doc/index.rst b/doc/index.rst index 142171581e3b41cd6c926c2920cb419222fc4a1a..733f37ecd0af127b5acf353ef6e8ffcea1175bd7 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -61,6 +61,19 @@ Tutorials `Problem set 2 `_ * Ian Johnson's `PyOpenCL tutorial `_. +Software that works with or enhances PyOpenCL +============================================= + +* Bogdan Opanchuk's `reikna `_ offers a + variety of GPU-based algorithms (FFT, random number generation, matrix + multiplication) designed to work with :class:`pyopencl.array.Array` objects. + +* Gregor Thalhammer's `gpyfft `_ provides a + Python wrapper for the OpenCL FFT library clFFT from AMD. + +If you know of a piece of software you feel that should be on this list, please +let me know, or, even better, send a patch! + Contents ======== diff --git a/doc/misc.rst b/doc/misc.rst index 077c2f403b490c2caa56a04aab9771ce10c39ad4..1785d511271873234bd9ce8f79b037be484b7e08 100644 --- a/doc/misc.rst +++ b/doc/misc.rst @@ -74,7 +74,7 @@ C interface to Python: Interoperability with other OpenCL software ------------------------------------------- -Just about every object in :mod:`pyopncl` supports the following +Just about every object in :mod:`pyopencl` supports the following interface (here shown as an example for :class:`pyopencl.MemoryObject`, from which :class:`pyopencl.Buffer` and :class:`pyopencl.Image` inherit): diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index a3a5555a027bf81ef2b3e7defb20b430d2409c4d..b9751a66fcb2ab86364dcf8c235dc758be20ffae 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -337,8 +337,14 @@ def _add_functionality(): return "" % ( self.name.strip(), self.platform.name.strip(), self.int_ptr) + def device_persistent_unique_id(self): + return (self.vendor, self.vendor_id, self.name, self.version) + Device.__repr__ = device_repr + # undocumented for now: + Device.persistent_unique_id = property(device_persistent_unique_id) + # }}} # {{{ Context diff --git a/pyopencl/array.py b/pyopencl/array.py index 2139c8be38cf44139bed800c47558125d5f504e4..f72543a212d7fa4d1f6b0ce166507878f824e2b7 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -823,7 +823,7 @@ class Array(object): else: # add a scalar if other == 0: - return self + return self.copy() else: common_dtype = _get_common_dtype(self, other, self.queue) result = self._new_like_me(common_dtype) @@ -846,7 +846,7 @@ class Array(object): else: # subtract a scalar if other == 0: - return self + return self.copy() else: result = self._new_like_me( _get_common_dtype(self, other, self.queue)) @@ -927,7 +927,7 @@ class Array(object): self._div(result, self, other) else: if other == 1: - return self + return self.copy() else: # create a new array for the result common_dtype = _get_common_dtype(self, other, self.queue) @@ -1020,9 +1020,9 @@ class Array(object): return result def astype(self, dtype, queue=None): - """Return *self*, cast to *dtype*.""" + """Return a copy of *self*, cast to *dtype*.""" if dtype == self.dtype: - return self + return self.copy() result = self._new_like_me(dtype=dtype) self._copy(result, self, queue=queue) @@ -1173,6 +1173,10 @@ class Array(object): # TODO: add more error-checking, perhaps if isinstance(shape[0], tuple) or isinstance(shape[0], list): shape = tuple(shape[0]) + + if shape == self.shape: + return self + size = reduce(lambda x, y: x * y, shape, 1) if size != self.size: raise ValueError("total size of new array must be unchanged") diff --git a/pyopencl/compyte b/pyopencl/compyte index b48cd3b576bbcb8c87afdc23c4686a19ed3fafe3..6ccb955b0d38faffeb7dd5bf913e6bedf46ee226 160000 --- a/pyopencl/compyte +++ b/pyopencl/compyte @@ -1 +1 @@ -Subproject commit b48cd3b576bbcb8c87afdc23c4686a19ed3fafe3 +Subproject commit 6ccb955b0d38faffeb7dd5bf913e6bedf46ee226