PGCL™ is an OpenCL™ framework for compiling and running OpenCL 1.1 embedded profile applications on the ST-Ericsson NovaThor™ U8500 and follow-on platforms using a single ARM core as the OpenCL host and multiple ARM cores as an OpenCL computing device.
The PGCL OpenCL framework consists of five components:
- PGCL driver—a command-level driver for processing source files containing C99, C++ or OpenCL program units. The PGCL driver command pgcl invokes an OpenCL host compiler to create OpenCL host executables and then invokes the PGI OpenCL device compiler to create statically compiled OpenCL device programs packaged as binary shared objects.
- C/C++ compiler for OpenCL host (host compiler)—compiles C99 or C++ program units for the OpenCL host. PGCL uses gcc and g++ as host compilers.
- PGI OpenCL device compiler—compiles OpenCL kernels for an OpenCL computing device.
- OpenCL Platform Layer—a library of routines to query platform capabilities and to create OpenCL device execution contexts from host code using calls to the OpenCL API.
- OpenCL Runtime Layer—a library of routines and a runtime system used to set up and execute OpenCL programs on an OpenCL computing device using calls to the OpenCL API.
The PGCL OpenCL framework is installed and compilation is performed on Linux-x86 (cross-compilation) to produce executables for ST-Ericsson ARM platforms running Android. The PGCL driver, pgcl, can be used to compile OpenCL host applications and to statically compile OpenCL device programs (or “kernels”). Using command line options, the pgcl driver invokes both an OpenCL host C/C++ compiler and the PGI OpenCL device compiler. Unless otherwise specified, the output of pgcl is:
- One OpenCL host ARM executable for the target operating system compiled using the host C/C++ input source files.
- One or more OpenCL programs (collections of kernels) compiled using the OpenCL input source files and packaged as ARM shared object files for the target operating system.
The pgcl driver does not support host source code and OpenCL device source code in the same file. Refer to the PGCL reference information for a detailed description of supported host and device source code file names, and how they are processed.
PGCL supports the Linux-x86 gcc and g++ compilers included in the Android NDK as host compilers. These compilers target ARM processors. The pgcl driver supports most host compiler options. Replacing calls togcc or g++ with calls to pgcl in makefiles retains compatibility plus adds support for resolving references to OpenCL API calls. This approach helps to simplify adding OpenCL kernels to existing applications andmakefiles. The OpenCL host compiler is selectable from the pgcl command line. Additional OpenCL host compilers may be supported in future releases.
The PGI OpenCL device compiler processes OpenCL device program units, or kernels. The OpenCL 1.1 language includes some restrictions to standard C99, and also some extensions in the form of new data types, syntax to support operations on vector types, and built-in support for many mathematical functions (sin, cos, etc). A detailed list of the OpenCL language features supported in current release of PGCL can be found in Appendix C of the PGCL Release Notes.
The PGCL OpenCL Platform Layer and Runtime Layer are provided as libraries bundled with the PGI OpenCL framework. Dynamic runtime compilation of OpenCL kernels on Android is currently not supported but will be added in an upcoming release. Other than this limitation and others implied by the OpenCL embedded profile, the OpenCL 1.1 Platform and Runtime Layer APIs are fully supported. Other PGCL features include:
- Complete support for all OpenCL 1.1 embedded profile language features.
- ARMv7 code generation, including automatic generation of NEON SIMD instructions for operations on OpenCL vector and floating point data types
- Support for launching OpenCL programs from within the Dalvik virtual machine (part of the Android platform)
- Offline static compilation of OpenCL programs and kernels
- A command-level interface designed to enable incremental and seamless integration into existingmakefiles and application build infrastructures