Leopold Toetsch <[EMAIL PROTECTED]> writes:

> I've stripped down the whole stack code to use one item per chunk. It
> passes all tests (3 disabled that push infintely and check for
> CHECK_LIMIT and t/pmc/eval_6 which is borken).
>
> This slows down register saving (and other stack operations)
> considerably whithout any additional measures[1]:
>
> $ perl tools/dev/parrotbench.pl -c=parrotbench.conf -b='^oof' -t
> Numbers are cpu times in seconds. (lower is better)
>          p-j-Oc  parr-j  parr-C  perl-th perl    python  ruby
> oofib   4.150s  11.530s 12.450s 4.100s  3.540s  2.140s  2.170s
>
> p-j-Oc = parrot -j -Oc where savetop is optimized to pushtopp
> parr-j = parrot -j, all 4 registers are saved (both unoptimized build)

Interesting. I redid oofib.imc to only save the registers it cares
about rather than using savetop, and here are my numbers (admittedly on
a PowerMac G5:

        parrot  parrotj parrotC perl    python  ruby
oofib   3.770s  3.190s  2.950s  2.210s  1.100s  1.770s
oofibt  7.750s  7.370s  6.960s  2.210s  1.140s  1.800s


oofibt is the original version, oofib is my rewrite (attached). The
perl, python & ruby equivalents were generated with a simple copy...

For reference, here are the numbers using a CVS fresh parrot:

        parrot  parrotj parrotC perl    python  ruby
oofib   3.770s  3.150s  3.100s  2.210s  1.080s  1.960s
oofibt  6.700s  6.240s  6.170s  2.330s  1.040s  1.890s

So it looks like saving single registers is a win whichever parrot
you're using...

.pcc_sub _main prototyped
    .param pmc argv
    .sym int argc
    argc = argv
    .sym pmc N
    N = new PerlInt
    N = 28
    if argc <= 1 goto noarg
    $S0 = argv[1]
    N = $S0
noarg:
    .sym float start
    time start

    .local pmc A
    .local pmc B
    .local pmc b

    A = newclass "A"
    B = subclass  A, "B"

    find_type $I0, "B"
    b = new  $I0

    .sym pmc r
    r = b."fib"(N)

    .sym float fin
    time fin
    print "fib("
    print N
    print ") = "
    print r
    print " "
    sub fin, start
    print fin
    print "s\n"
    end
.end

.namespace ["A"]

.sub fib method
    .param pmc n
    if n >= 2 goto rec
    .pcc_begin_return
    .return n
    .pcc_end_return
rec:
    .sym pmc n1
    .sym pmc n2
    .sym pmc r1
    .sym pmc r2
    n1 = new PerlInt
    n2 = new PerlInt
    n1 = n - 1
    n2 = n - 2
    P5 = n1
    I0 = 1
    I1 = 0
    I2 = 0
    I3 = 1
    I4 = 0
    S1 = "fibA"
    save P1
    save n2
    save self
    callmethodcc
    restore self
    r1 = P5
    restore P5

    I0 = 1
    I1 = 0
    I2 = 0
    I3 = 1
    I4 = 0
    S1 = "fibB"
    save r1
    callmethodcc
    restore r1 
    restore P1
    P5 = P5 + r1
    I0 = 1
    I1 = 0
    I2 = 0
    I3 = 1
    I4 = 0
    invoke P1
    end
.end

.sub fibA method
    .param pmc n
    if n >= 2 goto rec
    .pcc_begin_return
    .return n
    .pcc_end_return
rec:
    .sym pmc n1
    .sym pmc n2
    .sym pmc r1
    .sym pmc r2
    n1 = n - 1
    n2 = n - 2
    P5 = n1
    I0 = 1
    I1 = 0
    I2 = 0
    I3 = 1
    I4 = 0
    S1 = "fib"
    save P1
    save n2
    save self
    callmethodcc
    restore self
    r1 = P5
    restore P5

    I0 = 1
    I1 = 0
    I2 = 0
    I3 = 1
    I4 = 0
    S1 = "fibB"
    save r1
    callmethodcc
    restore r1 
    restore P1
    P5 = P5 + r1
    I0 = 1
    I1 = 0
    I2 = 0
    I3 = 1
    I4 = 0
    invoke P1
.end

.namespace ["B"]

.sub fibB method
    .param pmc n
    if n >= 2 goto rec
    .pcc_begin_return
    .return n
    .pcc_end_return
rec:
    .sym pmc n1
    .sym pmc n2
    .sym pmc r1
    .sym pmc r2
    n1 = new PerlInt
    n2 = new PerlInt
    n1 = n - 1
    n2 = n - 2
    P5 = n1
    I0 = 1
    I1 = 0
    I2 = 0
    I3 = 1
    I4 = 0
    S1 = "fib"
    save P1
    save n2
    save self
    callmethodcc
    restore self
    r1 = P5
    restore P5

    I0 = 1
    I1 = 0
    I2 = 0
    I3 = 1
    I4 = 0
    S1 = "fibA"
    save r1
    callmethodcc
    restore r1 
    restore P1
    P5 = P5 + r1
    I0 = 1
    I1 = 0
    I2 = 0
    I3 = 1
    I4 = 0
    invoke P1
.end

Reply via email to