/py-videocore

Python library for GPGPU on Raspberry Pi

Primary LanguagePythonMIT LicenseMIT

PyVideoCore

This is work in progress project. Backward compatibility is not guaranteed.

PyVideoCore is a Python library for GPGPU on Raspberry Pi boards. The Raspberry Pi SoC integrates Broadcom VideoCore IV graphics core. It has 12 quad processor units (QPU) which is a dual-issue 16 way (4 way pipelined and 4 way true) SIMD processor. Read the following guide thoroughly to study its architecture.

Several QPU assemblers are written by pioneers (hermanhermitage, petewarden, elorimer and so on). There is also an implementation of OpenCL for QPU: VC4CL.

PyVideoCore's QPU assembler is different from theirs in terms of that its assembly language is implemented as an Internal DSL of Python language. This makes GPGPU programming on Raspberry Pi relatively easier in the sense that

  • You can put host programs and GPU side programs in a single Python script.
  • You can execute the program without ahead-of-time compilation.
  • You can utilize Python functionality, libraries and tools to organize GPU programs.

Requirements

  • Raspberry Pi or Pi 2
  • Python 2 (>= 2.6) or Python 3
  • NumPy
  • rpi-vcsm >= 2.0.0
  • nose (if you want to run tests)

Installation

$ git clone https://github.com/nineties/py-videocore.git
$ cd py-videocore
$ sudo python setup.py install

You might need to update firmware.

$ sudo rpi-update

You can increase GPU memory size by raspi-config.

$ sudo raspi-config

Be Careful

  • You need to run programs as a super user so that this library can access /dev/mem.
  • Accessing wrong location of /dev/mem, due to a bug of this library or your program, may make your system unstable or could break your machine.

Getting Started

$ sudo python examples/hello_world.py

Running Tests

sudo nosetests -v
  • 128MB or more GPU memory is required to pass tests. Failed some tests with 64MB or less.

Documentation

TBD

Tutorials

In japanese.

Records

  • Achieved 8GFlops with sgemm.

https://pbs.twimg.com/media/CWYjkH7U4AAh9VE.jpg

License

Code and documentation are released under MIT license


[1]Supplementary information and errata list.