pyopencl 2023.1.4__tar.gz → 2024.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyopencl might be problematic. Click here for more details.
- {pyopencl-2023.1.4 → pyopencl-2024.2}/CITATION.cff +1 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/LICENSE +0 -23
- {pyopencl-2023.1.4 → pyopencl-2024.2}/PKG-INFO +12 -12
- {pyopencl-2023.1.4 → pyopencl-2024.2}/README.rst +9 -10
- {pyopencl-2023.1.4 → pyopencl-2024.2}/aksetup_helper.py +15 -6
- {pyopencl-2023.1.4 → pyopencl-2024.2}/configure.py +2 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/contrib/cldis.py +4 -4
- {pyopencl-2023.1.4 → pyopencl-2024.2}/contrib/fortran-to-opencl/translate.py +14 -17
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/Makefile +1 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/conf.py +2 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/make_constants.py +2 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/runtime_platform.rst +6 -13
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/runtime_program.rst +12 -6
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/black-hole-accretion.py +6 -4
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/demo-struct-reduce.py +5 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/demo.py +8 -4
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/demo_array.py +8 -4
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/demo_array_svm.py +8 -4
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/demo_elementwise.py +6 -4
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/demo_elementwise_complex.py +12 -6
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/demo_meta_codepy.py +14 -13
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/demo_meta_template.py +10 -8
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/dump-properties.py +3 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/gl_interop_demo.py +3 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/gl_particle_animation.py +68 -59
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/median-filter.py +1 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/n-body.py +5 -3
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/narray.py +3 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/pi-monte-carlo.py +6 -5
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/svm.py +5 -3
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/transpose.py +18 -23
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/__init__.py +82 -80
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/algorithm.py +8 -10
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/array.py +16 -12
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/bitonic_sort.py +5 -4
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cache.py +22 -22
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/capture_call.py +4 -3
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/characterize/__init__.py +4 -2
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/characterize/performance.py +2 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/clmath.py +2 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/clrandom.py +5 -369
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cltypes.py +4 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/compyte/ndarray/gen_elemwise.py +6 -5
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/compyte/ndarray/gen_reduction.py +6 -6
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/compyte/ndarray/setup_opencl.py +3 -2
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/compyte/ndarray/test_gpu_elemwise.py +5 -4
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/compyte/ndarray/test_gpu_ndarray.py +0 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/elementwise.py +4 -6
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/invoker.py +15 -9
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/ipython_ext.py +1 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/reduction.py +5 -5
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/scan.py +17 -21
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/tools.py +13 -16
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/version.py +1 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl.egg-info/PKG-INFO +12 -12
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl.egg-info/SOURCES.txt +0 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl.egg-info/requires.txt +4 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyproject.toml +9 -3
- {pyopencl-2023.1.4 → pyopencl-2024.2}/setup.cfg +7 -3
- {pyopencl-2023.1.4 → pyopencl-2024.2}/setup.py +79 -102
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/tools.hpp +3 -3
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/wrap_cl.cpp +2 -2
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/wrap_cl.hpp +164 -118
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/wrap_cl_part_1.cpp +29 -37
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/wrap_cl_part_2.cpp +97 -130
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/wrap_constants.cpp +40 -36
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/wrap_helpers.hpp +21 -9
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/wrap_mempool.cpp +31 -22
- {pyopencl-2023.1.4 → pyopencl-2024.2}/test/test_algorithm.py +13 -11
- {pyopencl-2023.1.4 → pyopencl-2024.2}/test/test_array.py +84 -52
- {pyopencl-2023.1.4 → pyopencl-2024.2}/test/test_arrays_in_structs.py +2 -2
- {pyopencl-2023.1.4 → pyopencl-2024.2}/test/test_clmath.py +7 -5
- {pyopencl-2023.1.4 → pyopencl-2024.2}/test/test_clrandom.py +4 -16
- {pyopencl-2023.1.4 → pyopencl-2024.2}/test/test_enqueue_copy.py +3 -3
- {pyopencl-2023.1.4 → pyopencl-2024.2}/test/test_wrapper.py +43 -11
- pyopencl-2023.1.4/pyopencl/cl/pyopencl-ranluxcl.cl +0 -957
- {pyopencl-2023.1.4 → pyopencl-2024.2}/MANIFEST.in +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/Makefile.in +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/README_SETUP.txt +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/contrib/fortran-to-opencl/README +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/contrib/pyopencl.vim +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/algorithm.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/array.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/howto.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/index.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/misc.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/runtime.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/runtime_const.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/runtime_gl.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/runtime_memory.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/runtime_queue.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/subst.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/tools.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/doc/types.rst +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/demo_mandelbrot.py +1 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/dump-performance.py +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/ipython-demo.ipynb +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/examples/noisyImage.jpg +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/_cluda.py +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/_mymako.py +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/bitonic_sort_templates.py +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cl/pyopencl-airy.cl +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cl/pyopencl-bessel-j-complex.cl +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cl/pyopencl-bessel-j.cl +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cl/pyopencl-bessel-y.cl +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cl/pyopencl-complex.h +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cl/pyopencl-eval-tbl.cl +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cl/pyopencl-hankel-complex.cl +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cl/pyopencl-random123/array.h +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cl/pyopencl-random123/openclfeatures.h +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cl/pyopencl-random123/philox.cl +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/cl/pyopencl-random123/threefry.cl +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/compyte/__init__.py +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/compyte/array.py +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/compyte/dtypes.py +1 -1
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl/compyte/ndarray/__init__.py +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl.egg-info/dependency_links.txt +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl.egg-info/not-zip-safe +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pyopencl.egg-info/top_level.txt +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/pytest.ini +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/bitlog.cpp +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/bitlog.hpp +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/clinfo_ext.h +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/mempool.hpp +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/src/pyopencl_ext.h +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/test/add-vectors-32.spv +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/test/add-vectors-64.spv +0 -0
- {pyopencl-2023.1.4 → pyopencl-2024.2}/test/empty-header.h +0 -0
|
@@ -78,26 +78,3 @@ PyOpenCL includes parts of the Random123 suite of random number generators:
|
|
|
78
78
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
79
79
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
80
80
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
81
|
-
|
|
82
|
-
PyOpenCL includes the RANLUXCL random number generator:
|
|
83
|
-
|
|
84
|
-
Copyright (c) 2011 Ivar Ursin Nikolaisen
|
|
85
|
-
|
|
86
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
87
|
-
software and associated documentation files (the "Software"), to deal in the Software
|
|
88
|
-
without restriction, including without limitation the rights to use, copy, modify,
|
|
89
|
-
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
|
90
|
-
permit persons to whom the Software is furnished to do so, subject to the following
|
|
91
|
-
conditions:
|
|
92
|
-
|
|
93
|
-
The above copyright notice and this permission notice shall be included in all copies
|
|
94
|
-
or substantial portions of the Software.
|
|
95
|
-
|
|
96
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
97
|
-
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
98
|
-
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
99
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
100
|
-
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
|
101
|
-
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
102
|
-
|
|
103
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyopencl
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2024.2
|
|
4
4
|
Summary: Python wrapper for OpenCL
|
|
5
5
|
Home-page: http://mathema.tician.de/software/pyopencl
|
|
6
6
|
Author: Andreas Kloeckner
|
|
@@ -22,8 +22,9 @@ Classifier: Topic :: Scientific/Engineering :: Physics
|
|
|
22
22
|
Requires-Python: ~=3.8
|
|
23
23
|
License-File: LICENSE
|
|
24
24
|
Requires-Dist: numpy
|
|
25
|
-
Requires-Dist: pytools>=
|
|
25
|
+
Requires-Dist: pytools>=2022.1.13
|
|
26
26
|
Requires-Dist: platformdirs>=2.2.0
|
|
27
|
+
Requires-Dist: importlib-resources; python_version < "3.9"
|
|
27
28
|
Provides-Extra: pocl
|
|
28
29
|
Requires-Dist: pocl_binary_distribution>=1.2; extra == "pocl"
|
|
29
30
|
Provides-Extra: oclgrind
|
|
@@ -35,19 +36,21 @@ Requires-Dist: Mako; extra == "test"
|
|
|
35
36
|
PyOpenCL: Pythonic Access to OpenCL, with Arrays and Algorithms
|
|
36
37
|
===============================================================
|
|
37
38
|
|
|
38
|
-
.. image:: https://gitlab.tiker.net/inducer/pyopencl/badges/main/pipeline.svg
|
|
39
|
+
.. |badge-gitlab-ci| image:: https://gitlab.tiker.net/inducer/pyopencl/badges/main/pipeline.svg
|
|
39
40
|
:alt: Gitlab Build Status
|
|
40
41
|
:target: https://gitlab.tiker.net/inducer/pyopencl/commits/main
|
|
41
|
-
.. image:: https://github.com/inducer/pyopencl/workflows/CI/badge.svg?branch=main&event=push
|
|
42
|
+
.. |badge-github-ci| image:: https://github.com/inducer/pyopencl/workflows/CI/badge.svg?branch=main&event=push
|
|
42
43
|
:alt: Github Build Status
|
|
43
44
|
:target: https://github.com/inducer/pyopencl/actions?query=branch%3Amain+workflow%3ACI+event%3Apush
|
|
44
|
-
.. image:: https://badge.fury.io/py/pyopencl.svg
|
|
45
|
+
.. |badge-pypi| image:: https://badge.fury.io/py/pyopencl.svg
|
|
45
46
|
:alt: Python Package Index Release Page
|
|
46
47
|
:target: https://pypi.org/project/pyopencl/
|
|
47
|
-
.. image:: https://zenodo.org/badge/1575307.svg
|
|
48
|
+
.. |badge-zenodo| image:: https://zenodo.org/badge/1575307.svg
|
|
48
49
|
:alt: Zenodo DOI for latest release
|
|
49
50
|
:target: https://zenodo.org/badge/latestdoi/1575307
|
|
50
51
|
|
|
52
|
+
|badge-gitlab-ci| |badge-github-ci| |badge-pypi| |badge-zenodo|
|
|
53
|
+
|
|
51
54
|
PyOpenCL lets you access GPUs and other massively parallel compute
|
|
52
55
|
devices from Python. It tries to offer computing goodness in the
|
|
53
56
|
spirit of its sister project `PyCUDA <https://mathema.tician.de/software/pycuda>`__:
|
|
@@ -84,8 +87,7 @@ can be found in the `documentation <https://documen.tician.de/pyopencl/>`__.
|
|
|
84
87
|
What you'll need if you do *not* want to use the convenient instructions above and
|
|
85
88
|
instead build from source:
|
|
86
89
|
|
|
87
|
-
*
|
|
88
|
-
(see their `FAQ <https://pybind11.readthedocs.io/en/stable/faq.html>`__)
|
|
90
|
+
* g++/clang new enough to be compatible with nanobind (specifically, full support of C++17 is needed)
|
|
89
91
|
* `numpy <https://numpy.org>`__, and
|
|
90
92
|
* an OpenCL implementation. (See this `howto <https://wiki.tiker.net/OpenCLHowTo>`__
|
|
91
93
|
for how to get one.)
|
|
@@ -95,11 +97,9 @@ Links
|
|
|
95
97
|
|
|
96
98
|
* `Documentation <https://documen.tician.de/pyopencl>`__
|
|
97
99
|
(read how things work)
|
|
100
|
+
* `Python package index <https://pypi.python.org/pypi/pyopencl>`__
|
|
101
|
+
(download releases, including binary wheels for Linux, macOS, Windows)
|
|
98
102
|
* `Conda Forge <https://anaconda.org/conda-forge/pyopencl>`__
|
|
99
103
|
(download binary packages for Linux, macOS, Windows)
|
|
100
|
-
* `Python package index <https://pypi.python.org/pypi/pyopencl>`__
|
|
101
|
-
(download releases)
|
|
102
|
-
* `C. Gohlke's Windows binaries <https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl>`__
|
|
103
|
-
(download Windows binaries)
|
|
104
104
|
* `Github <https://github.com/inducer/pyopencl>`__
|
|
105
105
|
(get latest source code, file bugs)
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
PyOpenCL: Pythonic Access to OpenCL, with Arrays and Algorithms
|
|
2
2
|
===============================================================
|
|
3
3
|
|
|
4
|
-
.. image:: https://gitlab.tiker.net/inducer/pyopencl/badges/main/pipeline.svg
|
|
4
|
+
.. |badge-gitlab-ci| image:: https://gitlab.tiker.net/inducer/pyopencl/badges/main/pipeline.svg
|
|
5
5
|
:alt: Gitlab Build Status
|
|
6
6
|
:target: https://gitlab.tiker.net/inducer/pyopencl/commits/main
|
|
7
|
-
.. image:: https://github.com/inducer/pyopencl/workflows/CI/badge.svg?branch=main&event=push
|
|
7
|
+
.. |badge-github-ci| image:: https://github.com/inducer/pyopencl/workflows/CI/badge.svg?branch=main&event=push
|
|
8
8
|
:alt: Github Build Status
|
|
9
9
|
:target: https://github.com/inducer/pyopencl/actions?query=branch%3Amain+workflow%3ACI+event%3Apush
|
|
10
|
-
.. image:: https://badge.fury.io/py/pyopencl.svg
|
|
10
|
+
.. |badge-pypi| image:: https://badge.fury.io/py/pyopencl.svg
|
|
11
11
|
:alt: Python Package Index Release Page
|
|
12
12
|
:target: https://pypi.org/project/pyopencl/
|
|
13
|
-
.. image:: https://zenodo.org/badge/1575307.svg
|
|
13
|
+
.. |badge-zenodo| image:: https://zenodo.org/badge/1575307.svg
|
|
14
14
|
:alt: Zenodo DOI for latest release
|
|
15
15
|
:target: https://zenodo.org/badge/latestdoi/1575307
|
|
16
16
|
|
|
17
|
+
|badge-gitlab-ci| |badge-github-ci| |badge-pypi| |badge-zenodo|
|
|
18
|
+
|
|
17
19
|
PyOpenCL lets you access GPUs and other massively parallel compute
|
|
18
20
|
devices from Python. It tries to offer computing goodness in the
|
|
19
21
|
spirit of its sister project `PyCUDA <https://mathema.tician.de/software/pycuda>`__:
|
|
@@ -50,8 +52,7 @@ can be found in the `documentation <https://documen.tician.de/pyopencl/>`__.
|
|
|
50
52
|
What you'll need if you do *not* want to use the convenient instructions above and
|
|
51
53
|
instead build from source:
|
|
52
54
|
|
|
53
|
-
*
|
|
54
|
-
(see their `FAQ <https://pybind11.readthedocs.io/en/stable/faq.html>`__)
|
|
55
|
+
* g++/clang new enough to be compatible with nanobind (specifically, full support of C++17 is needed)
|
|
55
56
|
* `numpy <https://numpy.org>`__, and
|
|
56
57
|
* an OpenCL implementation. (See this `howto <https://wiki.tiker.net/OpenCLHowTo>`__
|
|
57
58
|
for how to get one.)
|
|
@@ -61,11 +62,9 @@ Links
|
|
|
61
62
|
|
|
62
63
|
* `Documentation <https://documen.tician.de/pyopencl>`__
|
|
63
64
|
(read how things work)
|
|
65
|
+
* `Python package index <https://pypi.python.org/pypi/pyopencl>`__
|
|
66
|
+
(download releases, including binary wheels for Linux, macOS, Windows)
|
|
64
67
|
* `Conda Forge <https://anaconda.org/conda-forge/pyopencl>`__
|
|
65
68
|
(download binary packages for Linux, macOS, Windows)
|
|
66
|
-
* `Python package index <https://pypi.python.org/pypi/pyopencl>`__
|
|
67
|
-
(download releases)
|
|
68
|
-
* `C. Gohlke's Windows binaries <https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl>`__
|
|
69
|
-
(download Windows binaries)
|
|
70
69
|
* `Github <https://github.com/inducer/pyopencl>`__
|
|
71
70
|
(get latest source code, file bugs)
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import sys
|
|
3
|
+
|
|
4
|
+
|
|
3
5
|
try:
|
|
4
6
|
from setuptools import Extension
|
|
5
|
-
from setuptools.command.build_ext import
|
|
6
|
-
|
|
7
|
+
from setuptools.command.build_ext import \
|
|
8
|
+
build_ext as BaseBuildExtCommand # noqa: N812
|
|
7
9
|
|
|
8
10
|
except ImportError:
|
|
9
11
|
class Extension:
|
|
@@ -43,14 +45,21 @@ def setup(*args, **kwargs):
|
|
|
43
45
|
|
|
44
46
|
|
|
45
47
|
def get_numpy_incpath():
|
|
46
|
-
from os.path import join, dirname
|
|
47
48
|
from importlib.util import find_spec
|
|
49
|
+
from os.path import dirname, exists, join
|
|
48
50
|
origin = find_spec("numpy").origin
|
|
49
51
|
if origin is None:
|
|
50
52
|
raise RuntimeError("origin of numpy package not found")
|
|
51
53
|
|
|
52
54
|
pathname = dirname(origin)
|
|
53
|
-
|
|
55
|
+
for p in [
|
|
56
|
+
join(pathname, "_core", "include"), # numpy 2 onward
|
|
57
|
+
join(pathname, "core", "include"), # numpy prior to 2
|
|
58
|
+
]:
|
|
59
|
+
if exists(join(p, "numpy", "arrayobject.h")):
|
|
60
|
+
return p
|
|
61
|
+
|
|
62
|
+
raise RuntimeError("no valid path for numpy found")
|
|
54
63
|
|
|
55
64
|
|
|
56
65
|
class NumpyExtension(Extension):
|
|
@@ -762,7 +771,7 @@ def substitute(substitutions, fname):
|
|
|
762
771
|
with open(fname, "w") as outf:
|
|
763
772
|
outf.write("".join(new_lines))
|
|
764
773
|
|
|
765
|
-
from os import
|
|
774
|
+
from os import chmod, stat
|
|
766
775
|
infile_stat_res = stat(fname_in)
|
|
767
776
|
chmod(fname, infile_stat_res.st_mode)
|
|
768
777
|
|
|
@@ -771,7 +780,7 @@ def substitute(substitutions, fname):
|
|
|
771
780
|
|
|
772
781
|
def _run_git_command(cmd):
|
|
773
782
|
git_error = None
|
|
774
|
-
from subprocess import
|
|
783
|
+
from subprocess import PIPE, Popen
|
|
775
784
|
stdout = None
|
|
776
785
|
try:
|
|
777
786
|
popen = Popen(["git"] + cmd, stdout=PIPE)
|
|
@@ -28,12 +28,12 @@ A script to compile and print the native code for a OpenCL kernel.
|
|
|
28
28
|
Usage: python cldis.py prog.cl <ptx/sass/asm> <build options>
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
|
+
import glob
|
|
31
32
|
import os
|
|
32
|
-
import tempfile
|
|
33
|
-
import subprocess
|
|
34
33
|
import re
|
|
34
|
+
import subprocess
|
|
35
35
|
import sys
|
|
36
|
-
import
|
|
36
|
+
import tempfile
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
def main(ctx, tmp_dir, cl_str, output=None, build_options=[]):
|
|
@@ -44,7 +44,7 @@ def main(ctx, tmp_dir, cl_str, output=None, build_options=[]):
|
|
|
44
44
|
elif platform.name == "Portable Computing Language":
|
|
45
45
|
if device.name.startswith("NVIDIA"):
|
|
46
46
|
supported_outputs = ["ptx", "sass"]
|
|
47
|
-
elif device.name.startswith("pthread")
|
|
47
|
+
elif device.name.startswith("pthread") or device.name.startswith("cpu")
|
|
48
48
|
supported_outputs = ["asm"]
|
|
49
49
|
else:
|
|
50
50
|
raise NotImplementedError(f"Unknown pocl device '{device.name}'")
|
|
@@ -20,18 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
20
20
|
THE SOFTWARE.
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
-
import cgen
|
|
24
|
-
import numpy as np
|
|
25
23
|
import re
|
|
26
|
-
from pymbolic.parser import Parser as ExpressionParserBase
|
|
27
|
-
from pymbolic.mapper import CombineMapper
|
|
28
|
-
import pymbolic.primitives as p
|
|
29
|
-
from pymbolic.mapper.c_code import CCodeMapper as CCodeMapperBase
|
|
30
24
|
from sys import intern
|
|
31
|
-
|
|
32
25
|
from warnings import warn
|
|
33
26
|
|
|
27
|
+
import cgen
|
|
28
|
+
import numpy as np
|
|
29
|
+
import pymbolic.primitives as p
|
|
34
30
|
import pytools.lex
|
|
31
|
+
from pymbolic.mapper import CombineMapper
|
|
32
|
+
from pymbolic.mapper.c_code import CCodeMapper as CCodeMapperBase
|
|
33
|
+
from pymbolic.parser import Parser as ExpressionParserBase
|
|
35
34
|
|
|
36
35
|
|
|
37
36
|
class TranslatorWarning(UserWarning):
|
|
@@ -154,8 +153,7 @@ class FortranExpressionParser(ExpressionParserBase):
|
|
|
154
153
|
def parse_terminal(self, pstate):
|
|
155
154
|
scope = self.tree_walker.scope_stack[-1]
|
|
156
155
|
|
|
157
|
-
from pymbolic.parser import
|
|
158
|
-
_identifier, _openpar, _closepar, _float)
|
|
156
|
+
from pymbolic.parser import _closepar, _float, _identifier, _openpar
|
|
159
157
|
|
|
160
158
|
next_tag = pstate.next_tag()
|
|
161
159
|
if next_tag is _float:
|
|
@@ -221,8 +219,8 @@ class FortranExpressionParser(ExpressionParserBase):
|
|
|
221
219
|
}
|
|
222
220
|
|
|
223
221
|
def parse_prefix(self, pstate, min_precedence=0):
|
|
224
|
-
from pymbolic.parser import _PREC_UNARY
|
|
225
222
|
import pymbolic.primitives as primitives
|
|
223
|
+
from pymbolic.parser import _PREC_UNARY
|
|
226
224
|
|
|
227
225
|
pstate.expect_not_end()
|
|
228
226
|
|
|
@@ -235,10 +233,9 @@ class FortranExpressionParser(ExpressionParserBase):
|
|
|
235
233
|
|
|
236
234
|
def parse_postfix(self, pstate, min_precedence, left_exp):
|
|
237
235
|
from pymbolic.parser import (
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
from pymbolic.primitives import
|
|
241
|
-
Comparison, LogicalAnd, LogicalOr)
|
|
236
|
+
_PREC_CALL, _PREC_COMPARISON, _PREC_LOGICAL_AND, _PREC_LOGICAL_OR,
|
|
237
|
+
_openpar)
|
|
238
|
+
from pymbolic.primitives import Comparison, LogicalAnd, LogicalOr
|
|
242
239
|
|
|
243
240
|
next_tag = pstate.next_tag()
|
|
244
241
|
if next_tag is _openpar and _PREC_CALL > min_precedence:
|
|
@@ -351,7 +348,7 @@ class ComplexCCodeMapper(CCodeMapperBase):
|
|
|
351
348
|
complexes = [child for child in expr.children
|
|
352
349
|
if "c" == self.infer_type(child).kind]
|
|
353
350
|
|
|
354
|
-
from pymbolic.mapper.stringifier import
|
|
351
|
+
from pymbolic.mapper.stringifier import PREC_NONE, PREC_SUM
|
|
355
352
|
real_sum = self.join_rec(" + ", reals, PREC_SUM)
|
|
356
353
|
|
|
357
354
|
if len(complexes) == 1:
|
|
@@ -387,7 +384,7 @@ class ComplexCCodeMapper(CCodeMapperBase):
|
|
|
387
384
|
complexes = [child for child in expr.children
|
|
388
385
|
if "c" == self.infer_type(child).kind]
|
|
389
386
|
|
|
390
|
-
from pymbolic.mapper.stringifier import
|
|
387
|
+
from pymbolic.mapper.stringifier import PREC_NONE, PREC_PRODUCT
|
|
391
388
|
real_prd = self.join_rec("*", reals, PREC_PRODUCT)
|
|
392
389
|
|
|
393
390
|
if len(complexes) == 1:
|
|
@@ -489,7 +486,7 @@ class CCodeMapper(ComplexCCodeMapper):
|
|
|
489
486
|
if isinstance(idx, tuple) and len(idx) == 1:
|
|
490
487
|
idx, = idx
|
|
491
488
|
|
|
492
|
-
from pymbolic.mapper.stringifier import
|
|
489
|
+
from pymbolic.mapper.stringifier import PREC_CALL, PREC_NONE
|
|
493
490
|
return self.parenthesize_if_needed(
|
|
494
491
|
self.format("%s[%s%s]",
|
|
495
492
|
self.scope.translate_var_name(expr.aggregate.name),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from urllib.request import urlopen
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
_conf_url = \
|
|
4
5
|
"https://raw.githubusercontent.com/inducer/sphinxconfig/main/sphinxconfig.py"
|
|
5
6
|
with urlopen(_conf_url) as _inf:
|
|
@@ -21,4 +22,5 @@ intersphinx_mapping = {
|
|
|
21
22
|
"python": ("https://docs.python.org/3", None),
|
|
22
23
|
"numpy": ("https://numpy.org/doc/stable/", None),
|
|
23
24
|
"mako": ("https://docs.makotemplates.org/en/latest", None),
|
|
25
|
+
"pytools": ("https://documen.tician.de/pytools", None),
|
|
24
26
|
}
|
|
@@ -22,6 +22,7 @@ THE SOFTWARE.
|
|
|
22
22
|
|
|
23
23
|
import pyopencl as cl
|
|
24
24
|
|
|
25
|
+
|
|
25
26
|
fission = ("cl_ext_device_fission", "2011.1")
|
|
26
27
|
nv_devattr = ("cl_nv_device_attribute_query", "0.92")
|
|
27
28
|
gl_sharing = ("cl_khr_gl_sharing", "0.92")
|
|
@@ -548,6 +549,7 @@ if not cl.have_gl():
|
|
|
548
549
|
|
|
549
550
|
import inspect
|
|
550
551
|
|
|
552
|
+
|
|
551
553
|
CONSTANT_CLASSES = [
|
|
552
554
|
getattr(cl, name) for name in dir(cl)
|
|
553
555
|
if inspect.isclass(getattr(cl, name))
|
|
@@ -104,6 +104,8 @@ Device
|
|
|
104
104
|
|
|
105
105
|
.. versionadded:: 2020.3
|
|
106
106
|
|
|
107
|
+
.. autofunction:: choose_devices
|
|
108
|
+
|
|
107
109
|
Context
|
|
108
110
|
-------
|
|
109
111
|
|
|
@@ -122,9 +124,9 @@ Context
|
|
|
122
124
|
|
|
123
125
|
.. note::
|
|
124
126
|
|
|
125
|
-
Calling the constructor with no arguments will fail for
|
|
126
|
-
CL drivers that support the OpenCL ICD
|
|
127
|
-
just-give-me-a-context-already behavior, we recommend
|
|
127
|
+
Calling the constructor with no arguments will fail for
|
|
128
|
+
CL drivers that support the OpenCL ICD (which applies to most modern systems).
|
|
129
|
+
If you want similar, just-give-me-a-context-already behavior, we recommend
|
|
128
130
|
:func:`create_some_context`. See, e.g. this
|
|
129
131
|
`explanation by AMD
|
|
130
132
|
<https://web.archive.org/web/20101114195033/https://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=71>`__.
|
|
@@ -179,13 +181,4 @@ Context
|
|
|
179
181
|
|
|
180
182
|
|comparable|
|
|
181
183
|
|
|
182
|
-
..
|
|
183
|
-
|
|
184
|
-
Create a :class:`Context` 'somehow'.
|
|
185
|
-
|
|
186
|
-
If multiple choices for platform and/or device exist, *interactive*
|
|
187
|
-
is True, and *sys.stdin.isatty()* is also True,
|
|
188
|
-
then the user is queried about which device should be chosen.
|
|
189
|
-
Otherwise, a device is chosen in an implementation-defined manner.
|
|
190
|
-
|
|
191
|
-
|
|
184
|
+
.. autofunction:: create_some_context
|
|
@@ -15,10 +15,10 @@ Program
|
|
|
15
15
|
constructed with source. (It will depend on the ICD in use how much
|
|
16
16
|
compilation work is saved by this.)
|
|
17
17
|
By setting the environment variable :envvar:`PYOPENCL_NO_CACHE` to any
|
|
18
|
-
|
|
19
|
-
caching is performed. To retain the
|
|
20
|
-
in memory, simply retain the :class:`Program`
|
|
21
|
-
objects.
|
|
18
|
+
string that :func:`pytools.strtobool` evaluates as ``True``, this caching
|
|
19
|
+
is suppressed. No additional in-memory caching is performed. To retain the
|
|
20
|
+
compiled version of a kernel in memory, simply retain the :class:`Program`
|
|
21
|
+
and/or :class:`Kernel` objects.
|
|
22
22
|
|
|
23
23
|
PyOpenCL will also cache "invokers", which are short snippets of Python
|
|
24
24
|
that are generated to accelerate passing arguments to and enqueuing
|
|
@@ -26,6 +26,12 @@ Program
|
|
|
26
26
|
|
|
27
27
|
.. versionadded:: 2013.1
|
|
28
28
|
|
|
29
|
+
.. envvar:: PYOPENCL_COMPILER_OUTPUT
|
|
30
|
+
|
|
31
|
+
When setting the environment variable :envvar:`PYOPENCL_COMPILER_OUTPUT`
|
|
32
|
+
to any string that :func:`pytools.strtobool` evaluates as ``True``,
|
|
33
|
+
PyOpenCL will show compiler messages emitted during program build.
|
|
34
|
+
|
|
29
35
|
.. envvar:: PYOPENCL_BUILD_OPTIONS
|
|
30
36
|
|
|
31
37
|
Any options found in the environment variable
|
|
@@ -101,8 +107,8 @@ Program
|
|
|
101
107
|
Instead, either use the (recommended, stateless) calling interface::
|
|
102
108
|
|
|
103
109
|
sum_knl = prg.sum
|
|
104
|
-
sum_knl(queue, a_np.shape, None, a_g, b_g, res_g)
|
|
105
|
-
|
|
110
|
+
sum_knl(queue, a_np.shape, None, a_g, b_g, res_g)
|
|
111
|
+
|
|
106
112
|
or the long, stateful way around, if you prefer::
|
|
107
113
|
|
|
108
114
|
sum_knl.set_args(a_g, b_g, res_g)
|
|
@@ -32,13 +32,15 @@
|
|
|
32
32
|
# export CL_CONFIG_USE_VECTORIZER=True
|
|
33
33
|
# export CL_CONFIG_CPU_VECTORIZER_MODE=16
|
|
34
34
|
|
|
35
|
-
import pyopencl as cl
|
|
36
|
-
import numpy
|
|
37
|
-
import time
|
|
38
|
-
import sys
|
|
39
35
|
import getopt
|
|
36
|
+
import sys
|
|
37
|
+
import time
|
|
40
38
|
from socket import gethostname
|
|
41
39
|
|
|
40
|
+
import numpy
|
|
41
|
+
|
|
42
|
+
import pyopencl as cl
|
|
43
|
+
|
|
42
44
|
|
|
43
45
|
def DictionariesAPI():
|
|
44
46
|
PhysicsList = {"Einstein": 0, "Newton": 1}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
+
|
|
2
3
|
import pyopencl as cl
|
|
3
4
|
|
|
4
5
|
|
|
@@ -55,10 +56,14 @@ preamble = mmc_c_decl + r"""//CL//
|
|
|
55
56
|
"""
|
|
56
57
|
|
|
57
58
|
from pyopencl.clrandom import rand as clrand
|
|
59
|
+
|
|
60
|
+
|
|
58
61
|
a_gpu = clrand(queue, (20000,), dtype=np.int32, a=0, b=10**6)
|
|
59
62
|
a = a_gpu.get()
|
|
60
63
|
|
|
61
64
|
from pyopencl.reduction import ReductionKernel
|
|
65
|
+
|
|
66
|
+
|
|
62
67
|
red = ReductionKernel(ctx, mmc_dtype,
|
|
63
68
|
neutral="mmc_neutral()",
|
|
64
69
|
reduce_expr="agg_mmc(a, b)", map_expr="mmc_from_scalar(x[i])",
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
|
+
|
|
4
5
|
import pyopencl as cl
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
rng = np.random.default_rng()
|
|
9
|
+
a_np = rng.random(50000, dtype=np.float32)
|
|
10
|
+
b_np = rng.random(50000, dtype=np.float32)
|
|
8
11
|
|
|
9
12
|
ctx = cl.create_some_context()
|
|
10
13
|
queue = cl.CommandQueue(ctx)
|
|
@@ -30,6 +33,7 @@ res_np = np.empty_like(a_np)
|
|
|
30
33
|
cl.enqueue_copy(queue, res_np, res_g)
|
|
31
34
|
|
|
32
35
|
# Check on CPU with Numpy:
|
|
33
|
-
|
|
34
|
-
print(
|
|
36
|
+
error_np = res_np - (a_np + b_np)
|
|
37
|
+
print(f"Error:\n{error_np}")
|
|
38
|
+
print(f"Norm: {np.linalg.norm(error_np):.16e}")
|
|
35
39
|
assert np.allclose(res_np, a_np + b_np)
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import numpy.linalg as la
|
|
3
|
+
|
|
1
4
|
import pyopencl as cl
|
|
2
5
|
import pyopencl.array as cl_array
|
|
3
|
-
import numpy
|
|
4
|
-
import numpy.linalg as la
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
rng = np.random.default_rng()
|
|
9
|
+
a = rng.random(50000, dtype=np.float32)
|
|
10
|
+
b = rng.random(50000, dtype=np.float32)
|
|
8
11
|
|
|
9
12
|
ctx = cl.create_some_context()
|
|
10
13
|
queue = cl.CommandQueue(ctx)
|
|
@@ -26,3 +29,4 @@ knl = prg.sum # Use this Kernel object for repeated calls
|
|
|
26
29
|
knl(queue, a.shape, None, a_dev.data, b_dev.data, dest_dev.data)
|
|
27
30
|
|
|
28
31
|
print(la.norm((dest_dev - (a_dev+b_dev)).get()))
|
|
32
|
+
assert np.allclose(dest_dev.get(), (a_dev + b_dev).get())
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
1
3
|
import pyopencl as cl
|
|
2
4
|
import pyopencl.array as cl_array
|
|
3
5
|
from pyopencl.tools import SVMAllocator, SVMPool
|
|
4
|
-
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
n = 50000
|
|
7
|
-
a = np.random.rand(n).astype(np.float32)
|
|
8
|
-
b = np.random.rand(n).astype(np.float32)
|
|
9
9
|
|
|
10
|
+
rng = np.random.default_rng()
|
|
11
|
+
a = rng.random(n, dtype=np.float32)
|
|
12
|
+
b = rng.random(n, dtype=np.float32)
|
|
10
13
|
|
|
11
14
|
ctx = cl.create_some_context()
|
|
12
15
|
queue = cl.CommandQueue(ctx)
|
|
@@ -30,4 +33,5 @@ prg = cl.Program(ctx, """
|
|
|
30
33
|
knl = prg.sum
|
|
31
34
|
knl(queue, a.shape, None, a_dev.data, b_dev.data, dest_dev.data)
|
|
32
35
|
|
|
33
|
-
np.
|
|
36
|
+
print(np.linalg.norm((dest_dev - (a_dev + b_dev)).get()))
|
|
37
|
+
assert np.allclose(dest_dev.get(), (a_dev + b_dev).get())
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
|
|
3
1
|
import numpy as np
|
|
2
|
+
|
|
4
3
|
import pyopencl as cl
|
|
5
4
|
import pyopencl.array
|
|
6
5
|
from pyopencl.elementwise import ElementwiseKernel
|
|
7
6
|
|
|
7
|
+
|
|
8
8
|
n = 10
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
rng = np.random.default_rng()
|
|
11
|
+
a_np = rng.random(n, dtype=np.float32)
|
|
12
|
+
b_np = rng.random(n, dtype=np.float32)
|
|
11
13
|
|
|
12
14
|
ctx = cl.create_some_context()
|
|
13
15
|
queue = cl.CommandQueue(ctx)
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import numpy.linalg as la
|
|
3
|
+
|
|
1
4
|
import pyopencl as cl
|
|
2
5
|
import pyopencl.array as cl_array
|
|
3
|
-
import
|
|
4
|
-
|
|
6
|
+
from pyopencl.elementwise import ElementwiseKernel
|
|
7
|
+
|
|
5
8
|
|
|
6
9
|
ctx = cl.create_some_context()
|
|
7
10
|
queue = cl.CommandQueue(ctx)
|
|
8
11
|
|
|
9
12
|
n = 10
|
|
13
|
+
|
|
14
|
+
rng = np.random.default_rng()
|
|
10
15
|
a_gpu = cl_array.to_device(queue,
|
|
11
|
-
|
|
16
|
+
rng.standard_normal(n, dtype=np.float32)
|
|
17
|
+
+ 1j*rng.standard_normal(n, dtype=np.float32))
|
|
12
18
|
b_gpu = cl_array.to_device(queue,
|
|
13
|
-
|
|
19
|
+
rng.standard_normal(n, dtype=np.float32)
|
|
20
|
+
+ 1j*rng.standard_normal(n, dtype=np.float32))
|
|
14
21
|
|
|
15
|
-
from pyopencl.elementwise import ElementwiseKernel
|
|
16
22
|
complex_prod = ElementwiseKernel(ctx,
|
|
17
23
|
"float a, "
|
|
18
24
|
"cfloat_t *x, "
|
|
@@ -39,7 +45,7 @@ real_part = ElementwiseKernel(ctx,
|
|
|
39
45
|
c_gpu = cl_array.empty_like(a_gpu)
|
|
40
46
|
complex_prod(5, a_gpu, b_gpu, c_gpu)
|
|
41
47
|
|
|
42
|
-
c_gpu_real = cl_array.empty(queue, len(a_gpu), dtype=
|
|
48
|
+
c_gpu_real = cl_array.empty(queue, len(a_gpu), dtype=np.float32)
|
|
43
49
|
real_part(c_gpu, c_gpu_real)
|
|
44
50
|
print(c_gpu.get().real - c_gpu_real.get())
|
|
45
51
|
|