> 
> "for" loop in REPL is insanely slow, shows no difference.
> 
> Is this benchmark good enough?
> 
> ====
> )abbrev package BENCH1 Bench1
> Bench1() : Exp == Impl where
>    Exp == with
>      barray0 : PositiveInteger -> Void
>      barray1 : PositiveInteger -> Void
>      bvector0 : PositiveInteger -> Void
>      bvector1 : PositiveInteger -> Void
>    Impl == add
>      barray0 N ==
>        a0 := new(N,1)$IndexedOneDimensionalArray(Integer,0)
>        for j in 1..100 repeat
>          for i in 1..(N-1) repeat qelt(a0,i)
> 
>      barray1 N ==
>        a0 := new(N,1)$OneDimensionalArray(Integer)
>        for j in 1..100 repeat
>          for i in 1..(N-1) repeat qelt(a0,i)
> 
>      bvector0 N ==
>        a0 := new(N,1)$IndexedVector(Integer,0)
>        for j in 1..100 repeat
>          for i in 1..(N-1) repeat qelt(a0,i)
> 
>      bvector1 N ==
>        a0 := new(N,1)$Vector(Integer)
>        for j in 1..100 repeat
>          for i in 1..(N-1) repeat qelt(a0,i)
> ====

This is rather poor benchmark.  First, decent optimizing
compiler would optimize it to nothing.  Clearly your
results indicate that it runs _something_ but it is
not clear what you measure.  Second, you are likely to
get very tight loop.  Such loops have more or less
random performance: putting such loop in different
place in memory can change speed by factor of 2.
Adding useless instruction can make loop run faster.
Third, you use too big arrays.  To measure speed of
code you should use arrays which fit into L1 cache.
Resonable size is 1000-2000 which is long enough
to ignore impact of outer loop, but fits in L1
cache leaving a lot of space for other data.

> I do not build a new FriCAS on top of this patch, I just
> )read src/lisp/primitives.lisp
> )co src/algebra/array1
> )co src/algebra/vector
> 
> Result for SBCL:
> 
> barray0(10^6) before vs. after
> 1.03 -- 0.51
> 
> barray1(10^7) before vs. after
> 1.94 -- 1.80

You mean before and after patch to OneDimensionalArrayAggregate?

> The vector results is very similar to array1.
> 
> 1.  Note that 0-based is 5 times slower than 1-based.
> The compiler generated SPADCALL instead of QAREF1,
> I don't understand.

Spad compiler normally only inlines operations
from list of selected domains.  The list
is kept in Boot variable '$optimizableConstructorNames'.
'IndexedOneDimensionalArray' is not on the list.
And we can not add it: inlined operation is not
allowed to depend on domain parameters.  Since
accesor in 'IndexedOneDimensionalArray' depend
on offset which is domain parameter, they can not
be inlined with current compiler.

-- 
                              Waldek Hebisch

-- 
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.

Reply via email to