pyopencl 2024.2.2__cp310-cp310-win_amd64.whl → 2024.2.5__cp310-cp310-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.cp310-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,51 +0,0 @@
|
|
|
1
|
-
.. _reference-doc:
|
|
2
|
-
|
|
3
|
-
.. include:: subst.rst
|
|
4
|
-
|
|
5
|
-
OpenCL Runtime: Basics
|
|
6
|
-
======================
|
|
7
|
-
|
|
8
|
-
Version Queries
|
|
9
|
-
---------------
|
|
10
|
-
|
|
11
|
-
.. module:: pyopencl
|
|
12
|
-
.. moduleauthor:: Andreas Kloeckner <inform@tiker.net>
|
|
13
|
-
|
|
14
|
-
.. data:: VERSION
|
|
15
|
-
|
|
16
|
-
Gives the numeric version of PyOpenCL as a variable-length tuple
|
|
17
|
-
of integers. Enables easy version checks such as
|
|
18
|
-
``VERSION >= (0, 93)``.
|
|
19
|
-
|
|
20
|
-
.. data:: VERSION_STATUS
|
|
21
|
-
|
|
22
|
-
A text string such as ``"rc4"`` or ``"beta"`` qualifying the status
|
|
23
|
-
of the release.
|
|
24
|
-
|
|
25
|
-
.. data:: VERSION_TEXT
|
|
26
|
-
|
|
27
|
-
The full release name (such as ``"0.93rc4"``) in string form.
|
|
28
|
-
|
|
29
|
-
.. function:: get_cl_header_version()
|
|
30
|
-
|
|
31
|
-
Return a variable-length tuple of integers representing the
|
|
32
|
-
version of the OpenCL header against which PyOpenCL was
|
|
33
|
-
compiled.
|
|
34
|
-
|
|
35
|
-
.. versionadded:: 0.92
|
|
36
|
-
|
|
37
|
-
.. _errors:
|
|
38
|
-
|
|
39
|
-
Error Reporting
|
|
40
|
-
---------------
|
|
41
|
-
|
|
42
|
-
.. class:: Error
|
|
43
|
-
|
|
44
|
-
Base class for all PyOpenCL exceptions.
|
|
45
|
-
|
|
46
|
-
.. class:: MemoryError
|
|
47
|
-
|
|
48
|
-
.. class:: LogicError
|
|
49
|
-
|
|
50
|
-
.. class:: RuntimeError
|
|
51
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
OpenCL Runtime: Constants
|
|
2
|
-
=========================
|
|
3
|
-
|
|
4
|
-
.. currentmodule:: pyopencl
|
|
5
|
-
|
|
6
|
-
.. include:: constants.inc
|
|
7
|
-
|
|
8
|
-
.. class:: NameVersion
|
|
9
|
-
|
|
10
|
-
Describes the version of a specific feature.
|
|
11
|
-
|
|
12
|
-
.. note::
|
|
13
|
-
|
|
14
|
-
Only available with OpenCL 3.0 or newer.
|
|
15
|
-
|
|
16
|
-
.. versionadded:: 2020.3
|
|
17
|
-
|
|
18
|
-
.. method:: __init__(version, name)
|
|
19
|
-
.. attribute:: version
|
|
20
|
-
.. attribute:: name
|
|
21
|
-
|
|
22
|
-
.. class:: DeviceTopologyAmd
|
|
23
|
-
|
|
24
|
-
.. method:: __init__(bus, device, function)
|
|
25
|
-
.. attribute:: type
|
|
26
|
-
.. attribute:: bus
|
|
27
|
-
.. attribute:: device
|
|
28
|
-
.. attribute:: function
|
|
29
|
-
|
|
30
|
-
.. vim: shiftwidth=4
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
.. include:: subst.rst
|
|
2
|
-
|
|
3
|
-
.. _gl-interop:
|
|
4
|
-
|
|
5
|
-
OpenCL Runtime: OpenGL Interoperability
|
|
6
|
-
=======================================
|
|
7
|
-
|
|
8
|
-
.. currentmodule:: pyopencl
|
|
9
|
-
|
|
10
|
-
Functionality in this section is only available when PyOpenCL is compiled
|
|
11
|
-
with GL support. See :func:`have_gl`.
|
|
12
|
-
|
|
13
|
-
.. versionadded:: 0.91
|
|
14
|
-
|
|
15
|
-
.. function:: have_gl()
|
|
16
|
-
|
|
17
|
-
Return *True* if PyOpenCL was compiled with OpenGL interoperability,
|
|
18
|
-
otherwise *False*.
|
|
19
|
-
|
|
20
|
-
.. function:: get_gl_sharing_context_properties()
|
|
21
|
-
|
|
22
|
-
Return a :class:`list` of :class:`context_properties` that will
|
|
23
|
-
allow a newly created context to share the currently active GL
|
|
24
|
-
context.
|
|
25
|
-
|
|
26
|
-
.. function:: get_apple_cgl_share_group()
|
|
27
|
-
|
|
28
|
-
Get share group handle for current CGL context.
|
|
29
|
-
|
|
30
|
-
Apple OS X only.
|
|
31
|
-
|
|
32
|
-
.. versionadded:: 2011.1
|
|
33
|
-
|
|
34
|
-
.. class:: GLBuffer(context, flags, bufobj)
|
|
35
|
-
|
|
36
|
-
:class:`GLBuffer` inherits from :class:`MemoryObject`.
|
|
37
|
-
|
|
38
|
-
.. attribute:: gl_object
|
|
39
|
-
|
|
40
|
-
.. class:: GLRenderBuffer(context, flags, bufobj)
|
|
41
|
-
|
|
42
|
-
:class:`GLRenderBuffer` inherits from :class:`MemoryObject`.
|
|
43
|
-
|
|
44
|
-
.. attribute:: gl_object
|
|
45
|
-
|
|
46
|
-
.. class:: GLTexture(context, flags, texture_target, miplevel, texture, dims)
|
|
47
|
-
|
|
48
|
-
:class:`GLTexture` inherits from :class:`Image`. Only available in OpenCL 1.2
|
|
49
|
-
and newer.
|
|
50
|
-
|
|
51
|
-
.. attribute:: gl_object
|
|
52
|
-
|
|
53
|
-
.. method:: get_gl_texture_info(param)
|
|
54
|
-
|
|
55
|
-
See ``gl_texture_info`` for values of *param*. Only available when
|
|
56
|
-
PyOpenCL is compiled with GL support. See :func:`have_gl`.
|
|
57
|
-
|
|
58
|
-
.. function:: enqueue_acquire_gl_objects(queue, mem_objects, wait_for=None)
|
|
59
|
-
|
|
60
|
-
*mem_objects* is a list of :class:`MemoryObject` instances.
|
|
61
|
-
|std-enqueue-blurb|
|
|
62
|
-
|
|
63
|
-
.. function:: enqueue_release_gl_objects(queue, mem_objects, wait_for=None)
|
|
64
|
-
|
|
65
|
-
*mem_objects* is a list of :class:`MemoryObject` instances. |std-enqueue-blurb|
|
|
66
|
-
|
|
67
|
-
.. function:: get_gl_context_info_khr(properties, param_name, platform=None)
|
|
68
|
-
|
|
69
|
-
Get information on which CL device corresponds to a given
|
|
70
|
-
GL/EGL/WGL/CGL device.
|
|
71
|
-
|
|
72
|
-
See the :class:`Context` constructor for the meaning of
|
|
73
|
-
*properties* and :class:`gl_context_info` for *param_name*.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.. versionchanged:: 2011.2
|
|
77
|
-
Accepts the *platform* argument. Using *platform* equal to None is
|
|
78
|
-
deprecated as of PyOpenCL 2011.2.
|
|
@@ -1,527 +0,0 @@
|
|
|
1
|
-
.. include:: subst.rst
|
|
2
|
-
|
|
3
|
-
OpenCL Runtime: Memory
|
|
4
|
-
======================
|
|
5
|
-
|
|
6
|
-
.. currentmodule:: pyopencl
|
|
7
|
-
|
|
8
|
-
.. class:: MemoryObject
|
|
9
|
-
|
|
10
|
-
.. attribute:: info
|
|
11
|
-
|
|
12
|
-
Lower case versions of the :class:`mem_info` constants
|
|
13
|
-
may be used as attributes on instances of this class
|
|
14
|
-
to directly query info attributes.
|
|
15
|
-
|
|
16
|
-
.. attribute:: hostbuf
|
|
17
|
-
|
|
18
|
-
.. method:: get_info(param)
|
|
19
|
-
|
|
20
|
-
See :class:`mem_info` for values of *param*.
|
|
21
|
-
|
|
22
|
-
.. method:: release()
|
|
23
|
-
|
|
24
|
-
.. method:: get_host_array(shape, dtype, order="C")
|
|
25
|
-
|
|
26
|
-
Return the memory object's associated host memory
|
|
27
|
-
area as a :class:`numpy.ndarray` of the given *shape*,
|
|
28
|
-
*dtype* and *order*.
|
|
29
|
-
|
|
30
|
-
.. automethod:: from_int_ptr
|
|
31
|
-
.. autoattribute:: int_ptr
|
|
32
|
-
|
|
33
|
-
|comparable|
|
|
34
|
-
|
|
35
|
-
Memory Migration
|
|
36
|
-
----------------
|
|
37
|
-
|
|
38
|
-
.. function:: enqueue_migrate_mem_objects(queue, mem_objects, flags=0, wait_for=None)
|
|
39
|
-
|
|
40
|
-
:param flags: from :class:`mem_migration_flags`
|
|
41
|
-
|
|
42
|
-
.. versionadded:: 2011.2
|
|
43
|
-
|
|
44
|
-
Only available with CL 1.2.
|
|
45
|
-
|
|
46
|
-
Buffer
|
|
47
|
-
------
|
|
48
|
-
|
|
49
|
-
.. class:: Buffer(context, flags, size=0, hostbuf=None)
|
|
50
|
-
|
|
51
|
-
Create a :class:`Buffer`.
|
|
52
|
-
See :class:`mem_flags` for values of *flags*.
|
|
53
|
-
If *hostbuf* is specified, *size* defaults to the size of
|
|
54
|
-
the specified buffer if it is passed as zero.
|
|
55
|
-
|
|
56
|
-
:class:`Buffer` inherits from :class:`MemoryObject`.
|
|
57
|
-
|
|
58
|
-
.. note::
|
|
59
|
-
|
|
60
|
-
Python also defines a type of `buffer object
|
|
61
|
-
<https://docs.python.org/3/c-api/buffer.html>`__,
|
|
62
|
-
and PyOpenCL interacts with those, too, as the host-side
|
|
63
|
-
target of :func:`enqueue_copy`. Make sure to always be
|
|
64
|
-
clear on whether a :class:`Buffer` or a Python buffer
|
|
65
|
-
object is needed.
|
|
66
|
-
|
|
67
|
-
Note that actual memory allocation in OpenCL may be deferred.
|
|
68
|
-
Buffers are attached to a :class:`Context` and are only
|
|
69
|
-
moved to a device once the buffer is used on that device.
|
|
70
|
-
That is also the point when out-of-memory errors will occur.
|
|
71
|
-
If you'd like to be sure that there's enough memory for
|
|
72
|
-
your allocation, either use :func:`enqueue_migrate_mem_objects`
|
|
73
|
-
(if available) or simply perform a small transfer to the
|
|
74
|
-
buffer. See also :class:`pyopencl.tools.ImmediateAllocator`.
|
|
75
|
-
|
|
76
|
-
.. method:: get_sub_region(origin, size, flags=0)
|
|
77
|
-
|
|
78
|
-
Only available in OpenCL 1.1 and newer.
|
|
79
|
-
|
|
80
|
-
.. method:: __getitem__(slc)
|
|
81
|
-
|
|
82
|
-
*slc* is a :class:`slice` object indicating from which byte index range
|
|
83
|
-
a sub-buffer is to be created. The *flags* argument of
|
|
84
|
-
:meth:`get_sub_region` is set to the same flags with which *self* was
|
|
85
|
-
created.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
.. function:: enqueue_fill_buffer(queue, mem, pattern, offset, size, wait_for=None)
|
|
89
|
-
|
|
90
|
-
:arg mem: the on device :class:`Buffer`
|
|
91
|
-
:arg pattern: a buffer object (likely a :class:`numpy.ndarray`, eg.
|
|
92
|
-
``np.uint32(0)``). The memory associated with *pattern* can be reused or
|
|
93
|
-
freed once the function completes.
|
|
94
|
-
:arg size: The size in bytes of the region to be filled. Must be a multiple of the
|
|
95
|
-
size of the pattern.
|
|
96
|
-
:arg offset: The location in bytes of the region being filled in *mem*.
|
|
97
|
-
Must be a multiple of the size of the pattern.
|
|
98
|
-
|
|
99
|
-
Fills a buffer with the provided pattern
|
|
100
|
-
|
|
101
|
-
|std-enqueue-blurb|
|
|
102
|
-
|
|
103
|
-
Only available with CL 1.2.
|
|
104
|
-
|
|
105
|
-
.. versionadded:: 2011.2
|
|
106
|
-
|
|
107
|
-
.. _svm:
|
|
108
|
-
|
|
109
|
-
Shared Virtual Memory (SVM)
|
|
110
|
-
---------------------------
|
|
111
|
-
|
|
112
|
-
Shared virtual memory allows the host and the compute device to share
|
|
113
|
-
address space, so that pointers on the host and on the device may have
|
|
114
|
-
the same meaning. In addition, it allows the same memory to be accessed
|
|
115
|
-
by both the host and the device. *Coarse-grain* SVM requires that
|
|
116
|
-
buffers be mapped before being accessed on the host, *fine-grain* SVM
|
|
117
|
-
does away with that requirement.
|
|
118
|
-
|
|
119
|
-
.. warning::
|
|
120
|
-
|
|
121
|
-
Compared to :class:`Buffer`\ s, SVM brings with it a new concern: the
|
|
122
|
-
synchronization of memory deallocation. Unlike other objects in OpenCL,
|
|
123
|
-
SVM is represented by a plain (C-language) pointer and thus has no ability for
|
|
124
|
-
reference counting.
|
|
125
|
-
|
|
126
|
-
As a result, it is perfectly legal to allocate a :class:`Buffer`, enqueue an
|
|
127
|
-
operation on it, and release the buffer, without worrying about whether the
|
|
128
|
-
operation has completed. The OpenCL implementation will keep the buffer alive
|
|
129
|
-
until the operation has completed. This is *not* the case with SVM: Unless
|
|
130
|
-
otherwise specified, memory deallocation is performed immediately when
|
|
131
|
-
requested, and so SVM will be deallocated whenever the Python
|
|
132
|
-
garbage collector sees fit, even if the operation has not completed,
|
|
133
|
-
immediately leading to undefined behavior (i.e., typically, memory corruption and,
|
|
134
|
-
before too long, a crash).
|
|
135
|
-
|
|
136
|
-
Version 2022.2 of PyOpenCL offers substantially improved tools
|
|
137
|
-
for dealing with this. In particular, all means for allocating SVM
|
|
138
|
-
allow specifying a :class:`CommandQueue`, so that deallocation
|
|
139
|
-
is enqueued and performed after previously-enqueued operations
|
|
140
|
-
have completed.
|
|
141
|
-
|
|
142
|
-
SVM requires OpenCL 2.0.
|
|
143
|
-
|
|
144
|
-
.. _opaque-svm:
|
|
145
|
-
|
|
146
|
-
Opaque and "Wrapped-:mod:`numpy`" Styles of Referencing SVM
|
|
147
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
148
|
-
|
|
149
|
-
When trying to pass SVM pointers to functionality in :mod:`pyopencl`,
|
|
150
|
-
two styles are supported:
|
|
151
|
-
|
|
152
|
-
- First, the opaque style. This style most closely resembles
|
|
153
|
-
:class:`Buffer`-based allocation available in OpenCL 1.x.
|
|
154
|
-
SVM pointers are held in opaque "handle" objects such as :class:`SVMAllocation`.
|
|
155
|
-
|
|
156
|
-
- Second, the wrapped-:mod:`numpy` style. In this case, a :class:`numpy.ndarray`
|
|
157
|
-
(or another object implementing the :c:func:`Python buffer protocol
|
|
158
|
-
<PyObject_GetBuffer>`) serves as the reference to an area of SVM.
|
|
159
|
-
This style permits using memory areas with :mod:`pyopencl`'s SVM
|
|
160
|
-
interfaces even if they were allocated outside of :mod:`pyopencl`.
|
|
161
|
-
|
|
162
|
-
Since passing a :class:`numpy.ndarray` (or another type of object obeying the
|
|
163
|
-
buffer interface) already has existing semantics in most settings in
|
|
164
|
-
:mod:`pyopencl` (such as when passing arguments to a kernel or calling
|
|
165
|
-
:func:`enqueue_copy`), there exists a wrapper object, :class:`SVM`, that may
|
|
166
|
-
be "wrapped around" these objects to mark them as SVM.
|
|
167
|
-
|
|
168
|
-
The commonality between the two styles is that both ultimately implement
|
|
169
|
-
the :class:`SVMPointer` interface, which :mod:`pyopencl` uses to obtain
|
|
170
|
-
the actual SVM pointer.
|
|
171
|
-
|
|
172
|
-
Note that it is easily possible to obtain a :class:`numpy.ndarray` view of SVM
|
|
173
|
-
areas held in the opaque style, see :attr:`SVMPointer.buf`, permitting
|
|
174
|
-
transitions from opaque to wrapped-:mod:`numpy` style. The opposite transition
|
|
175
|
-
(from wrapped-:mod:`numpy` to opaque) is not necessarily straightforward,
|
|
176
|
-
as it would require "fishing" the opaque SVM handle out of a chain of
|
|
177
|
-
:attr:`numpy.ndarray.base` attributes (or similar, depending on
|
|
178
|
-
the actual object serving as the main SVM reference).
|
|
179
|
-
|
|
180
|
-
See :ref:`numpy-svm-helpers` for helper functions that ease setting up the
|
|
181
|
-
wrapped-:mod:`numpy` structure.
|
|
182
|
-
|
|
183
|
-
Wrapped-:mod:`numpy` SVM tends to be a good fit for fine-grain SVM because of
|
|
184
|
-
the ease of direct host-side access, but the creation of the nested structure
|
|
185
|
-
that makes this possible is associated with a certain amount of cost.
|
|
186
|
-
|
|
187
|
-
By comparison, opaque SVM access tends to be a good fit for coarse-grain
|
|
188
|
-
SVM, because direct host access is not possible without mapping the array
|
|
189
|
-
anyway, and it has lower setup cost. It is of course entirely possible to use
|
|
190
|
-
opaque SVM access with fine-grain SVM.
|
|
191
|
-
|
|
192
|
-
.. versionchanged:: 2022.2
|
|
193
|
-
|
|
194
|
-
This version adds the opaque style of SVM access.
|
|
195
|
-
|
|
196
|
-
Using SVM with Arrays
|
|
197
|
-
^^^^^^^^^^^^^^^^^^^^^
|
|
198
|
-
|
|
199
|
-
While all types of SVM can be used as the memory backing
|
|
200
|
-
:class:`pyopencl.array.Array` objects, ensuring that new arrays returned
|
|
201
|
-
by array operations (e.g. arithmetic) also use SVM is easiest to accomplish
|
|
202
|
-
by passing an :class:`~pyopencl.tools.SVMAllocator` (or
|
|
203
|
-
:class:`~pyopencl.tools.SVMPool`) as the *allocator* parameter in functions
|
|
204
|
-
returning new arrays.
|
|
205
|
-
|
|
206
|
-
SVM Pointers, Allocations, and Maps
|
|
207
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
208
|
-
|
|
209
|
-
.. autoclass:: SVMPointer
|
|
210
|
-
|
|
211
|
-
.. autoclass:: SVMAllocation
|
|
212
|
-
|
|
213
|
-
.. autoclass:: SVM
|
|
214
|
-
|
|
215
|
-
.. autoclass:: SVMMap
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
.. _numpy-svm-helpers:
|
|
219
|
-
|
|
220
|
-
Helper functions for :mod:`numpy`-based SVM allocation
|
|
221
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
222
|
-
|
|
223
|
-
.. autofunction:: svm_empty
|
|
224
|
-
.. autofunction:: svm_empty_like
|
|
225
|
-
.. autofunction:: csvm_empty
|
|
226
|
-
.. autofunction:: csvm_empty_like
|
|
227
|
-
.. autofunction:: fsvm_empty
|
|
228
|
-
.. autofunction:: fsvm_empty_like
|
|
229
|
-
|
|
230
|
-
Operations on SVM
|
|
231
|
-
^^^^^^^^^^^^^^^^^
|
|
232
|
-
|
|
233
|
-
(See also :ref:`mem-transfer`.)
|
|
234
|
-
|
|
235
|
-
.. autofunction:: enqueue_svm_memfill
|
|
236
|
-
.. autofunction:: enqueue_svm_migratemem
|
|
237
|
-
|
|
238
|
-
Image
|
|
239
|
-
-----
|
|
240
|
-
|
|
241
|
-
.. class:: ImageFormat([channel_order, channel_type])
|
|
242
|
-
|
|
243
|
-
.. attribute:: channel_order
|
|
244
|
-
|
|
245
|
-
See :class:`channel_order` for possible values.
|
|
246
|
-
|
|
247
|
-
.. attribute:: channel_data_type
|
|
248
|
-
|
|
249
|
-
See :class:`channel_type` for possible values.
|
|
250
|
-
|
|
251
|
-
.. attribute:: channel_count
|
|
252
|
-
|
|
253
|
-
.. versionadded:: 0.91.5
|
|
254
|
-
|
|
255
|
-
.. attribute:: dtype_size
|
|
256
|
-
|
|
257
|
-
.. versionadded:: 0.91.5
|
|
258
|
-
|
|
259
|
-
.. attribute:: itemsize
|
|
260
|
-
|
|
261
|
-
.. versionadded:: 0.91.5
|
|
262
|
-
|
|
263
|
-
.. method:: __repr__
|
|
264
|
-
|
|
265
|
-
Returns a :class:`str` representation of the image format.
|
|
266
|
-
|
|
267
|
-
.. versionadded:: 0.91
|
|
268
|
-
|
|
269
|
-
|comparable|
|
|
270
|
-
|
|
271
|
-
.. versionchanged:: 0.91
|
|
272
|
-
|
|
273
|
-
Constructor arguments added.
|
|
274
|
-
|
|
275
|
-
.. versionchanged:: 2013.2
|
|
276
|
-
|
|
277
|
-
:class:`ImageFormat` was made comparable and hashable
|
|
278
|
-
|
|
279
|
-
.. function:: get_supported_image_formats(context, flags, image_type)
|
|
280
|
-
|
|
281
|
-
See :class:`mem_flags` for possible values of *flags*
|
|
282
|
-
and :class:`mem_object_type` for possible values of *image_type*.
|
|
283
|
-
|
|
284
|
-
.. class:: Image(context, flags, format, shape=None, pitches=None, hostbuf=None, is_array=False, buffer=None)
|
|
285
|
-
|
|
286
|
-
See :class:`mem_flags` for values of *flags*.
|
|
287
|
-
*shape* is a 2- or 3-tuple. *format* is an instance of :class:`ImageFormat`.
|
|
288
|
-
*pitches* is a 1-tuple for 2D images and a 2-tuple for 3D images, indicating
|
|
289
|
-
the distance in bytes from one scan line to the next, and from one 2D image
|
|
290
|
-
slice to the next.
|
|
291
|
-
|
|
292
|
-
If *hostbuf* is given and *shape* is *None*, then *hostbuf.shape* is
|
|
293
|
-
used as the *shape* parameter.
|
|
294
|
-
|
|
295
|
-
:class:`Image` inherits from :class:`MemoryObject`.
|
|
296
|
-
|
|
297
|
-
.. note::
|
|
298
|
-
|
|
299
|
-
If you want to load images from :class:`numpy.ndarray` instances or read images
|
|
300
|
-
back into them, be aware that OpenCL images expect the *x* dimension to vary
|
|
301
|
-
fastest, whereas in the default (C) order of :mod:`numpy` arrays, the last index
|
|
302
|
-
varies fastest. If your array is arranged in the wrong order in memory,
|
|
303
|
-
there are two possible fixes for this:
|
|
304
|
-
|
|
305
|
-
* Convert the array to Fortran (column-major) order using :func:`numpy.asarray`.
|
|
306
|
-
|
|
307
|
-
* Pass *ary.T.copy()* to the image creation function.
|
|
308
|
-
|
|
309
|
-
.. versionadded:: 0.91
|
|
310
|
-
|
|
311
|
-
.. versionchanged:: 2011.2
|
|
312
|
-
Added *is_array* and *buffer*, which are only available on CL 1.2 and newer.
|
|
313
|
-
|
|
314
|
-
.. attribute:: info
|
|
315
|
-
|
|
316
|
-
Lower case versions of the :class:`mem_info`
|
|
317
|
-
and :class:`image_info` constants
|
|
318
|
-
may be used as attributes on instances of this class
|
|
319
|
-
to directly query info attributes.
|
|
320
|
-
|
|
321
|
-
.. attribute:: shape
|
|
322
|
-
|
|
323
|
-
Return the value of the *shape* constructor argument as a :class:`tuple`.
|
|
324
|
-
|
|
325
|
-
.. method:: get_image_info(param)
|
|
326
|
-
|
|
327
|
-
See :class:`image_info` for values of *param*.
|
|
328
|
-
|
|
329
|
-
.. method:: release()
|
|
330
|
-
|
|
331
|
-
|comparable|
|
|
332
|
-
|
|
333
|
-
.. function:: image_from_array(ctx, ary, num_channels=None, mode="r", norm_int=False)
|
|
334
|
-
|
|
335
|
-
Build a 2D or 3D :class:`Image` from the :class:`numpy.ndarray` *ary*. If
|
|
336
|
-
*num_channels* is greater than one, the last dimension of *ary* must be
|
|
337
|
-
identical to *num_channels*. *ary* must be in C order. If *num_channels* is
|
|
338
|
-
not given, it defaults to 1 for scalar types and the number of entries
|
|
339
|
-
for :ref:`vector-types`.
|
|
340
|
-
|
|
341
|
-
The :class:`ImageFormat` is chosen as the first *num_channels* components
|
|
342
|
-
of "RGBA".
|
|
343
|
-
|
|
344
|
-
:param mode: "r" or "w" for read/write
|
|
345
|
-
|
|
346
|
-
.. note::
|
|
347
|
-
|
|
348
|
-
When reading from the image object, the indices passed to ``read_imagef``
|
|
349
|
-
are in the reverse order from what they would be when accessing *ary* from
|
|
350
|
-
Python.
|
|
351
|
-
|
|
352
|
-
If *norm_int* is *True*, then the integer values are normalized to a floating
|
|
353
|
-
point scale of 0..1 when read.
|
|
354
|
-
|
|
355
|
-
.. versionadded:: 2011.2
|
|
356
|
-
|
|
357
|
-
.. function:: enqueue_fill_image(queue, mem, color, origin, region, wait_for=None)
|
|
358
|
-
|
|
359
|
-
:arg color: a buffer object (likely a :class:`numpy.ndarray`)
|
|
360
|
-
|
|
361
|
-
|std-enqueue-blurb|
|
|
362
|
-
|
|
363
|
-
Only available with CL 1.2.
|
|
364
|
-
|
|
365
|
-
.. versionadded:: 2011.2
|
|
366
|
-
|
|
367
|
-
.. _mem-transfer:
|
|
368
|
-
|
|
369
|
-
Transfers
|
|
370
|
-
---------
|
|
371
|
-
|
|
372
|
-
.. autofunction:: enqueue_copy(queue, dest, src, **kwargs)
|
|
373
|
-
|
|
374
|
-
.. autofunction:: enqueue_fill(queue, dest, src, **kwargs)
|
|
375
|
-
|
|
376
|
-
.. function:: enqueue_copy_buffer_p2p_amd(platform, queue, src, dest, size=None, wait_for=None)
|
|
377
|
-
|
|
378
|
-
AMD extension to perform a peer-to-peer copy between two buffers on two different devices.
|
|
379
|
-
The two devices must be in different contexts. The queue must be where the source
|
|
380
|
-
buffer is located.
|
|
381
|
-
|
|
382
|
-
:arg platform: a :class:`Platform` instance
|
|
383
|
-
:arg queue: a :class:`CommandQueue` instance
|
|
384
|
-
:arg src: a :class:`Buffer` instance
|
|
385
|
-
:arg dest: a :class:`Buffer` instance
|
|
386
|
-
|
|
387
|
-
:param size: the number of bytes to copy. If *None*, the minimum of the sizes of the two buffers is used.
|
|
388
|
-
|
|
389
|
-
|std-enqueue-blurb|
|
|
390
|
-
|
|
391
|
-
Only available on AMD platforms.
|
|
392
|
-
|
|
393
|
-
.. versionadded:: 2023.1.2
|
|
394
|
-
|
|
395
|
-
Mapping Memory into Host Address Space
|
|
396
|
-
--------------------------------------
|
|
397
|
-
|
|
398
|
-
.. autoclass:: MemoryMap
|
|
399
|
-
|
|
400
|
-
.. function:: enqueue_map_buffer(queue, buf, flags, offset, shape, dtype, order="C", strides=None, wait_for=None, is_blocking=True)
|
|
401
|
-
|
|
402
|
-
|explain-waitfor|
|
|
403
|
-
*shape*, *dtype*, and *order* have the same meaning
|
|
404
|
-
as in :func:`numpy.empty`.
|
|
405
|
-
See :class:`map_flags` for possible values of *flags*.
|
|
406
|
-
*strides*, if given, overrides *order*.
|
|
407
|
-
|
|
408
|
-
:return: a tuple *(array, event)*. *array* is a
|
|
409
|
-
:class:`numpy.ndarray` representing the host side
|
|
410
|
-
of the map. Its *.base* member contains a
|
|
411
|
-
:class:`MemoryMap`.
|
|
412
|
-
|
|
413
|
-
.. versionchanged:: 2011.1
|
|
414
|
-
*is_blocking* now defaults to True.
|
|
415
|
-
|
|
416
|
-
.. versionchanged:: 2013.1
|
|
417
|
-
*order* now defaults to "C".
|
|
418
|
-
|
|
419
|
-
.. versionchanged:: 2013.2
|
|
420
|
-
Added *strides* argument.
|
|
421
|
-
|
|
422
|
-
Sample usage::
|
|
423
|
-
|
|
424
|
-
mapped_buf = cl.enqueue_map_buffer(queue, buf, ...)
|
|
425
|
-
with mapped_buf.base:
|
|
426
|
-
# work with mapped_buf
|
|
427
|
-
...
|
|
428
|
-
|
|
429
|
-
# memory will be unmapped here
|
|
430
|
-
|
|
431
|
-
.. function:: enqueue_map_image(queue, buf, flags, origin, region, shape, dtype, order="C", strides=None, wait_for=None, is_blocking=True)
|
|
432
|
-
|
|
433
|
-
|explain-waitfor|
|
|
434
|
-
*shape*, *dtype*, and *order* have the same meaning
|
|
435
|
-
as in :func:`numpy.empty`.
|
|
436
|
-
See :class:`map_flags` for possible values of *flags*.
|
|
437
|
-
*strides*, if given, overrides *order*.
|
|
438
|
-
|
|
439
|
-
:return: a tuple *(array, event)*. *array* is a
|
|
440
|
-
:class:`numpy.ndarray` representing the host side
|
|
441
|
-
of the map. Its *.base* member contains a
|
|
442
|
-
:class:`MemoryMap`.
|
|
443
|
-
|
|
444
|
-
.. versionchanged:: 2011.1
|
|
445
|
-
*is_blocking* now defaults to True.
|
|
446
|
-
|
|
447
|
-
.. versionchanged:: 2013.1
|
|
448
|
-
*order* now defaults to "C".
|
|
449
|
-
|
|
450
|
-
.. versionchanged:: 2013.2
|
|
451
|
-
Added *strides* argument.
|
|
452
|
-
|
|
453
|
-
Samplers
|
|
454
|
-
--------
|
|
455
|
-
|
|
456
|
-
.. class:: Sampler
|
|
457
|
-
|
|
458
|
-
.. method:: __init__(context, normalized_coords, addressing_mode, filter_mode)
|
|
459
|
-
|
|
460
|
-
*normalized_coords* is a :class:`bool` indicating whether
|
|
461
|
-
to use coordinates between 0 and 1 (*True*) or the texture's
|
|
462
|
-
natural pixel size (*False*).
|
|
463
|
-
See :class:`addressing_mode` and :class:`filter_mode` for possible
|
|
464
|
-
argument values.
|
|
465
|
-
|
|
466
|
-
Also supports an alternate signature ``(context, properties)``.
|
|
467
|
-
|
|
468
|
-
:arg properties: a sequence
|
|
469
|
-
of keys and values from :class:`sampler_properties` as accepted
|
|
470
|
-
by :c:func:`clCreateSamplerWithProperties` (see the OpenCL
|
|
471
|
-
spec for details). The trailing *0* is added automatically
|
|
472
|
-
and does not need to be included.
|
|
473
|
-
|
|
474
|
-
This signature Requires OpenCL 2 or newer.
|
|
475
|
-
|
|
476
|
-
.. versionchanged:: 2018.2
|
|
477
|
-
|
|
478
|
-
The properties-based signature was added.
|
|
479
|
-
|
|
480
|
-
.. attribute:: info
|
|
481
|
-
|
|
482
|
-
Lower case versions of the :class:`sampler_info` constants
|
|
483
|
-
may be used as attributes on instances of this class
|
|
484
|
-
to directly query info attributes.
|
|
485
|
-
|
|
486
|
-
.. method:: get_info(param)
|
|
487
|
-
|
|
488
|
-
See :class:`sampler_info` for values of *param*.
|
|
489
|
-
|
|
490
|
-
.. automethod:: from_int_ptr
|
|
491
|
-
.. autoattribute:: int_ptr
|
|
492
|
-
|
|
493
|
-
|comparable|
|
|
494
|
-
|
|
495
|
-
Pipes
|
|
496
|
-
-----
|
|
497
|
-
|
|
498
|
-
.. class:: Pipe(context, flags, packet_size, max_packets, properties=())
|
|
499
|
-
|
|
500
|
-
See :class:`mem_flags` for values of *flags*.
|
|
501
|
-
|
|
502
|
-
:arg properties: a sequence
|
|
503
|
-
of keys and values from :class:`pipe_properties` as accepted
|
|
504
|
-
by :c:func:`clCreatePipe`. The trailing *0* is added automatically
|
|
505
|
-
and does not need to be included.
|
|
506
|
-
(This argument must currently be empty.)
|
|
507
|
-
|
|
508
|
-
This function requires OpenCL 2 or newer.
|
|
509
|
-
|
|
510
|
-
.. versionadded:: 2020.3
|
|
511
|
-
|
|
512
|
-
.. versionchanged:: 2021.1.7
|
|
513
|
-
|
|
514
|
-
*properties* now defaults to an empty tuple.
|
|
515
|
-
|
|
516
|
-
.. method:: get_pipe_info(param)
|
|
517
|
-
|
|
518
|
-
See :class:`pipe_info` for values of *param*.
|
|
519
|
-
|
|
520
|
-
Type aliases
|
|
521
|
-
------------
|
|
522
|
-
|
|
523
|
-
.. currentmodule:: pyopencl._cl
|
|
524
|
-
|
|
525
|
-
.. class:: Buffer
|
|
526
|
-
|
|
527
|
-
See :class:`pyopencl.Buffer`.
|