SPU Code Overlay

From OpenCV on the Cell

(Redirected from SPU code overlay)
Jump to: navigation, search

The SPU programs of the cvcell library uses the overlay manager contained in spu-ld, in order to reduce overhead of function call from PPU.


What is SPU code overlay?

SPU code overlay is the mechanism of executing the program exceeding LS size. The overlay manager is contained in spu-ld. Please refer to Software Development Kit 2.1 Programmer's Guide.


The following figure is the example of an overlay program. There is no dependency between A-B and C-D-E. The main calls module A, it is loaded to the Region 1. And module B is called, it overwrites module A.


image:OverlayOutline.png


Note:

  • Only a text section and a rodata section are loaded.
  • Other section as data, bss, ... are mapped Region 0.

Overlay in the CVCell

In the cvcell, the overlay mechanism is used in order to switch SPU programs quickly. As compared with libspe, the call overhead can be shortened about to 1/100.



Note:

  • Since there is no start-up, it is necessary to clear bss by the beginning of each program.
  • A global constructor is not performed.


Create the overlay module

The following is a link parameter for creating a overlay module mainA.seg from a.o, b.o and c.o.


spu-g++ -T ld.script.seg -Wl,-Ttext,2000 -Wl,-e,mainA -Wl,-gc-sections -nostartfiles -o mainA.seg a.o b.o c.o
Parameter Description
-T ld.script.seg Specify a linker script.
-Wl,-Ttext,2000 Fix the address of text section.
-Wl,-e,mainA Set an entry address to mainA.
-nostartfiles Create an execution module without a start-up routine.


Make it into a local label except mainA.

spu-objcopy --keep-global-symbol mainA mainA.seg


ld.script.seg:

.rodata         : { *(.data .data.* .rodata .rodata.* .gnu.linkonce.r.*) }

Include a .data section in .rodata in an execution module, to load by overlay manager.

Views
Personal tools
Toolbox