On Wed, May 29, 2024 at 02:00:29AM +0200, Grégory Vanuxem wrote:
> Hello,
>
> Is there an already implemented way to count the number of Spad
> function calls needed to compute a more general computation?
No.
> I could
> add a global counter to a routine/macro like spadcall or something
> like that, but I am wondering if this was already done? I don't think
> it is simple.
Well, redefining SPADCALL to also increment a counter looks simple,
but of limited use. First, it is likely to measurably increase time
taken by SPADCALL, so it is not good for normal use.
> I have seen in the code some comments about this but I
> do not know how to do it exactly. As an illustration, in the Complex(R
> : CommutativeRing) domain there is this comment:
>
> Ops ==>
> x + y == [x.real + y.real, x.imag + y.imag]
> -- by re-defining this here, we save 5 fn calls
The person who wrote it probably measured execution time and looked why
it is slower than expected. Looking at generated code one can easily
see it operations are inline or done via SPADCALL. If there are
SPADCALL-s one may try to re-arrange code to elliminate them.
And it is easy to see why this helps: generic code would have to
use SPADCALL to acces 'real' and 'imag'. In 'Complex' representation
is visible so code can use access to record components which is
done by inline code.
--
Waldek Hebisch