Skip to main content

This package extends PyOpenCl by providing an object-oriented kernel programming framework and debugging capabilities.

Project description

This package extends PyOpenCl by providing an object-oriented kernel programming framework and debugging capabilities.

What makes pyopencl-extension special?
  • Build on top of PyOpenCl which can increase performance significantly.

  • Usage of this framework forces consistent code when programming for GPU.

  • Allows debugging of OpenCl-Programs through kernel emulation in Python using a visual debugger (tested with Pycharm).

  • OpenCl emulation allows to find out-of-bounds array indexing more easily.

  • Integrated profiling features give quick overview over performance bottlenecks.

The project is in an early development stage and actively maintained. For any feature requests/feedback/etc. you can get in touch via Github or by E-Mail (philipp.mohr@tuhh.de).

Installation

Install this library with pip install pyopencl-extension.

When automatic installation of PyOpenCl fails (happens when using Windows):

  1. Download appropriate .whl binary from PyOpenCl binaries for Windows

  2. Make sure to have proper OpenCl driver for your graphics card installed.

  3. Run pip install "pyopencl-X-cpX-cpX-X.whl" in terminal, where X must be replaced with corresponding version.

Usage

One very simple example is given below.

from pyopencl_extension import Kernel, Global, Scalar, Types, zeros
import numpy as np

ary = zeros((10,), Types.short)

knl = Kernel('some_operation',
             {'ary': Global(ary),  # notice that ary is set as default argument
              'number': Scalar(Types.short)},
             """
                ary[get_global_id(0)] = get_global_id(0) + number;
             """,
             global_size=ary.shape).compile(emulate=True)
knl(number=3)
assert np.allclose(ary.get(), np.arange(10) + 3)

By setting the argument ‘emulate=True’ the kernel will be compiled in emulation mode. This mode creates a file ‘some_operation.py’, which can be inspected using a visual debugger:

https://i.imgur.com/Gfg9AtZ.png

More advanced examples can by found in the tests hosted on Github.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyopencl-extension-0.2.9.tar.gz (65.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyopencl_extension-0.2.9-py3-none-any.whl (59.2 kB view details)

Uploaded Python 3

File details

Details for the file pyopencl-extension-0.2.9.tar.gz.

File metadata

  • Download URL: pyopencl-extension-0.2.9.tar.gz
  • Upload date:
  • Size: 65.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for pyopencl-extension-0.2.9.tar.gz
Algorithm Hash digest
SHA256 4c74d84bbd70bc4bb02c1e5911c2272e8ddc1f2737e9bb646f9da22fbc7094ce
MD5 d22768012ef01b2caeb6018fb1fc235c
BLAKE2b-256 1487d8d34ffa10ffc6342f599aa68fa7f721340f4d57628b51e54e8d1d66d791

See more details on using hashes here.

File details

Details for the file pyopencl_extension-0.2.9-py3-none-any.whl.

File metadata

  • Download URL: pyopencl_extension-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 59.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for pyopencl_extension-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 090eb8ec5335dfbd307e660fd3fa39848fb1a410f6a58d7a51e89d157ce1b78f
MD5 6249f54c46162cc75f6915ee0e16e02d
BLAKE2b-256 f18b228540030b6a72d4b2a5dd1b883815adb4249752a1da1c867832d9527095

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page