My first foo library
Sometimes we develop a code we would like to be placed in libraries. The Cell BE IDE provides the ability of creating libraries, for both PPU and SPU. In this post I will show you the necessary steps to create a PPU library and link it into a PPU program.
The first step is to create a PPU library, so launch eclipse ide and do the following.
On the left panel where projects are shown right click and then select -> New -> Managed Make C++ Project. Fill the name and the place for the project to be stored and click next. The next dialog will ask you the project type, the Cell PPU Static Library entry has to be selected. Click finish.
We have created the PPU static library project, so we can place code. New->Class. We create a class called Foo with a simple public method to be called from our ppu project. I paste the code in the following lines:
Header
#ifndef FOO_H_
#define FOO_H_
class Foo
{
public:
Foo();
virtual ~Foo();
public : int Sum (int a, int b);
}; #endif /*FOO_H_*/
Body
#include “Foo.h”
Foo::Foo()
{
}
Foo::~Foo()
{
}
int Foo::Sum (int a, int b)
{
return a + b;
}
The next step is to create the PPU project. File-> New -> Managed Make C++ Project. Fill the name of the new project, the place to be located in, etc.
As the Cell BE Tutorial says we must add the libspe2 library to our project, so in the project options, C/C++ Build, configuration Settings, PPU GNU 32 bit C++ Linker-> Libraries->Libraries (-l) -> Add add(spe2)
Create a new source file: File -> New -> Source file (name.cpp) and write the following
#include “Foo.h”
int main(void)
{
return 0;
}
As we save the file and the compilation begins, it will return an error: ‘Foo.h no such file or directory‘. So we have to add extra information to the project to get this code found. We have to tell the project where to find header files as shown bellow.
Now we can place the rest of the code:
#include “Foo.h”
int main(void)
{
Foo f;
int res = f.Sum(2,3);
return 0;
}
The above code compiles fine but we get a linker error because we haven’t told the linker where the code is, so we add this information as shown bellow.

Finally we have our ppu library and a project that uses this library.
We can also a new spu library and use it from a spu projects. The mechanism is very similar the one I have tried to show you.
In my applications I use static libraries instead of dynamic ones. I am doing it because I am running the applications under the simulator and if I don’t do things this way my applications would fail unless I syncronize my simulated environment with the dynamic libraries.
Parallel Cell Programing Conference
In Geilo (Norway) took place a conference about parallel computing (20th-25th january) organized by Sintef (http://www.sintef.no/) . The Cell Broadband Engine processor was one of the stars of this conference.
The course web page is linked here. The electronic versions of the talks can be found in this link.
Simulated processor
This evening I have discovered the processor’s specifications in the simulated environment. In the simulator console we can enter commands once the simulator is launched (the console is not responding if pause is on, so we must run the sim). In fact this is other linux kernel that has been launched inside fedora core 7. In the /proc directory the answer can be found:
[root@(none) proc]# more /proc/cpuinfo
processor : 0
cpu : Cell Broadband Engine, altivec supported
clock : 3200.000000MHz
revision : 5.0 (pvr 0070 0500)
processor : 1
cpu : Cell Broadband Engine, altivec supported
clock : 3200.000000MHz
revision : 5.0 (pvr 0070 0500)
timebase : 25000000
platform : Cell
machine : CHRP IBM,SystemSim-Cell
[root@(none) proc]#
Eclipse IDE for Cell Broadband Engine SDK
First step consist in installing Java JDK 1.4. Once Java is installed the enviorment variables JAVA_HOME and Path have to point to the jre directory.
For example: JAVA_HOME=/usr/java/j2sdk1.4.2_13/jre
PATH=$PATH:/$JAVA_HOME/bin
We can edit this lines in ~/.bash_profile .There are many ways of modifying/creating these variables, like editing /etc/profile, ~/.bashrc if we launch eclipse from a terminal, etc.
Next step is installing eclipse 3.2.x, CDT 3.1. In order to install the ide plugin for eclipse move to the eclipse menu:
Help -> Software Updates -> Find and install -> New local site ( /opt/cell/ide ), and then select ‘com.ibm.celldt.update‘.
SDK 3.0 Installation guide
This post is a summary of the SDK 3.0 installation guide on Fedora Core 7, described in the paper IBM SDK for Multicore Acceleration V3.0 Installation Guide.
Prerequisites. Some packages are required. This packages can be installed as follows:
#yum update selinux-policy selinux-policy-targeted
#yum install rsync sed tcl wget
#yum install expat
Download iso images. The Cell Broadband Engine Resource Center provides the developer and extras packages. If you intent to use the cell broadband engine simulator you must also download the extras package.
Once these images have been downloaded a temporal directory has to be created and the recent downloaded packages copied in it.
#mkdir -p /tmp/cellsdkiso
#cd /tmp/cellsdkiso
#cp /path_iso_images_are_located/*.iso /tmp/cellsdkiso
Yum daemon has to be stopped during installation.
#/etc/init.d/yum-updatesd stop
The daemon status can be checked with the instruction below:
#/etc/init.d/yum-updatesd status
The installation rpm file has to be downloaded and installed.
#rpm -ivh cell-install-3.0.0-1.0.noarch.rpm
In this moment the skd installation starts.
#cd /opt/cell
#./cellsdk –iso /tmp/cellsdkiso install
A graphical installation can be launch. This is an alternative to the sentences above. A new parameter (–gui) has to be added.
#./cellsdk –gui –iso /tmp/cellsdkiso install
Once installation has finished one line has to be added to the yum configuration file (/etc/yum.conf):
exclude=blas kernel numactl oprofile
To check our sysroot image is updated:
#/opt/cell/cellsdk_sync_sdk_simulator install
-
Archives
- May 2009 (1)
- January 2009 (1)
- September 2008 (1)
- August 2008 (1)
- July 2008 (1)
- June 2008 (1)
- March 2008 (1)
- February 2008 (5)
-
Categories
-
RSS
Entries RSS
Comments RSS

