OpenCL framework, tutorial and examples

Moderator: dar

OpenCL framework, tutorial and examples

Postby CyberHiPriest » Mon May 02, 2016 2:42 pm

I've finished up playing around with OpenCL and the COPRTHR library.

The fun way to explore the Epiphany & OpenCL was to create some graphical examples. You get instant (visual) feedback of your code and a good feeling of what is possible.

I also learned about the limitations of COPRTHR and what I would like to see changed and improved, but I'll discuss that in another thread.

Here are some screenshots of a few examples:

A field of cubes
cubes.jpg (64.51 KiB) Viewed 12506 times

Mandelbrot zoomer
fractalzoom.jpg (260.58 KiB) Viewed 12506 times

Raymarched tunnel with ribbon
tunnel.jpg (130.98 KiB) Viewed 12506 times

The code for all of this can be found at

Please feel free to contribute examples, bugfixes, speed optimizations, etc.
What is raymarch?

RayMarch is a WIP framework to create raymarching OpenCL code that runs with the COPRTHR library on x86(_64) Linux PC and the Parallella board (ARMv7 & Epiphany 16-core accellerator).

How to use?

It's pretty simple actually; just copy an example from the examples directory to the '' file, and do a 'make'.

Code: Select all
# cp examples/ ./
# make clean; make
# ./raymarch -h
RayMarch, a WIP raymarching example framework using COPRTHR and OpenCL.
(C) Copyright 2016, Jan Vermeulen <>, all rights reserved.
Released under GPLv3, see file LICENSE for details.
Error. Unrecognized option: -h

Usage: ./raymarch [options]
    -c      Use CPUs (COPRTHR) as OpenCL target.
    -a      Use accellerator (Epiphany) as OpenCL target.
    -g      Use GPU as OpenCL target.
    -nthreads X Use X number of threads/compute units.
# ./raymarch -a -nthreads 16

That's it basically.

Check out the examples, many are reworked versions from website.

If you want to contribute your own examples, just start with the example and implement your own 'render_pixel' function.


  • Optimize the speed of the kernels & functions.
  • Figure out why some examples create an Alignment Trap on the ARM CPU.
  • More (and better) examples.
Server park:
Parallella Z7010 w/ E16G03 (microserver) with Linaro Ubuntu 15.04
PowerPC405 board with custom Linux 2.6.35
PowerPC e300c3 board with custom Linux 2.6.38
Marvell 88F6192 board with Arch Linux
MIPS64r3 board with custom debian Linux 2.2.27
User avatar
Posts: 4
Joined: Tue Apr 26, 2016 2:12 pm

Re: OpenCL framework, tutorial and examples

Postby jar » Tue May 03, 2016 1:58 am

Cool. Good work. Maybe you could add this to the parallella-examples repository on github with a pull request?

I perused your device code. It's barely OpenCL other than determining the thread ID and using float2/float4 data structs. And I don't mean that as a knock on the code, but rather to suggest that you are using a complicated programming model and just about none of the features. For ray tracers, the code is trivially parallel amd they have significant arithmetic complexity so that they don't really stress the memory heirarchy or inter-core memory movement. This is fine, but it's not able to really stress the API in order to demonstrate why OpenCL doesn't match the architecture well. If that makes sense...
User avatar
Posts: 295
Joined: Mon Dec 17, 2012 3:27 am

Return to OpenCL

Who is online

Users browsing this forum: No registered users and 1 guest