Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-12

Improving i8086 performance..

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Max Nazhalov

Hello, Everybody!

Can anyone having the real i8086 hardware check attached MUL-helpers? I've tested them on a modern Intel CPU -- "mul_dword" is about 4.5..5 times faster comparing to the generic FPC implementation, and "mul_qword" is about 18..20, but these numbers surely should be quite different for the real i8086 due to the progress in the today's ALU design. Just curious how "fast" they can be in the silicon of those days..

---
WBR,
Max

Reply by email

Jim Leonard
to Max Nazhalov
Max Nazhalov wrote 8 lines
Hello, Everybody! Can anyone having the real i8086 hardware check attached MUL-helpers? I've tested them on a modern Intel CPU -- "mul_dword" is about 4.5..5 times faster comparing to the generic FPC implementation, and "mul_qword" is about 18..20, but these numbers surely should be quite different for the real i8086 due to the progress in the today's ALU design. Just curious how "fast" they can be in the silicon of those days..

I'm not sure how useful a comparison this is because there is no dword or qword MUL on i8086. Also, your request is not clear: Do you want them checked for correctness, or speed?

Do you need a real 8086 or will an 8088 do? I have both, but the 8088 is set up right now whereas I'd need to drag out the 8086 and set it up. But in either case, I won't write your test harness for you; if you provide me with a compiled harness .exe then I'd be happy to run it for you and send you the results back.

If you don't know how to write a harness with decent timing code, just print the system time, do 1000 iterations, then print system time again. 808x is slow enough that 1000 iterations will be enough to get good numbers.

Jim Leonard () Check out some trippy MindCandy: http://www.mindcandydvd.com/ A child borne of the home computer wars: http://trixter.oldskool.org/ You're all insane and trying to steal my magic bag!

Reply by email

Kostas Michalopoulos
to Jim Leonard

If you want to do speed tests, try some emulator. For example PicoXT (which emulates an XT clone):
http://www.picofactory.com/free/software/pc-xt-emulator/

Jim Leonard wrote 34 lines
On 12/23/2013 7:34 AM, Max Nazhalov wrote: > > Hello, Everybody! > > Can anyone having the real i8086 hardware check attached MUL-helpers? > I've tested them on a modern Intel CPU -- "mul_dword" is about 4.5..5 > times faster comparing to the generic FPC implementation, and > "mul_qword" is about 18..20, but these numbers surely should be quite > different for the real i8086 due to the progress in the today's ALU > design. > Just curious how "fast" they can be in the silicon of those days.. I'm not sure how useful a comparison this is because there is no dword or qword MUL on i8086. Also, your request is not clear: Do you want them checked for correctness, or speed? Do you need a real 8086 or will an 8088 do? I have both, but the 8088 is set up right now whereas I'd need to drag out the 8086 and set it up. But in either case, I won't write your test harness for you; if you provide me with a compiled harness .exe then I'd be happy to run it for you and send you the results back. If you don't know how to write a harness with decent timing code, just print the system time, do 1000 iterations, then print system time again. 808x is slow enough that 1000 iterations will be enough to get good numbers. -- Jim Leonard () Check out some trippy MindCandy: http://www.mindcandydvd.com/ A child borne of the home computer wars: http://trixter.oldskool.org/ You're all insane and trying to steal my magic bag! _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Jim Leonard
to Kostas Michalopoulos
Kostas Michalopoulos wrote
If you want to do speed tests, try some emulator. For example PicoXT (which emulates an XT clone): http://www.picofactory.com/free/software/pc-xt-emulator/

That emulator is not cycle-exact, so it doesn't have the same characteristics as the real hardware. PCem comes closer, but is also not exact.

Because MUL/IMUL/DIV/IDIV on 808x has variable execution times based on the inputs, it is best for the OP to test on real hardware if he wants an accurate comparison.

Jim Leonard () Check out some trippy MindCandy: http://www.mindcandydvd.com/ A child borne of the home computer wars: http://trixter.oldskool.org/ You're all insane and trying to steal my magic bag!

Reply by email

Nikolay Nikolov
to Max Nazhalov: Hello, Everybody! Can anyone having the real i8086 hardware check attached MUL-helpers?…
Max Nazhalov wrote 8 lines
Hello, Everybody! Can anyone having the real i8086 hardware check attached MUL-helpers? I've tested them on a modern Intel CPU -- "mul_dword" is about 4.5..5 times faster comparing to the generic FPC implementation, and "mul_qword" is about 18..20, but these numbers surely should be quite different for the real i8086 due to the progress in the today's ALU design. Just curious how "fast" they can be in the silicon of those days..

I made a small benchmark:

http://debian.fmi.uni-sofia.bg/~nickysn/fpc-8086/mul-benchmark/

The generic pascal version is compiled with -O2 for 8086/8088 (so, it doesn't use any 186+ instructions).

I ran it on my HP 200LX, which has a 7.91 MHz Intel "Hornet" 80186 CPU. Here are the results:

32-bit multiplication, N=10 (40960 multiplications)

mul32pas: 1902 ticks
mul32asm: 71 ticks

Or, in other words, 26.8 times faster. Not bad at all! :)

64-bit multiplication, N=10 (20480 multiplications)

mul64pas: 2704 ticks
mul64asm: 77 ticks

So the 64-bit multiplication got 35.1 times faster!

However, due to holidays, I'm not at home, where I have an IBM 5150 with an 8088 and a NEC V20 CPU (both CPUs are pin compatible, but the NEC is slightly faster at the same clockspeed, especially its mul and div instructions are faster, so it'd be interesting to test both). In about 2 weeks I'll be back home and I'll be able to test it on these CPUs. But it'd be nice if Jim could run the test on his 8088 machine, because we'll know the results sooner and because it'll save me from having to swap processors on the 5150, since it currently has the NEC installed.

Also, where I currently am, I have access to a 286 machine with a broken PSU, so in the next few days, I'm planning to replace the PSU and run the test on a 286 as well :)

As for correctness, I ran the fpc testsuite with no regressions and reviewed the asm code (and checked the math). It looks correct, but I still haven't reviewed the overflow checking part of the 64-bit multiplication routine. I'll commit the patch when I finish that.

Anyway, thanks for the patch, it looks great so far and the speed up seems to be even greater on old processors, compared to the modern ones.

Nikolay

Reply by email