Cell Simulator |
|
I'm going to skip talking about GUI till a little later. First, now that Cell is installed, we should set up a decent testing environment for programming and then set up a simple program. First, create a directory to store the source code. I created mine in ~/mambo/Code/. Since this is our first program, the standard Hello World is in order. Hence create a directory 'helloworld' in ~/mambo/Code/. Inside ~/mambo/Code/helloworld/ create 'ppu' and 'spu' directories as well. Now, we just need the makefiles and some code to get compiling working. Copy the makefiles of some samples to your directories:$ cp /opt/IBM/cell-sdk-1.1/src/samples/simpleDMA/Makefile ~/mambo/Code/helloworld/ $ cp /opt/IBM/cell-sdk-1.1/src/samples/simpleDMA/ppu/Makefile ~/mambo/Code/helloworld/ppu/ $ cp /opt/IBM/cell-sdk-1.1/src/samples/simpleDMA/spu/Makefile ~/mambo/Code/helloworld/spu/ For the first program, open up hello.c in ~/mambo/Code/helloworld/ppu/hello.c with your favorite editor (AKA vi for the real programmers out there). Type in the following:
#include <stdio.h>
Now, edit the ~/mambo/Code/helloworld/ppu/Makefile to:
# All Rights Reserved. From here, you should be able to make the project: $ make
Congrats! Believe it or not, you have successfully compiled a program for MAMBO. =) Anyways, we now need to run the program to see if it works. In another terminal, lets run the simulator. Again this is done by going into (Wherever MAMBO is)/systemsim-cell/run/cell/linux/, then run:
first press the Fast Mode button to enable the simulator to quickly load up the linux kernel. (Without this, it might take a long time to boot up.) Now click Go The third extra window that came up with the simulator (white) should have a familiar linux boot-up coming up. After awhile it should look like: Right now, the simulator is running and waiting of a linux command. You can try To execute the helloworld program we created, we must first copy the hello program from FC5 to the simulator. To do this we are to going to first copy the hello program to /tmp/ and then use the simulator's callthru program to copy hello into the simulator, change permissions to executable, and then execute. Here are the commands:
$ cp hello /tmp/
Congrats, you have successfully compiled and executed the hello world program. The astute read would notice that the program was compiled for only the PPU (Power Processing Unit). The next tutorial will guide how to compile a program to run on the SPU (Synergistic Processing Unit) as well as the PPU. |