Skip to content
Snippets Groups Projects
runtime.rst 21.19 KiB

OpenCL Platform/Runtime Documentation

Version Queries

Error Reporting

Base class for all PyOpenCL exceptions.

Constants

Platforms, Devices and Contexts

Two instances of this class may be compared using "==" and "!=".

Two instances of this class may be compared using ==" and "!=".

Create a new context. properties is a list of key-value tuples, where each key must be one of :class:`context_properties`. At most one of devices and dev_type may be not None, where devices is a list of :class:`Device` instances, and dev_type is one of the :class:`device_type` constants. If neither is specified, a context with a dev_type of :attr:`device_type.DEFAULT` is created.

Note

Calling the constructor with no arguments will fail for recent CL drivers that support the OpenCL ICD. If you want similar, just-give-me-a-context-already behavior, we recommend :func:`create_some_context`. See, e.g. this explanation by AMD.

Note

For :attr:`context_properties.CL_GL_CONTEXT_KHR`, :attr:`context_properties.CL_EGL_DISPLAY_KHR`, :attr:`context_properties.CL_GLX_DISPLAY_KHR`, :attr:`context_properties.CL_WGL_HDC_KHR`, and :attr:`context_properties.CL_CGL_SHAREGROUP_KHR` the value in the key-value pair is a PyOpenGL context or display instance.

Two instances of this class may be compared using "==" and "!=".

Command Queues and Events

Create a new command queue. properties is a bit field consisting of :class:`command_queue_properties` values.

if device is None, one of the devices in context is chosen in an implementation-defined manner.

Two instances of this class may be compared using "==" and "!=".

Two instances of this class may be compared using "==" and "!=".

A subclass of :class:`Event`. Only available with OpenCL 1.1 and newer.

Memory

Two instances of this class may be compared using "==" and "!=".

Buffers

Create a :class:`Buffer`. See :class:`mem_flags` for values of flags. If hostbuf is specified, size defaults to the size of the specified buffer if it is passed as zero.

:class:`Buffer` is a subclass of :class:`MemoryObject`.

Image Formats

Images

shape is a 2- or 3-tuple.

If hostbuf is given and shape is None, then hostbuf.shape is used as the shape parameter.

:class:`Image` is a subclass of :class:`MemoryObject`.

Note

If you want to load images from :mod:`numpy.ndarray` instances or read images back into them, be aware that OpenCL images expect the x dimension to vary fastest, whereas in the default (C) order of :mod:`numpy` arrays, the last index varies fastest. If your array is arranged in the wrong order in memory, there are two possible fixes for this:

  • Convert the array to Fortran (column-major) order using :func:`numpy.asarray`.
  • Pass ary.T.copy() to the image creation function.

Two instances of this class may be compared using "==" and "!=".

Mapping Memory into Host Address Space

Samplers

normalized_coords is a :class:`bool` indicating whether to use coordinates between 0 and 1 (True) or the texture's natural pixel size (False). See :class:`addressing_mode` and :class:`filter_mode` for possible argument values.

Two instances of this class may be compared using "==" and "!=".

Programs and Kernels

binaries must contain one binary for each entry in devices.

Two instances of this class may be compared using "==" and "!=".

Two instances of this class may be compared using "==" and "!=".

A helper class to pass __local memory arguments to kernels.

GL Interoperability

Functionality in this section is only available when PyOpenCL is compiled with GL support. See :func:`have_gl`.

:class:`GLBuffer` is a subclass of :class:`MemoryObject`.

:class:`GLRenderBuffer` is a subclass of :class:`MemoryObject`.

dims is either 2 or 3. :class:`GLTexture` is a subclass of :class:`Image`.