Cell Broadband Engine

Wednesday, January 10, 2007

If you have enjoyed hacking with the Cell SDK 1.1, it is perhaps time to port your code to the SDK 2.0 and experiment with the new available features. In this and the upcoming posts I will be covering some of the news of the SDK 2.0 as well as some of issues you have to face when porting code from SDK 1.1 to SDK 2.0.

The first thing worth mentioning is that the SDK 2.0 has upgraded to GCC 4.1.1 and XLC 8.1. These compiler should provide better performance than those which were shipped with the SDK 1.1. My first few measurement with GCC confirm this statement.

Beware that there has been some restructuring and cleaning up of the directory structure as well as include path. Thus if you has some Makefile, or configuratio file which were relying on the SDK 1.1 structure you'll have to workout some changes.

Another difference that you'll find in the SDK 2.0 is that now it is not necessary any more to explicitely import the libc.a when compiling SPU code. Thus you will have to remove all the $(SDKLIB_spu)/libc.a that might be contained in the IMPORT variable in your makefile.

Beware that in SDK 2.0 you always have to include the header cbe_mfc.h before the header math.h. If you do viceversa you'll see some compilation errors on the function __fabs.

Wednesday, November 15, 2006

Cell provides mailboxes in order to nicely synchronize SPEs and PPE. However, there is something that should be taken into account by programmers who care about performances. When the SPE use mailboxes to communicate with the PPE, the latter performs a DMA transaction for each tentative read of the mailbox. The end result is that a lot of bus traffic is generated, which might adversely impacts performances. Another approache that, while less user friendly, ensure maximum performances is tu rely on Spinlocks and DMA transfers. The basic idea is to have the PPE and the SPE coordinate by writing some agreed areas of the main memory and local store respectively. The code below shows how you might achieve this. Actually the sample code, allows you to measure the performance of this spinlock synchronization, which you can easily compare with mailbox based synchronization.

---------- SPE Code ------------#include <stdio.h>#include <stdlib.h>

#include <libspe.h>#include <cbe_mfc.h>

// -- Common Include --#include "cbench/common.h"

extern spe_program_handle_t cbench_spinlock_spu;

volatile unsigned long long spinlock __attribute__((aligned(128)));unsigned long long spinlock_spu __attribute__((aligned(128)));

/* * This has to be an unsigned long long, just because we need to write * this much on the destination spinlock. */unsigned long long spinlock_spu_ls __attribute__ ((aligned (128)));unsigned int spinlock_ppu_ea __attribute__ ((aligned (128)));

Sunday, November 12, 2006

A few weeks ago there was a summit on Software and Algorithms for the Cell Processor. The material presented at the summit can be found at here. Several interesting slides set are available, however I would recommend Cell programmers to take a look at Cell BE Programming Gotchas. This presentation has a few things you always want to keep in mind when programming Cell. I would add a few things to that, and would probably make some logs to contribute some more gotchas.

Another presentation worth looking at, is Experience Programming Cell. This presentation shows some good hints on the kind of computation that Cell enjoys, and those that it does not. To many people this should not come to a surprise, but it is always good to set the stage for everyone. After looking at this presentation, then you might want to look at this presentation on the Roadrunner Supercomputer.

In the last few weeks I've been working on a new cool processor,called the Cell Broadband Engine. This is an heterogeneous multi-core processorwhich will be powering the upcoming Sony PlayStation 3. Thearchitecture of the processor is rather neat, and programming it feelslike doing distributed computing, which is one of the thing I am usedto do the most.

I used to post Cell BE related blogs in my online collectionofrandom thoughts. I thougt that perhaps it would have been better tohave a Blog dedicated to Cell, thus I went ahead and created it. I'llbe moving all the Cell related blog entry over here.