[Cbe-oss-dev] Call/return from PPE to SPE functions

Brian Watt bwatt at us.ibm.com
Wed May 30 00:00:22 EST 2007


> On Tuesday 29 May 2007, Brian Watt wrote:
> > However, this can be only done when the entry point is equal to
> > spe->base_private->entry, and not just any LS address. What I need is 
any
> > entry address to be specified. In addition I need to allow setting a
> > variable number of SPE registers (from 3 up to 75), and then upon
> > completion it needs to return an updated register 3. What does the 
mailing
> > list think about such a capability and the modifications required in
> > LIBSPE2 to accomplish this?
> 
> You could do it in theory, but it would be horribly inefficient. The 
only
> time that you can set SPE general purpose registers is when the context
> is saved in kernel memory. Making a function call to the SPU this way
> basically means having more overhead than starting the program in the
> first place.

Hmmm, there is no "starting the program in the first place", instead the
SPU context would be created, and the program loaded once per 
thread-of-control,
then one or more SPE functions would be called as requested by the PPE 
program
using spe_context_run. So I don't see why there would be any more overhead 
than
today's starting of a main function or a SPE_RUN_USER_REGS function.

The difference in this approach is that the programming model is made much
simplier, because the developer need only write code using the standard 
call-return
paradigm and the system would under-the-covers do the necessary work to 
have the
call-return operate from PPE to SPE and back. I'd even say that the header 
of
an SPU function could be marked so that the compiler would automatically 
generate
this linkage as part of its code generation.
 
> I'd recommend that you define a parameter area in local store for
> your program and pass the arguments by writing in there before you
> call spe_context_run().

Thanks for the suggestion, however, I was trying to mimic the current
linkage convention by using the registers. Nevertheless, I will think
more about passing in arguments in LS similar to what stop-and-signal
does in the other direction, from SPE to PPE.

Today there is a set_regs function in the run.c file that is invoked by
the spe_context_run. This function opens the register spufs file and 
updates
it with the register values. This could still be used for function 
invocation,
although I'm sure that it is an computationally expensive way to update 
the
registers. Possibly a direct program state approach might be better, but
I've not investigated this yet. That is another reason I'm taking about
it here and learning about the options.

To allow the return of the result in a register, a new get_regs function
would need to be added to run.c which is invoked when the completion stop
and signal (0x2000) is received.

Note: this assumes that there is a small _start function (crt0.S) on the
SPE that sets up the stack, and branches to the requested function's entry
point. Presently I'm assuming that when _start is invoke that $0 (register 
0)
contains the function entry point address. Then when the requested 
function
returns, the _start function issues the completion stop and signal.
 
>    Arnd <><

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/cbe-oss-dev/attachments/20070529/f539b9a6/attachment.htm>


More information about the cbe-oss-dev mailing list