Compiler Syntax and Behavior

The current version of the CellSs environment is based on source to source C compiler that is able to process user annotations in the code. What is required from the user is to indicate those parts of the code that are to be executed in the SPEs. Since the PPE is slower than the SPEs, the candidates to be annotated are the CPU consuming parts of the application.

The current version of the source to source compiler supports the following features:
 

  • Provide the ability of specifying that a function is a task to be executed in the SPEs.
  • Provide the ability of specifying function parameter directions.
  • Provide the ability of specifying parameters that are arrays and their lengths.

What is to say, the compiler supports the annotation of parts of code encapsulated in a function (or procedure), that have scalar parameters or arrays. The user must indicate the direction of the parameters (input, output or input/output) in order to allow the runtime to find the data dependencies.

Figure below shows an example of code with annotations.

Let's assume array_op is a computation intensive function in a user application. The annotation is indicating that this function can be executed in the SPEs and the direction of the parameters. The function has four input parameters, namely: a, b, index_i and index_j; and an output parameter, c. The { } after the parameter names in the annotation (a, b and c) indicate that those parameters are arrays. In this example, the size of the input or output arrays is not provided since it is already specified in the function interface. As it can be seen, the annotation of the code is very simple. It can be easily used to annotated any kind of software.

From the annotated source code, the CellSs compiler is able to generate two different sets of files: the main program of the application to be executed in the PPE and the tasks code to be executed in the SPEs. In the main program files, the compiler inserts the following code:

  • Calls to CellSs runtime initializing and finalizing functions.
  • Calls for registering the annotated functions. This creates a table of functions that can be later indexed by the SPE generated code.
  • Substitutes the original calls to annotated functions by calls to the Execute function from the CellSs runtime

For the SPE side, the compiler generates an adapter for each of the annotated tasks. These adapters can then be called (under request of the PPE program) from the SPE main program (tasks program), which is hard-coded in the CellSs SPE runtime library.

The current implementation of this compiler is based on the Mercurium compiler. This compiler was originally designed for OpenMP but since its infrastructure is quite general it has been reasonable easy to port it to enable Cell Superscalar.