Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

C6Run QT Fractal Example

From Texas Instruments Wiki
Jump to: navigation, search


C6Run is still available for download, but is no longer being actively developed or maintained. Please consider other alternatives such as, Codec Engine IUNIVERSAL support, OpenCL or RCM.

^ Up to main C6EZRun Main Page ^

This article is part of a collection of articles describing the C6EZRun Software Development Project. Select the link above to return to the main project page.

C6EZRun Based Fractals Demonstration
video platform video management video solutions video player
C6EZRun Based Fractals Demonstration


This demo is a modification of the standard Mandelbrot fractal demo that ships with the Qt 4.6 development kit, which is described here. This page describes how one can get the demo modified to make use of the floating point DSP core available on platforms using the TI OMAP-L137 or OMAP-L138 embedded processors. The usage here shows off the C6Run project, which is an ease-of-use tool for ARM developers to leverage the DSP on TI's DSP+ARM embedded processors.


The following video shows a demonstration of the fractals demo and the benefits of DSP using C6Run: [1]

Fractal Background

For our purposes, a fractal is the set of points in the complex plane that when used as an input value in an iterated complex function, results in the function converging (not exceeding a certain bound). For computer graphics, coloring is added to describe the rate of conversion/diversion and this is what makes the fractal image interesting. The iterative complex function uses complex numbers with real and imaginary parts. In a computer processor, these complex numbers are represented using a pair of floating-point numbers, hence the operations on the complex numbers are floating-point operations. Ideally, a processor with floating point hardware would execute this code

Mandelbrot fractal

This Wikipedia article gives a very good overview of the particular fractal known as the Mandelbrot set. The iterative function that describes the set is fairly simple

zn+1 = zn2 + c

A complex number, c, is in the Mandelbrot set if, when starting with z0 = 0 and applying the above iteration repeatedly, the magnitude of zn does not diverge (is bounded).

Qt Demo Description

The demo is an application that uses the Qt application framework. Qt is used for user interface. This includes touchscreen, display, various icons etc. There are two threads running in the demo, one for the user interface (UI) and one for rendering the image that is displayed.

For demoing the power of the DSP using C6Run, the rendering thread has had the computation components extracted from the RenderThread::run() member function. These computations have been moved into a function in their own C file, which was compiled into a static library using the C6RunLib tools. The RenderThread::run() method now calls the extracted C function, which in turn makes use of the DSP for execution. The complex process of how the execution is proxied to the DSP is hidden from the user. The demo highlights how easy it is to get DSP acceleration for an ARM developer.

When running the Qt Mandelbrot example on the ARM9 core of the OMAP-L138, the redraw operation can take minutes. Switching the render computations to use the DSP immediately speeds up the calculations time required to mere seconds. Actual times vary due the complexity of the scene and the number of iterations required per pixel, but using the DSP consistently speeds up the rendering by a factor of 10 or more.


To build the C6Run-enhanced Qt fractal demo, you can follow the steps given below.

  1. Install the Qt 4.6 development system. The procedures here assume you have the qt examples as part of the linux-devkit path, which exists if you are inside the TI SDK4 environment or if you are developing for a community platform using Angstrom. If you are doing this in a standalone environment, you may want to check here for instructions on how to get started.
  2. Make sure the C6Run tool has been configured and the back-end libraries have been built. Within an SDK4 environment, this can be done by
    [host] $ make c6run
    from the top level of the SDK4 install directory
  3. Source the needed C6Run variables by executing the following:
    [host] $ source <C6RUN_INSTALL_DIR>/
  4. Setup any required settings for building QT applications. Inside a Angstrom host development kit or a TI SDK4 environment, this can be done by sourcing the environment setup script in the linux-devkit directory
    [host] $ source linux-devkit/environment-setup
  5. Go into the mandelbrot example directory. In the TI SDK4:
    [host] $ cd linux-devkit/arm-none-linux-gnueabi/usr/bin/qtopia/examples/threads/mandelbrot
    In an Angstrom host development environment:
    [host] $ cd linux-devkit/arm-angstrom-linux-gnueabi/usr/bin/qtopia/examples/threads/mandelbrot
  6. Save a copy of the original source files, in case something goes wrong.
    [host] $ mkdir ../mandelbrot_orig; cp *.* ../mandelbrot_orig/
  7. Generate the required Qt project (.pro) file.
    [host] $ qmake -project
  8. Download the qt-mandelbrot-accel-Add-DSP-acceleration.patch patch file to the mandelbrot example directory
  9. Apply the downloaded patch. This requires your host system to have the git source control client installed.
    [host] $ git apply qt-mandelbrot-accel-Add-DSP-acceleration.patch
  10. Build the C6Run-based library. This will generate the critical.o file:
    [host] $ ${C6RUN_TOOLCHAIN_PATH}/bin/c6runlib-cc -O3 -c -ms0 critical.c
    This will create the critical.lib static library from the critical.o object file:
    [host] $ ${C6RUN_TOOLCHAIN_PATH}/bin/c6runlib-ar rcs critical.lib critical.o
    If you wanted to run this modified example on the ARM only (for comparison with the DSP accelerated version, for example), you could use the following commands:
    [host] $ ${ARM_TOOLCHAIN_PATH}/bin/${ARM_TOOLCHAIN_PREFIX}gcc -O3 -c critical.c
    [host] $ ${ARM_TOOLCHAIN_PATH}/bin/${ARM_TOOLCHAIN_PREFIX}ar rcs critical.lib critical.o
  11. Generate the Qt project Makefile.
    [host] $ qmake
  12. Build the final executable.
    [host] $ make

Running the C6Run Fractal Demo

The output executable file, mandelbrot, needs to be loaded to the target filesystem for execution. Before running the program, the CMEM and DSPLink kernel modules must be installed using the script generated during the C6Run configuration step. In an SDK4 filesystem, it is likely the script is located in /usr/share/ti/c6run-apps. If it is not already in the target filesystem, it can be found in <C6RUN_INSTALL_DIR>/platforms/<PLATFORM> on the host and then copied to the target filesystem. Once this script is executed, the mandelbrot program can be executed as

[host] $ mandelbrot -qws

Return to C6Run Main Page

^ Up to main C6EZRun Main Page ^

This article is part of a collection of articles describing the C6EZRun Software Development Project. Select the link above to return to the main project page.