PS3 Compiler
ps3

My thesis project is a compiler and virtual machine for the PS3.  Each SPU on the PS3 will run an instance virtual machine, and scripted tasks will be dispatched to the different cores as their dependencies become met.  The goal is to make the concurrency of the PS3 SPUs more accessible by providing higher level language features that support the multi-core hardware model.



Background

This project is currently under development, and due to unexpected delays is scheduled for completion by January of 2009.

I will be developing a compiler for a new variant of Linda for use with the PS3.  Linda allows memory to be checked out from a large pool by workers, which corresponds very nicely to transferring data to SPU local memory.  This language is object oriented and operates via anonymous message passing.  Object values are be posted to a shared memory area (a tuple space). Work items then consume these values if they are capable of processing them.

Once the language is complete, a 3D software rasterizer will be implemented in both this language and in C++.  The complexity of the code required and the runtime speed of both solutions will be measured.  Hopefully, this will demonstrate that code written in the new language is less complex and equally efficient.

The first stage of the project will be spent developing a minimal language which can be compiled to run on both the PPU and SPU of the cell processor.  Next, features will be added to support accessing the shared memory space.  Finally, the ability to spin off worker items will be added to the language.  If time permits, features which are popular in other object oriented languages will be incorporated.

I will use the PS3, running Yellow Dog Linux 6, as both my development environment and as my target platform.  Testing will be performed once a week after the completion of each major feature by developing and running a test case.



Implementation Notes

Though the compiler itself is written in C++, I have elected to implement the runtime in C in order to reduce the compiled size of the resulting executable so that it will better fit on the PS3 SPUs.  The first layer of the compiler is the scanner, which tokenizes the input.  The scanner provides access to these tokens via stl-style iterators, so the entire range can be passed to stl algorithms and the like.  The parser then uses one of these iterators to traverse the entire file and build a parse tree.  Names are resolved every time a scope is exited to ensure proper overloading.  Finally, the nodes are traversed from the root and bytecode is generated.

 

Currently Implemented Features

  • Global functions and runtime stack

  • Reference counted runtime heap

  • Variables capable of storing strings, arrays, floats, ints, and functions

  • Arithmetic, logical, and meny other operators with proper precedence rules

  • Basic control flow statements (while, if-else)

  • Classes containing member functions, member variables, and other classes

  • Compile time name resolution based on current scope

  • Efficient runtime name resolution for class members

  • Virtual machine running on all SPUs


In progress

  • Tuple space implementation

  • In, out, read, and exec operations to interact with tuple space

  • Task scheduler

I will continue to update this page as progress is made.



Example of Current Project State

The script file is on the left, and after being compiled the result of execution is shown on the right.  I added some notes in red.

compiler_error