On Fri, Sep 15, 2017 at 5:26 AM, Ralf Hemmecke <[email protected]> wrote:
> Hello,
>
> in extension of what Qian provided, I've tried to remove recursion also
> in other places of the gbintern code.
>
> https://github.com/hemmecke/fricas/commits/no-gb-recursion
>
> I'd like to commit that to the svn repo. Can someone please review the
> attached patch?
>
> Ralf
I reviewed the patch, it's good, and I ran the
control-stack-exhausted.input file,
it got a little faster, 738 seconds, before the patch it was 750 seconds IIRC.
I then took a profile, to my surprise, almost 30% time is spent on
|DIRPROD;subtractIfCan;2$U;17| and |NNI;subtractIfCan;2$U;4|,
see the 'subtractIfCan' calls in gbintern.spad. That function is
implemented in vector.spad
subtractIfCan(u:%, v:%):Union(%,"failed") ==
w := new(dim, 0)$Vector(R)
for i in 1..dim repeat
(c := subtractIfCan(qelt(u, i)$Rep, qelt(v,i)$Rep)) case "failed" =>
return "failed"
qsetelt!(w, i, c::R)$Rep
w pretend %
It has 2 problems:
1. it allocs the 'w' first, which very likely will not be used.
2. subtractIfCan for NNI is very wasteful, the return type
Union("failed", NNI) takes 3 times the space than NNI.
(type Maybe doesn't have this problem, but that's a different topic)
I changed it to (subtractIfCan2 is integer subtraction)
subtractIfCan(u:%, v:%):Union(%,"failed") ==
for i in 1..dim repeat
qelt(u, i)$Rep < qelt(v,i)$Rep=>
return "failed"
map(subtractIfCan2$R, u, v)
together with other small optimization, I managed to speed it up to
443 seconds (saves 40% time).
I'll refine the optimization to make a patch.
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.