"Robert L." <No_spamming@noWhere_7073.org> writes:
>Marcel Hendrix wrote:
>
>> ( Run on a 64-bit nc Forth, Windows 7 64bit, Intel Core i7 920, 2.67 GHz)
>> FORTH> : foo 1 1000000 * drop ;
>> FORTH> \ : test 1 100000000 ?DO foo LOOP ;
>> : test cr timer-reset 100000000 1 ?DO foo LOOP .elapsed ;
>> FORTH> test
>> 0.219 seconds elapsed. ok
>
>Let's multiply the number of iterations by 5.
Let's multiply them by 10:
: foo 1 1000000 * drop ;
: test 1000000000 1 ?DO foo LOOP ;
see foo
see test
bye
perf stat -e cycles -e instructions vfxlin "include xxx.fs"
shows:
VFX Forth for Linux IA32 Version: 4.72 [build 0555]
Including xxx.fs
FOO
( 080C0AB0 C3 ) NEXT,
( 1 bytes, 1 instructions )
TEST
...
( 080C0AF0 83042401 ) ADD [ESP], 01
( 080C0AF4 8344240401 ) ADD [ESP+04], 01
( 080C0AF9 71F5 ) JNO 080C0AF0
...
As you can see, the mulitplication itself is optimized away, and what
we measure is only the loop overhead (which is a previously known
weakness of VFX at at least 5 cycles latency per iteration on recent
Intel CPUs, thanks to updating the loop counters in memory (instead of
1 cycle when keeping them in registers).
Timing:
5511896630 cycles
3010622182 instructions # 0.55 insns per cycle
1.379565513 seconds time elapsed
I.e., 3 instructions and 5.5 cycles per iteration.
iForth-5.1-mini does not show the disassembly with SEE, so I'll spare
you that. The timing results are:
5790620961 cycles
3414925175 instructions # 0.59 insns per cycle
1.455163427 seconds time elapsed
After subtracting the substantial startup overhead of iForth, these
are essentially the same results as for VFX. So iForth also performs
three instructions per iteration (i.e., it probably optimizes the
multiplication away completely), and also takes 5.5 cycles per
iteration (i.e., it also makes the mistake of keeping the loop counter
in memory).
- anton
--
M. Anton Ertl
http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs:
http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard:
http://www.forth200x.org/forth200x.html
EuroForth 2017:
http://euro.theforth.net/