cell programming

Just another WordPress.com weblog

How to add cell sdk libraries

In a previous post I explained how to create a library for a PPU program. In this post I am going to explain how to add cell sdk libraries. In this example I am showing how to use the spu simdmath library.

Imagine you are developing a SPU program and you need to use the fabsf4 function (see C/C++ Language Extensions for Cell Broadband Engine Architecture) to compute the absolute value of the elements of a vector.

The fasf4 function is contained in the simdmath library, so it is needed to include some headers and add some directories in the library search path.

In linux there are two types of libraries: static and dynamic libraries. Dynamic libraries in linux are the same as dll’s in Windows. In linux, dynamic libraries use to have ‘.so’ extension and static libraries ‘.a’ extension.

In this case we are looking for static libraries to include that code inside our binaries.

We have to find out the location of this library. The easiest way to find out where headers and libraries are is to perform a search.

[jsanchez@localhost opt]$ cd /opt

[jsanchez@localhost opt]$ find -iname ‘*simdmath.*’
./cell/sysroot/usr/lib/libsimdmath.so.3.0.3
./cell/sysroot/usr/lib/libsimdmath.so
./cell/sysroot/usr/lib/libsimdmath.a
./cell/sysroot/usr/lib/libsimdmath.so.3
./cell/sysroot/usr/lib64/libsimdmath.so.3.0.3
./cell/sysroot/usr/lib64/libsimdmath.so
./cell/sysroot/usr/lib64/libsimdmath.a
./cell/sysroot/usr/lib64/libsimdmath.so.3
./cell/sysroot/usr/spu/lib/libsimdmath.a
./cell/sysroot/usr/spu/include/simdmath.h
./cell/sysroot/usr/include/simdmath.h
[jsanchez@localhost opt]$

If you haven’t understood the find sentence, launch a terminal and put ‘man find’ for more information.

Now we have to include the library in the spu project. The useful data we have extracted from the previous sentece is the following:

/opt/cell/sysroot/usr/spu/include/simdmath.h (header)

/opt/cell/sysroot/usr/spu/lib/libsimdmath.a (library)

We then include the library reference as explained in a previous post using this information. There is just one exception, when the name of the library is added we have to put ’simdmath’, not ‘libsimdmath’, because of the eclipse plugin add the lib prefix when linking the program.

In the test program I added the following headers in the source code.

#include “simdmath.h”
#include “fabsf4.h”

June 1, 2008 - Posted by Javier Sánchez Egido | Cell, Eclipse, Tutorial, library | , , , , | 2 Comments

2 Comments »

  1. Can you give a link to your other posts about Cell BE programming?
    Thanks!

    Comment by Nate | June 11, 2008 | Reply

  2. I am sorry but I have made only just a few post and all that post can be found in this page.

    Comment by Javier Sánchez Egido | June 12, 2008 | Reply


Leave a comment