Sieve of Eratosthenes - Spin vs. Asm benchmark
Bill Henning
Posts: 6,445
I wanted to see a Spin vs. Asm benchmark, so I threw together a quick prime number generator.
It's probably buggy, inelegant etc., but it gives an indication of the speed difference - native asm code that does a lot of hub access is still approximately 42x faster than spin.
It uses my 320x240 bitmap hack to view the bit flags "live"
bug fixes welcome.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com - a new blog about microcontrollers
It's probably buggy, inelegant etc., but it gives an indication of the speed difference - native asm code that does a lot of hub access is still approximately 42x faster than spin.
It uses my 320x240 bitmap hack to view the bit flags "live"
bug fixes welcome.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com - a new blog about microcontrollers
Comments
good to know! As you are well aware you are not sieving primes with your program, but to accomplish that would only be a small change, and was not your purpose in the first place.
But this makes it easier to do the math The central loop body in your assembly code takes around 1 µs, and it is peformed 3 mio times (as SUM( 1/3...1/256) = 4.6 ), so it should take 3 seconds @80 MHz - correct me of I am wrong
The SPIN code consists of a medium complex REPEAT (15..20 µs) plus 3 operations (<< |< |=) taking 3*7 µs
So I should have guessed a speed-up of 35 to 40 (rather than the 42 you have meassured)
There is some optimization potentiality in the machine code, but not more than 30%.
The main reason why SPIN is so "fast" with this example is the use of constants (5, 64k); substituting them by variables will bring you closer to deSilvas "80"
Post Edited (deSilva) : 12/2/2007 6:03:10 PM GMT