pyopencl 2024.2.2__cp38-cp38-win_amd64.whl → 2024.2.5__cp38-cp38-win_amd64.whl
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/__init__.py +16 -4
- pyopencl/_cl.cp38-win_amd64.pyd +0 -0
- pyopencl/algorithm.py +3 -1
- pyopencl/bitonic_sort.py +2 -0
- pyopencl/characterize/__init__.py +23 -0
- pyopencl/compyte/.git +1 -0
- pyopencl/compyte/.gitignore +21 -0
- pyopencl/compyte/ndarray/Makefile +31 -0
- pyopencl/compyte/ndarray/gpu_ndarray.h +35 -0
- pyopencl/compyte/ndarray/pygpu_language.h +207 -0
- pyopencl/compyte/ndarray/pygpu_language_cuda.cu +622 -0
- pyopencl/compyte/ndarray/pygpu_language_opencl.cpp +317 -0
- pyopencl/compyte/ndarray/pygpu_ndarray.cpp +1546 -0
- pyopencl/compyte/ndarray/pygpu_ndarray.h +71 -0
- pyopencl/compyte/ndarray/pygpu_ndarray_object.h +232 -0
- pyopencl/tools.py +60 -56
- pyopencl/version.py +9 -3
- {pyopencl-2024.2.2.dist-info → pyopencl-2024.2.5.dist-info}/METADATA +105 -105
- pyopencl-2024.2.5.dist-info/RECORD +56 -0
- {pyopencl-2024.2.2.dist-info → pyopencl-2024.2.5.dist-info}/WHEEL +1 -1
- pyopencl-2024.2.2.data/data/CITATION.cff +0 -74
- pyopencl-2024.2.2.data/data/CMakeLists.txt +0 -83
- pyopencl-2024.2.2.data/data/Makefile.in +0 -21
- pyopencl-2024.2.2.data/data/README.rst +0 -70
- pyopencl-2024.2.2.data/data/README_SETUP.txt +0 -34
- pyopencl-2024.2.2.data/data/aksetup_helper.py +0 -1013
- pyopencl-2024.2.2.data/data/configure.py +0 -6
- pyopencl-2024.2.2.data/data/contrib/cldis.py +0 -91
- pyopencl-2024.2.2.data/data/contrib/fortran-to-opencl/README +0 -29
- pyopencl-2024.2.2.data/data/contrib/fortran-to-opencl/translate.py +0 -1441
- pyopencl-2024.2.2.data/data/contrib/pyopencl.vim +0 -84
- pyopencl-2024.2.2.data/data/doc/Makefile +0 -23
- pyopencl-2024.2.2.data/data/doc/algorithm.rst +0 -214
- pyopencl-2024.2.2.data/data/doc/array.rst +0 -305
- pyopencl-2024.2.2.data/data/doc/conf.py +0 -26
- pyopencl-2024.2.2.data/data/doc/howto.rst +0 -105
- pyopencl-2024.2.2.data/data/doc/index.rst +0 -137
- pyopencl-2024.2.2.data/data/doc/make_constants.py +0 -561
- pyopencl-2024.2.2.data/data/doc/misc.rst +0 -885
- pyopencl-2024.2.2.data/data/doc/runtime.rst +0 -51
- pyopencl-2024.2.2.data/data/doc/runtime_const.rst +0 -30
- pyopencl-2024.2.2.data/data/doc/runtime_gl.rst +0 -78
- pyopencl-2024.2.2.data/data/doc/runtime_memory.rst +0 -527
- pyopencl-2024.2.2.data/data/doc/runtime_platform.rst +0 -184
- pyopencl-2024.2.2.data/data/doc/runtime_program.rst +0 -364
- pyopencl-2024.2.2.data/data/doc/runtime_queue.rst +0 -182
- pyopencl-2024.2.2.data/data/doc/subst.rst +0 -36
- pyopencl-2024.2.2.data/data/doc/tools.rst +0 -4
- pyopencl-2024.2.2.data/data/doc/types.rst +0 -42
- pyopencl-2024.2.2.data/data/examples/black-hole-accretion.py +0 -2227
- pyopencl-2024.2.2.data/data/examples/demo-struct-reduce.py +0 -75
- pyopencl-2024.2.2.data/data/examples/demo.py +0 -39
- pyopencl-2024.2.2.data/data/examples/demo_array.py +0 -32
- pyopencl-2024.2.2.data/data/examples/demo_array_svm.py +0 -37
- pyopencl-2024.2.2.data/data/examples/demo_elementwise.py +0 -34
- pyopencl-2024.2.2.data/data/examples/demo_elementwise_complex.py +0 -53
- pyopencl-2024.2.2.data/data/examples/demo_mandelbrot.py +0 -183
- pyopencl-2024.2.2.data/data/examples/demo_meta_codepy.py +0 -56
- pyopencl-2024.2.2.data/data/examples/demo_meta_template.py +0 -55
- pyopencl-2024.2.2.data/data/examples/dump-performance.py +0 -38
- pyopencl-2024.2.2.data/data/examples/dump-properties.py +0 -86
- pyopencl-2024.2.2.data/data/examples/gl_interop_demo.py +0 -84
- pyopencl-2024.2.2.data/data/examples/gl_particle_animation.py +0 -218
- pyopencl-2024.2.2.data/data/examples/ipython-demo.ipynb +0 -203
- pyopencl-2024.2.2.data/data/examples/median-filter.py +0 -99
- pyopencl-2024.2.2.data/data/examples/n-body.py +0 -1070
- pyopencl-2024.2.2.data/data/examples/narray.py +0 -37
- pyopencl-2024.2.2.data/data/examples/noisyImage.jpg +0 -0
- pyopencl-2024.2.2.data/data/examples/pi-monte-carlo.py +0 -1166
- pyopencl-2024.2.2.data/data/examples/svm.py +0 -82
- pyopencl-2024.2.2.data/data/examples/transpose.py +0 -229
- pyopencl-2024.2.2.data/data/pytest.ini +0 -3
- pyopencl-2024.2.2.data/data/src/bitlog.cpp +0 -51
- pyopencl-2024.2.2.data/data/src/bitlog.hpp +0 -83
- pyopencl-2024.2.2.data/data/src/clinfo_ext.h +0 -134
- pyopencl-2024.2.2.data/data/src/mempool.hpp +0 -444
- pyopencl-2024.2.2.data/data/src/pyopencl_ext.h +0 -77
- pyopencl-2024.2.2.data/data/src/tools.hpp +0 -90
- pyopencl-2024.2.2.data/data/src/wrap_cl.cpp +0 -61
- pyopencl-2024.2.2.data/data/src/wrap_cl.hpp +0 -5853
- pyopencl-2024.2.2.data/data/src/wrap_cl_part_1.cpp +0 -369
- pyopencl-2024.2.2.data/data/src/wrap_cl_part_2.cpp +0 -702
- pyopencl-2024.2.2.data/data/src/wrap_constants.cpp +0 -1274
- pyopencl-2024.2.2.data/data/src/wrap_helpers.hpp +0 -213
- pyopencl-2024.2.2.data/data/src/wrap_mempool.cpp +0 -738
- pyopencl-2024.2.2.data/data/test/add-vectors-32.spv +0 -0
- pyopencl-2024.2.2.data/data/test/add-vectors-64.spv +0 -0
- pyopencl-2024.2.2.data/data/test/empty-header.h +0 -1
- pyopencl-2024.2.2.data/data/test/test_algorithm.py +0 -1180
- pyopencl-2024.2.2.data/data/test/test_array.py +0 -2392
- pyopencl-2024.2.2.data/data/test/test_arrays_in_structs.py +0 -100
- pyopencl-2024.2.2.data/data/test/test_clmath.py +0 -529
- pyopencl-2024.2.2.data/data/test/test_clrandom.py +0 -75
- pyopencl-2024.2.2.data/data/test/test_enqueue_copy.py +0 -271
- pyopencl-2024.2.2.data/data/test/test_wrapper.py +0 -1565
- pyopencl-2024.2.2.dist-info/LICENSE +0 -282
- pyopencl-2024.2.2.dist-info/RECORD +0 -123
- pyopencl-2024.2.2.dist-info/top_level.txt +0 -1
- {pyopencl-2024.2.2.data/data → pyopencl-2024.2.5.dist-info/licenses}/LICENSE +0 -0
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
How-tos
|
|
2
|
-
=======
|
|
3
|
-
|
|
4
|
-
How to use struct types with PyOpenCL
|
|
5
|
-
-------------------------------------
|
|
6
|
-
|
|
7
|
-
We import and initialize PyOpenCL as usual:
|
|
8
|
-
|
|
9
|
-
.. doctest::
|
|
10
|
-
:options: +ELLIPSIS
|
|
11
|
-
|
|
12
|
-
>>> import numpy as np
|
|
13
|
-
>>> import pyopencl as cl
|
|
14
|
-
>>> import pyopencl.tools
|
|
15
|
-
>>> import pyopencl.array
|
|
16
|
-
|
|
17
|
-
>>> ctx = cl.create_some_context(interactive=False)
|
|
18
|
-
>>> queue = cl.CommandQueue(ctx)
|
|
19
|
-
|
|
20
|
-
Then, suppose we would like to declare a struct consisting of an integer and a
|
|
21
|
-
floating point number. We first create a :class:`numpy.dtype` along these
|
|
22
|
-
lines:
|
|
23
|
-
|
|
24
|
-
.. doctest::
|
|
25
|
-
|
|
26
|
-
>>> my_struct = np.dtype([("field1", np.int32), ("field2", np.float32)])
|
|
27
|
-
>>> print(my_struct)
|
|
28
|
-
[('field1', '<i4'), ('field2', '<f4')]
|
|
29
|
-
|
|
30
|
-
.. note::
|
|
31
|
-
|
|
32
|
-
Not all :mod:`numpy` dtypes are supported yet. For example strings (and
|
|
33
|
-
generally things that have a shape of their own) are not supported.
|
|
34
|
-
|
|
35
|
-
Since OpenCL C may have a different opinion for :mod:`numpy` on how the struct
|
|
36
|
-
should be laid out, for example because of `alignment
|
|
37
|
-
<https://en.wikipedia.org/wiki/Data_structure_alignment>`__. So as a first step, we
|
|
38
|
-
match our dtype against CL's version:
|
|
39
|
-
|
|
40
|
-
.. doctest::
|
|
41
|
-
|
|
42
|
-
>>> my_struct, my_struct_c_decl = cl.tools.match_dtype_to_c_struct(
|
|
43
|
-
... ctx.devices[0], "my_struct", my_struct)
|
|
44
|
-
>>> print(my_struct_c_decl)
|
|
45
|
-
typedef struct {
|
|
46
|
-
int field1;
|
|
47
|
-
float field2;
|
|
48
|
-
} my_struct;
|
|
49
|
-
<BLANKLINE>
|
|
50
|
-
<BLANKLINE>
|
|
51
|
-
|
|
52
|
-
We then tell PyOpenCL about our new type.
|
|
53
|
-
|
|
54
|
-
.. doctest::
|
|
55
|
-
|
|
56
|
-
>>> my_struct = cl.tools.get_or_register_dtype("my_struct", my_struct)
|
|
57
|
-
|
|
58
|
-
Next, we can create some data of that type on the host and transfer it to
|
|
59
|
-
the device:
|
|
60
|
-
|
|
61
|
-
.. doctest::
|
|
62
|
-
|
|
63
|
-
>>> ary_host = np.empty(20, my_struct)
|
|
64
|
-
>>> ary_host["field1"].fill(217)
|
|
65
|
-
>>> ary_host["field2"].fill(1000)
|
|
66
|
-
>>> ary_host[13]["field2"] = 12
|
|
67
|
-
>>> print(ary_host) #doctest: +NORMALIZE_WHITESPACE
|
|
68
|
-
[(217, 1000.) (217, 1000.) (217, 1000.) (217, 1000.) (217, 1000.)
|
|
69
|
-
(217, 1000.) (217, 1000.) (217, 1000.) (217, 1000.) (217, 1000.)
|
|
70
|
-
(217, 1000.) (217, 1000.) (217, 1000.) (217, 12.) (217, 1000.)
|
|
71
|
-
(217, 1000.) (217, 1000.) (217, 1000.) (217, 1000.) (217, 1000.)]
|
|
72
|
-
|
|
73
|
-
>>> ary = cl.array.to_device(queue, ary_host)
|
|
74
|
-
|
|
75
|
-
We can then operate on the array with our own kernels:
|
|
76
|
-
|
|
77
|
-
.. doctest::
|
|
78
|
-
|
|
79
|
-
>>> prg = cl.Program(ctx, my_struct_c_decl + """
|
|
80
|
-
... __kernel void set_to_1(__global my_struct *a)
|
|
81
|
-
... {
|
|
82
|
-
... a[get_global_id(0)].field1 = 1;
|
|
83
|
-
... }
|
|
84
|
-
... """).build()
|
|
85
|
-
|
|
86
|
-
>>> evt = prg.set_to_1(queue, ary.shape, None, ary.data)
|
|
87
|
-
>>> print(ary) #doctest: +NORMALIZE_WHITESPACE
|
|
88
|
-
[(1, 1000.) (1, 1000.) (1, 1000.) (1, 1000.) (1, 1000.) (1, 1000.)
|
|
89
|
-
(1, 1000.) (1, 1000.) (1, 1000.) (1, 1000.) (1, 1000.) (1, 1000.)
|
|
90
|
-
(1, 1000.) (1, 12.) (1, 1000.) (1, 1000.) (1, 1000.) (1, 1000.)
|
|
91
|
-
(1, 1000.) (1, 1000.)]
|
|
92
|
-
|
|
93
|
-
as well as with PyOpenCL's built-in operations:
|
|
94
|
-
|
|
95
|
-
.. doctest::
|
|
96
|
-
|
|
97
|
-
>>> from pyopencl.elementwise import ElementwiseKernel
|
|
98
|
-
>>> elwise = ElementwiseKernel(ctx, "my_struct *a", "a[i].field1 = 2;",
|
|
99
|
-
... preamble=my_struct_c_decl)
|
|
100
|
-
>>> evt = elwise(ary)
|
|
101
|
-
>>> print(ary) #doctest: +NORMALIZE_WHITESPACE
|
|
102
|
-
[(2, 1000.) (2, 1000.) (2, 1000.) (2, 1000.) (2, 1000.) (2, 1000.)
|
|
103
|
-
(2, 1000.) (2, 1000.) (2, 1000.) (2, 1000.) (2, 1000.) (2, 1000.)
|
|
104
|
-
(2, 1000.) (2, 12.) (2, 1000.) (2, 1000.) (2, 1000.) (2, 1000.)
|
|
105
|
-
(2, 1000.) (2, 1000.)]
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
Welcome to PyOpenCL's documentation!
|
|
2
|
-
====================================
|
|
3
|
-
|
|
4
|
-
PyOpenCL gives you easy, Pythonic access to the `OpenCL
|
|
5
|
-
<https://www.khronos.org/opencl/>`__ parallel computation API.
|
|
6
|
-
What makes PyOpenCL special?
|
|
7
|
-
|
|
8
|
-
* Object cleanup tied to lifetime of objects. This idiom,
|
|
9
|
-
often called
|
|
10
|
-
`RAII <https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization>`__
|
|
11
|
-
in C++, makes it much easier to write correct, leak- and
|
|
12
|
-
crash-free code.
|
|
13
|
-
|
|
14
|
-
* Completeness. PyOpenCL puts the full power of OpenCL's API at your
|
|
15
|
-
disposal, if you wish. Every obscure ``get_info()`` query and
|
|
16
|
-
all CL calls are accessible.
|
|
17
|
-
|
|
18
|
-
* Automatic Error Checking. All errors are automatically translated
|
|
19
|
-
into Python exceptions.
|
|
20
|
-
|
|
21
|
-
* Speed. PyOpenCL's base layer is written in C++, so all the niceties above
|
|
22
|
-
are virtually free.
|
|
23
|
-
|
|
24
|
-
* Helpful Documentation. You're looking at it. ;)
|
|
25
|
-
|
|
26
|
-
* Liberal license. PyOpenCL is open-source under the
|
|
27
|
-
:ref:`MIT license <license>`
|
|
28
|
-
and free for commercial, academic, and private use.
|
|
29
|
-
|
|
30
|
-
Here's an example, to give you an impression:
|
|
31
|
-
|
|
32
|
-
.. literalinclude:: ../examples/demo.py
|
|
33
|
-
|
|
34
|
-
(You can find this example as
|
|
35
|
-
:download:`examples/demo.py <../examples/demo.py>` in the PyOpenCL
|
|
36
|
-
source distribution.)
|
|
37
|
-
|
|
38
|
-
Tutorials
|
|
39
|
-
=========
|
|
40
|
-
|
|
41
|
-
* Gaston Hillar's `two-part article series
|
|
42
|
-
<https://web.archive.org/web/20190707171427/www.drdobbs.com/open-source/easy-opencl-with-python/240162614>`__
|
|
43
|
-
in Dr. Dobb's Journal provides a friendly introduction to PyOpenCL.
|
|
44
|
-
* `Simon McIntosh-Smith <http://people.cs.bris.ac.uk/~simonm/>`__
|
|
45
|
-
and `Tom Deakin <https://www.tomdeakin.com/>`__'s course
|
|
46
|
-
`Hands-on OpenCL <https://handsonopencl.github.io/>`__ contains
|
|
47
|
-
both `lecture slides <https://github.com/HandsOnOpenCL/Lecture-Slides/releases>`__
|
|
48
|
-
and `exercises (with solutions) <https://github.com/HandsOnOpenCL/Exercises-Solutions>`__
|
|
49
|
-
(The course covers PyOpenCL as well as OpenCL's C and C++ APIs.)
|
|
50
|
-
* PyOpenCL course at `PASI <https://www.bu.edu/pasi>`__: Parts
|
|
51
|
-
`1 <https://www.youtube.com/watch?v=X9mflbX1NL8>`__
|
|
52
|
-
`2 <https://www.youtube.com/watch?v=MqvfCE_bKOg>`__
|
|
53
|
-
`3 <https://www.youtube.com/watch?v=TAvKmV7CuUw>`__
|
|
54
|
-
`4 <https://www.youtube.com/watch?v=SsuJ0LvZW1Q>`__
|
|
55
|
-
(YouTube, 2011)
|
|
56
|
-
* PyOpenCL course at `DTU GPULab <http://gpulab.compute.dtu.dk/>`__ and
|
|
57
|
-
`Simula <https://www.simula.no/>`__ (2011):
|
|
58
|
-
`Lecture 1 <https://tiker.net/pub/simula-pyopencl-lec1.pdf>`__
|
|
59
|
-
`Lecture 2 <https://tiker.net/pub/simula-pyopencl-lec2.pdf>`__
|
|
60
|
-
`Problem set 1 <https://tiker.net/pub/simula-pyopencl-probset1.pdf>`__
|
|
61
|
-
`Problem set 2 <https://tiker.net/pub/simula-pyopencl-probset2.pdf>`__
|
|
62
|
-
* Ian Johnson's `PyOpenCL tutorial <https://web.archive.org/web/20170907175053/http://enja.org:80/2011/02/22/adventures-in-pyopencl-part-1-getting-started-with-python>`__.
|
|
63
|
-
|
|
64
|
-
Software that works with or enhances PyOpenCL
|
|
65
|
-
=============================================
|
|
66
|
-
|
|
67
|
-
* Jon Roose's `pyclblas <https://pyclblas.readthedocs.io/en/latest/index.html>`__
|
|
68
|
-
(`code <https://github.com/jroose/pyclblas>`__)
|
|
69
|
-
makes BLAS in the form of `clBLAS <https://github.com/clMathLibraries/clBLAS>`__
|
|
70
|
-
available from within :mod:`pyopencl` code.
|
|
71
|
-
|
|
72
|
-
Two earlier wrappers continue to be available:
|
|
73
|
-
one by `Eric Hunsberger <https://github.com/hunse/pyopencl_blas>`__ and one
|
|
74
|
-
by `Lars Ericson <https://lists.tiker.net/pipermail/pyopencl/2015-June/001890.html>`__.
|
|
75
|
-
|
|
76
|
-
* Cedric Nugteren provides a wrapper for the
|
|
77
|
-
`CLBlast <https://github.com/CNugteren/CLBlast>`__
|
|
78
|
-
OpenCL BLAS library:
|
|
79
|
-
`PyCLBlast <https://github.com/CNugteren/CLBlast/tree/master/src/pyclblast>`__.
|
|
80
|
-
|
|
81
|
-
* Gregor Thalhammer's `gpyfft <https://github.com/geggo/gpyfft>`__ provides a
|
|
82
|
-
Python wrapper for the OpenCL FFT library clFFT from AMD.
|
|
83
|
-
|
|
84
|
-
* Bogdan Opanchuk's `reikna <https://pypi.org/project/reikna/>`__ offers a
|
|
85
|
-
variety of GPU-based algorithms (FFT, random number generation, matrix
|
|
86
|
-
multiplication) designed to work with :class:`pyopencl.array.Array` objects.
|
|
87
|
-
|
|
88
|
-
* Troels Henriksen, Ken Friis Larsen, and Cosmin Oancea's `Futhark
|
|
89
|
-
<https://futhark-lang.org/>`__ programming language offers a nice way to code
|
|
90
|
-
nested-parallel programs with reductions and scans on data in
|
|
91
|
-
:class:`pyopencl.array.Array` instances.
|
|
92
|
-
|
|
93
|
-
* Robbert Harms and Alard Roebroeck's `MOT <https://github.com/robbert-harms/MOT>`__
|
|
94
|
-
offers a variety of GPU-enabled non-linear optimization algorithms and MCMC
|
|
95
|
-
sampling routines for parallel optimization and sampling of multiple problems.
|
|
96
|
-
|
|
97
|
-
* Vincent Favre-Nicolin's `pyvkfft <https://github.com/vincefn/pyvkfft/>`__
|
|
98
|
-
makes `vkfft <https://github.com/DTolm/VkFFT>`__ accessible from PyOpenCL.
|
|
99
|
-
|
|
100
|
-
If you know of a piece of software you feel that should be on this list, please
|
|
101
|
-
let me know, or, even better, send a patch!
|
|
102
|
-
|
|
103
|
-
Contents
|
|
104
|
-
========
|
|
105
|
-
|
|
106
|
-
.. toctree::
|
|
107
|
-
:maxdepth: 2
|
|
108
|
-
|
|
109
|
-
runtime
|
|
110
|
-
runtime_const
|
|
111
|
-
runtime_platform
|
|
112
|
-
runtime_queue
|
|
113
|
-
runtime_memory
|
|
114
|
-
runtime_program
|
|
115
|
-
runtime_gl
|
|
116
|
-
tools
|
|
117
|
-
array
|
|
118
|
-
types
|
|
119
|
-
algorithm
|
|
120
|
-
howto
|
|
121
|
-
misc
|
|
122
|
-
🚀 Github <https://github.com/inducer/pyopencl>
|
|
123
|
-
💾 Download Releases <https://pypi.org/project/pyopencl>
|
|
124
|
-
|
|
125
|
-
Note that this guide does not explain OpenCL programming and technology. Please
|
|
126
|
-
refer to the official `Khronos OpenCL documentation <https://www.khronos.org/opencl/>`__
|
|
127
|
-
for that.
|
|
128
|
-
|
|
129
|
-
PyOpenCL also has its own `web site <https://mathema.tician.de/software/pyopencl>`__,
|
|
130
|
-
where you can find updates, new versions, documentation, and support.
|
|
131
|
-
|
|
132
|
-
Indices and tables
|
|
133
|
-
==================
|
|
134
|
-
|
|
135
|
-
* :ref:`genindex`
|
|
136
|
-
* :ref:`modindex`
|
|
137
|
-
* :ref:`search`
|