Overview
0.9a
The libspe2 functionality is split into 4 libraries:
- libspe-base This library provides the basic infrastructure to manage and use SPEs. The central data structure is a SPE context spe_context. It contains all information necessary to manage an SPE, run code on it, communicate with it, and so on. To use the libspe-base library, the header file spebase.h has to be included and and an application needs to link against libspebase.a or libspebase.so.
- libspe-event This is a convenience library for the handling of events generated by an SPE. It is based on libspe-base and epoll. Since the spe_context introduced by libspe-base contains the file descriptors to mailboxes etc, any other event handling mechanism could also be implemented based on libspe-base.
- main thread usually the application main thread running on a PPE
- SPE thread a thread that uses SPEs. Execution starts on the PPE. Execution shifts between PPE and an SPE back and fro, e.g., PPE services system calls for SPE transparently
Note: In the new model, it is not necessary to have a main thread - the SPE thread can be the only application thread. It may run parts of its code on PPE and then start an SPE, e.g., for an accelerated function. The main thread is needed only if you want to use multiple SPEs concurrently. The following minimalistic sample illustrates the basic steps:
Here is the same sample with some error checking:
This illustrates a threaded sample using the pthread library:
Here is the same sample with some error checking:
This illustrates accessing the MFC Local Store Address Register.
This illustrates a sample using the event libary. The event, which we receive is of course that the spu program has stopped, because otherwise we would not get there.
Events are more useful in multithreaded environments: