Coder Social home page Coder Social logo

runinho / v3dlib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wimrijnders/v3dlib

0.0 1.0 0.0 8.39 MB

C++ library for programming the VideoCore GPU on all Raspberry Pi's.

License: Other

Shell 0.02% C++ 8.35% C 91.43% Makefile 0.07% CMake 0.13%

v3dlib's Introduction

V3DLib

Version 0.7.15

V3DLib is a C++ library for creating programs to run on the VideoCore GPU's of all versions of the Raspberry Pi.

Prior to the Pi 4, this meant compiling for just the VideoCore IV GPU. The Pi 4, however, has a VideoCore VI GPU which, although related, is significantly different. V3DLib compiles and assembles for both versions of the VideoCore GPU.

Kernel programs compile dynamically, so that a given program can run unchanged on any version of the RaspBerry Pi. The kernels are generated inline and offloaded to the GPU's at runtime.

Motivation for this Project

The Raspberry Pi's have pretty nifty on-chip capabilities for SIMD vector processing. It bothered me to no end that this is largely unused; the only thing really using it is OpenGL.

The goal of this project is to make the SIMD vector processing accessible for a larger audience, and to ease the pain of programming it.

Getting Started

Before trying to deal with any code, take a moment to view the Basics Page. This will supply you with a working model of the VideoCore and will facilitate your understanding.

Also, for starters, scan the naming conventions at the top of the Architecture and Design Page. Read the rest at your own leisure.

Compiling and Building

This assumes that you are building on a Raspberry Pi.

  • Please look at the Known Issues, so you have an idea what to expect.
  • For more extensive details on building, see Build Instructions.
  • Fair Warning: The first build can take a long time, especially on older Pi's. See the Build Instructions for details.
> sudo apt-get install git                                       # If not done already

> sudo apt install libexpat1-dev                                 # You need this for one lousy include file

> git clone --depth 1 https://github.com/wimrijnders/V3DLib.git  # Get only latest commit
> cd V3DLib
> make QPU=1 DEBUG=1 all                                         # Make debug versions with hardware
                                                                 # GPU support of all examples.
    
> make QPU=1 DEBUG=1 test                                        # Build and run the tests

Code Example

V3DLib contains a high-level programming language for easing the pain of GPU-programming. The following is an example of the language (the 'Hello' program):

#include "V3DLib.h"
#include "Support/Settings.h"

using namespace V3DLib;

V3DLib::Settings settings;


void hello(Int::Ptr p) {                          // The kernel definition
  *p = 1;
}


int main(int argc, const char *argv[]) {
  settings.init(argc, argv);

  auto k = compile(hello);                        // Construct the kernel

  Int::Array array(16);                           // Allocate and initialise the array shared between ARM and GPU
  array.fill(100);

  k.load(&array);                                 // Invoke the kernel
  settings.process(k);  

  for (int i = 0; i < (int) array.size(); i++) {  // Display the result
    printf("%i: %i\n", i, array[i]);
  }

  return 0;
}

Credit where Credit is Due

This project builds upon the QPULib project, by Matthew Naylor. I fully acknowledge his work for the VideoCore IV and am grateful for what he has achieved in setting up the compilation and assembly.

QPULib, however, is no longer under development, and I felt the need to expand it to support the VideoCore VI as well. Hence, V3DLib was conceived.

Useful Links

References

The following works were very helpful in the development.

VideoCore IV

VideoCore VI

Tools


v3dlib's People

Contributors

doleron avatar mn416 avatar runinho avatar wimrijnders avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.