Skip to content

Developer Information

James Price edited this page May 20, 2014 · 3 revisions

Program Structure

Oclgrind consists of three distinct components. The core is the SPIR interpreter/OpenCL device simulator, which can be used either via an OpenCL runtime API implementation or using a standalone kernel interface.

TODO: More implementation details

Oclgrind Core

This component lives in src/core, and produces the library oclgrind-core. Classes within this component are encapsulated in the oclgrind namespace. The header files defining the core classes will be installed to INSTALL_PATH/include/oclgrind/.

OpenCL Runtime API

The runtime lives in src/runtime, and produces the libraries oclgrind and oclgrind-icd. These libraries are almost identical; the only difference is that the ICD version adds underscores to the API functions to avoid clashing with the ICD loader. On Unix systems, an oclgrind script is also generated that uses LD_PRELOAD/DYLD_INSERT_LIBRARIES to force an application to run with Oclgrind (rather than the ICD or an alternative implementation).

Kernel Interface

This component lives in src/kernel, and produces the binary oclgrind-kernel.

Build Systems

There are two build systems used in Oclgrind: autotools and CMake.

Clang/SPIR Generator

At present, Oclgrind has only been tested with patched version of Clang 3.2 that compiles OpenCL C to SPIR, released by the Khronos Group. In the future, the intention is to modify Oclgrind to build with newer versions of LLVM that support SPIR generation out-of-the-box.

Precompiled Headers

During installation, Clang is used to generate a precompiled header for clc.h. This greatly improves compilation times when providing OpenCL C source code to Oclgrind.

Tests

TODO: Details about adding new tests

There are three categories of tests:

  • tests/kernels - tests for kernel language functionality (using oclgrind-kernel)
  • tests/runtime - tests for the OpenCL runtime API
  • tests/apps - full applications that test general functionality

The tests can be with the commands make check (autotools) or make test (CMake). With Visual Studio a RUN_TESTS project will be generated that will run the tests.

Clone this wiki locally