The following post provides an introduction to the use of OpenCL™ for programming Parallella.
What is OpenCL?
OpenCL is an industry standard API for parallel programming co-processors on heterogeneous platforms. Designed primarily for computing with general-purpose graphics processing units (GPUs), the API may be used to access the compute capability of other types of devices including multicore CPUs and other accelerators. OpenCL provides a good API for exposing the compute capability of the Epiphany co-processor on the Parallella platform.
OpenCL consists of a kernel programming API used to program the co-processor device and a run-time host API used to coordinate the execution of these kernels and perform other operations such as memory synchronization. The OpenCL programming model is based on the parallel execution of a kernel over many threads to exploit SIMD or SIMT architectures.
OpenCL for the Epiphany Processor
Creating an API for architectures not even considered during the creation of a standard is challenging. This can be seen in the case of Epiphany, which possesses an architecture very different from a GPU, and which supports functionality not yet supported by a GPU. OpenCL as an API for Epiphany is good, but not perfect.
Our focus with the implementation of OpenCL for Epiphany is to leverage the API to support effective parallel programming that takes advantage of the underlying architecture. For programmers familiar with OpenCL in a GPU context, it will be important to understand the key differences and the algorithm design and extensions that must be employed to take full advantage of the Epiphany co-processor. A best-practices guide will be provided to help new and experienced OpenCL programmers get started with Parallella.
OpenCL Support for Parallella: Where We Are Today
The OpenCL support for Parallella is provided by the COPRTHR SDK developed by Brown Deer Technology, with version 1.5 providing full support for the Parallella platform, including OpenCL for both the ARM processor and the Epiphany co-processor. A release candidate is available now, and we are close to locking down the release. As part of an ongoing effort, we will continue to improve the implementation by expanding coverage and optimizing performance.
A few FAQs About OpenCL for Parallella
What version of the OpenCL standard is supported?
The OpenCL implementation for Parallella presently targets the 1.1 standard specification. Programmers should be aware that not all of the standard is implemented at this time and extensions have been added to expose features of the Epiphany architecture not addressed in the standard. The primary objective is to use OpenCL to provide a useful parallel programming model for Parallella programmers.
Why do we use GCC when everyone else uses LLVM?
The choice of compiler is not strongly bound to the COPRTHR SDK – in fact LLVM was once supported by default. For Parallella we use GCC because GCC 4.7 provides the compiler back-end support for the architecture.
Why isn’t the memory local to an Epiphany core considered OpenCL __local memory?
OpenCL address space qualifiers co-mingle the concepts of locality and visibility. For the Epiphany architecture, the per-core memory is most accurately viewed as __private in locality and __local in visibility, with non-uniform access from any core using a common address space.
Where To Go For More Information
The Khronos website provides an excellent starting point for more information about the OpenCL API. The COPRTHR SDK can be downloaded as a pre-built package for Parallella or built from source available on github. A Parallella Quick Start Guide is also available from the download page.
OpenCL™ is a trademark of Apple Inc. used by permission by the Khronos Group which
develops and maintains the OpenCL standard.