Git Product home page Git Product logo

opencl_by_example's Introduction

Welcome to OpenCL by Examples using C++.

Why OpenCL?

I actually started learning CUDA for GPGPU first, but since I do my work with a MacBook Air (late 2012 model); I quickly realized I couldn't run CUDA code. My machine has an Intel HD Graphics 4000, I know, it sucks, but still usuable! My search on how to best make use of it led me to OpenCL.

My interests with OpenCL is primarly motivated by my interests in Deep Learning. I want a better understanding of how these frameworks are making use of GPGPU to blaze through model training.

Here we are now, a repo of OpenCL examples. I'll be adding more examples here as I pickup more of OpenCL. I am thinking each example will get a bit more complex.

Setup I am using

  1. Mac OSX
  2. OpenCL 1.2
  3. C++ 11
  4. cmake 3.7

How to Build and Run

  1. Clone this repo and cd in this repo.
  2. Run mkdir build && cd build
  3. Run cmake .. && make

If everything has been correctly installed, you should be able to build the examples with no problems. Check out the CMakeLists.txt file for info on how the examples are being built.

Note, I already added the C++ header for OpenCL 1.x in the libs directory. However, if you are for example working with OpenCL 2 you can create your own header file. Head over to the KhronosGroup OpenCL-CLHPP repo and do the following.

  1. Run git clone https://github.com/KhronosGroup/OpenCL-CLHPP
  2. Run cd OpenCL-CLHPP
  3. Run python gen_cl_hpp.py -i input_cl2.hpp -o cl2.hpp
  4. Move the generated header file cl2.hpp into the libs directory.
  5. Profit!

Quick Introduction and OpenCL Terminology

You're here so I don't need to convince you that parallel computing is awesome and the future. I don't expect you to become an expert after you've gone through this repo, but I do hope you at least get an overview of how to think in OpenCL.

OpenCL™ (Open Computing Language) is the open, royalty-free standard for cross-platform, parallel programming of diverse processors found in personal computers, servers, mobile devices and embedded platforms. - khronos site

The following are terms to know:

  • Platform: Vendor specific OpenCL implementation.
  • Host: The client code that is running on the CPU. Basically your application.
  • Device: The physical devices you have that support OpenCL (CPU/GPU/FPGA etc..)
  • Context: Devices you select to work together.
  • Kernel: The function that is run on the device and does the work.
  • Work Item: A unit of work that executes a kernel.
  • Work Group: A collection of work items.
  • Command Queue: The only way to tell a device what to do.
  • Buffer: A chunk of memory on the device.
  • Memory: Can be global/local/private/constant (more on this later.)
  • Compute Unit: Think of a GPU core.

OpenCL Memory Model

alt text

opencl_by_example's People

Contributors

mez avatar

Watchers

 avatar  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.