Example 1: Euler particle-system simulation

This programming example illustrates many of the concepts discussed earlier in this chapter.

It can be found in the SDK under:
 /opt/cell/sdk/src/tutorial/euler
This example — a simple Euler-based particle-system simulation — illustrates the following steps involved in coding for the Cell Broadband Engine:
  1. Transform scaler code to vector code (SIMDize) for execution on the PPE's VXU.
  2. Port the code for execution on the SPE's SPU unit.
  3. Parallelize the code for execution across multiple SPEs.

A subsequent step — tuning the code for performance on the SPE — is covered in Performance analysis. The above steps are only one example of coding for the Cell Broadband Engine. The steps can be reordered or combined, depending upon the skill and comfort level of the programmer.

This example shows a particle-system simulation using numerical integration techniques to animate a large set of particles. Numerical integration is implemented using Euler's method of integration. It computes the next value of a function of time, F(t), by incrementing the current value of the function by the product of the time step and the derivative of the function:
 F(t + dt) = F(t) + dt*F'(t);
Our simple particle system consists of:
This programming example is intended to illustrate programming concepts for the Cell Broadband Engine, and is not meant to be a physically realistic simulation. For example, it does not consider: In addition, we assume that all 3-D vectors (x,y,z) are expressed as 4-D homogeneous coordinates (x,y,z,1).