Tuesday, October 28, 2014

Oil Runtime Compiler (ORC)

Orc(Oil Runtime Compiler) is a just-in-time compiler implemented as a library and set of associated tools for compiling and executing simple programs that operate on arrays of data.  Orc is unlike other general-purpose JIT engines: the Orc bytecode and language is designed so that it can be readily converted into SIMD instructions.  This translates to interesting language features and limitations: Orc has built-in capability for SIMD-friendly operations such as shuffling, saturated addition and subtraction, but only works on arrays of data.  This makes Orc good for applications such as audio processing, array math, and signal analysis & image processing.
The “code” is currently an intermediate form that is roughly a platform-agnostic assembly language that understands variables and simple arrays. It’s an intermediate form in the sense that it’s currently only stored as a list of structs — there isn’t a parser yet. 
The Orc language is an assembly-like language,The Orc tools then convert this into an intermediate form (as C source code) that includes the bytecode, functions for automatically calling the compiled bytecode from C, and backup functions (in C) that are used when Orc is not available or unable to compile the bytecode into efficient SIMD code.  Orc generates code optimized for the specific processor that is running, using instruction sets that are available.ORC will include the compiler support for speculative multi-threading
Since Orc creates backup functions, you can optionally use many Orc-using libraries and applications without actually having the Orc library — this is useful for transitioning an application into using Orc.  However, when Orc is disabled, the application is unable to use the SIMD code generated by Orc.
Additional opcode sets can be created and registered in a manner similar to how the liborc-float and liborc-pixel libraries. In order to make full use of new opcode sets, one must also define rules for translating these opcodes into target code. The example libraries do this by registering rule sets for various targets (mainly SSE) for their opcode sets. Orc provides low-level API for generating target code. Not all possible target instructions can be generated with the target API, so developers may need to modify and add functions to the main Orc library as necessary to generate target code.