News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

a mathematical demo

Started by litwr, 19:31, 24 December 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

litwr

It fast calculates π number with up to 3000 exact digits. It calculates 100 digits during 4.2 seconds.  The fastest known division and multiplication routines are used. Just RUN"PI
To restart demo type RUN.
See libnew:examples:pi [z88dk] for details on algorithm.
This demo is released for the several other platforms too.  For example, Commodore 64 with blank screen makes 100 digits for 5.8 seconds.
BTW A merry Xmas to all!  ;)

litwr

I've just add several improvements.  The ultrafast division was used.  I am going to publish its algorithm soon.  The results are surprising.  Look at the timings for 800 digits calculation.

  • Commodore 64/PAL (screen off) - 232.9 sec
  • Commodore 128/PAL (fast mode) - 123.6 sec
  • Amstrad CPC6128 - 120.1 sec
Amstrad is slightly slower than C128 for 100 digits because its text output is slower.   However for the bigger numbers it is faster.
If somebody wants to check Commodore version of this program then use the link - a mathematical demo - Commodore 64 (C64) Forum.

Executioner

Quote from: litwr on 20:31, 05 January 16
The results are surprising.

Not that surprising. Everyone always harps on about how much faster a 6502 is than a Z80, but in reality a Z80 at 4MHz is the same speed or faster for simple instructions as a 6502 at 1MHz, and the 6502 lacks a lot of the functionality of the Z80, including 16 bit maths.

MacDeath

#3
can some arithMathic co-processor for Z80 be added on a CPC ? do they even exist for Z80 ?

yeah 4mhz Z80 is supposed to be better at Math than 1mhz 6502... but less good on basic instructions to other components... from what I was told, is this even true ?



incredible, the BBC computer wins the benchmark on BBC channel.
;D


TotO

Sure, you can interface an AMD FPU (AM9511/12) with the Z80 by using I/O (slow) or DMA.
But... I'm not really sure that will be interresting today.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

andycadley

Quote from: MacDeath on 22:19, 06 January 16
incredible, the BBC computer wins the benchmark on BBC channel.
Haha, I love how completely arbitrary the scoring in that is. The BBC does have a very good BASIC implementation though and it's 2MHz 6502 is certainly no slouch. Can't say I'm surprised the QL lost though, I'm amazed that had one that actually worked! During the unboxing bit, I was sure they were going to mention a box you had to plug permanently onto the expansion port to actually get the machine to run, I guess it must've been a slightly later revision.

HAL6128

Quote from: TotO on 22:46, 06 January 16
Sure, you can interface an AMD FPU (AM9511/12) with the Z80 by using I/O (slow) or DMA.
But... I'm not really sure that will be interresting today.
Isn't it possible to use the MiniBooster / CPC Booster as some kind of Co-Processor with the help of its additional AMTEL /  AVR Risc Processor?
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

TotO

Sure. But, in a same way, using i/o ports should make the fast computing result slow down by the data exchanges.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

alex76gr

#8
Thank you so much for this.
Maybe your program will become the standard cross-platform benchmark that will end the dispute of which CPU is faster.
I still believe that i got my myopia from the green GT-65 monitor, but i can't prove it! :)

HAL6128

Quote from: TotO on 07:47, 07 January 16
Sure. But, in a same way, using i/o ports should make the fast computing result slow down by the data exchanges.
Then it only make sense to use the Booster for a huge set of calculation at once when no data exchange takes place and the end result will be exchange. Just for curiosity. The old CPCBooster+ has a small RAM space available for own code. Is it the same with the MiniBooster?
Would it be possible to use the "PI calculating program" above, let the MiniBooster calculate and transfer the result (only the figures) to the CPC?
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

TFM

You can use AVRstudio to add functionality to the Booster.  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

TotO

It is the same ATMega. So, the same RAM but the usage and functions are not exactly the same.
By the way, if you only need to return PI, it should be better to store it into your code and not compute it. :)
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Bryce

The BBC uses a Z80 as its second processor, so I think we should use a 6502 as the CPCs second processor :)

Bryce.

TFM

Quote from: Bryce on 21:22, 07 January 16
The BBC uses a Z80 as its second processor, so I think we should use a 6502 as the CPCs second processor :)

Bryce.


Yes for 1541 support!  ;D
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Bryce

Quote from: TFM on 21:23, 07 January 16

Yes for 1541 support!  ;D

The 1541 is C64 = 6510 CPU and already has its own CPU inside too.

Bryce.

litwr

#15
It is common to consider 6502:z80 speed ratio as 2.2-2.4:1.  So C128 with ≈1.8 MHz should be close to 3.96-4.32 MHz z80 without wait states.  Amstrad CPC6128 CPU effective frequency is close to 3.2 MHz.  This arithmetic caused my surprise.  However it is also well known that in some important cases the mentioned speed ratio is about 1.5:1.  The most known case of z80 advantage is the memory copy.  The π-demo shows that z80 division is also an example of the high z80 efficiency, the division gives ratio 1.8:1.  IMHO it is possible to write z80 programs with 2:1 ratio but it is very difficult.

I made several improvements to the codes and gather results for 800 digits calculation.

Commodore 64 (PAL) - 212.2
Commodore 64 (NTSC) - 204.3
Commodore 128 (PAL) - 112.6
Amstrad CPC6128 - 115.5
IBM PC 8150 (1981) - 49.5

IBM PC uses Intel 8088 at 4.77 MHz.  This CPU has hardware division and multiplication.  However the version for IBM PC is not so well optimized as versions for z80 or 6502.

I gave number 1 to the current version at http://litwr2.atspace.eu/cpc.html
The program for IBM PC is at http://litwr2.atspace.eu/ibm-5150/ibm-5150.html

BBC Micro is possibly the fastest 8-bit computer before 1987. The only rival maybe Commodore +4 (PAL).

TFM

Quote from: Bryce on 21:52, 07 January 16
The 1541 is C64 = 6510 CPU and already has its own CPU inside too.

Bryce.


See, you can save all that and just use the mechanics and minor components (RAM is not so much expansive any longer anyway  ;) ).
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

TFM

Quote from: litwr on 07:15, 08 January 16
Commodore 64 (PAL) - 212.2
Commodore 64 (NTSC) - 204.3
Commodore 128 (PAL) - 112.6
Amstrad CPC6128 - 115.5
IBM PC 8150 (1981) - 49.5

BBC Micro is possibly the fastest 8-bit computer before 1987. The only rival maybe Commodore +4 (PAL).


Would be great if somebody can to the test for them too. But that the pc is twice as fast as the CPC is imho very unexpected, I would have guessed maybe 20%. Also it would be interesting to see if in other cased the Z80 would do better compared to that 8088.


Thanks for doing all the work! Very interesting!  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

TotO

The 8088 CPU is not a real 8bit CPU... It is a 8086 core stripped into a 8bit package. (like the 68008 VS 68000)
So, I'm not surprised it was fastest by using hardware improved APU.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

litwr

Quote from: TFM on 18:49, 08 January 16
Would be great if somebody can to the test for them too. But that the pc is twice as fast as the CPC is imho very unexpected, I would have guessed maybe 20%. Also it would be interesting to see if in other cased the Z80 would do better compared to that 8088.
Thanks for doing all the work! Very interesting!  :)
Thank you very much.  :) I optimized version for 8088 too. So the latest results for IBM PC 5150 are 26.3 seconds for 800 digits.  I also made a version for RT-11 for the big family of PDP-11 computers...
I am completely unfamiliar with BBC Micro architecture.  :( It should be very easy to move the demo to any 6502, z80, ... platform but I need some help.  For example, how to get the timer data?


ZbyniuR

Did you see this?    Search for prime numbers in Basic, here compare CPC and C64:

https://www.youtube.com/watch?v=pxye-RbKFpY

My friends from speccy.pl made more tests:

BBC Master        - 0'25 - here is little bit optimised but I suppose it safe maximum 2 sec.
Amiga Basic   - 0'30
BBC Micro       - 0'47
BBC Electron    - 1'04
Sam Coupe         - 1'14
CPC 6128 (80)    - 1'19  - little bit faster ;)
CPC 464 (40)    - 1'22  -
C128 (80)    - 1'23  - 80 column mode made switch to 2MHz
C64           - 2'15
C+4           - 2'16
C128 (40)       - 2'48
C128 CP/M      - 3'28  - Microsoft Basic
Atari XL/XE    - 3'50 - faster processor than C64 but slower interpreter
MSX1           - 3'53
ZX 48           - 4'08 - terrible slowly :(
ZX 128         - 4'50
TI99/4A       - 5'58 
ZX81         - 13'12
In STARS, TREK is better than WARS.

AMSDOS

Quote from: ZbyniuR on 21:06, 09 January 16
Did you see this?    Search for prime numbers in Basic, here compare CPC and C64:

https://www.youtube.com/watch?v=pxye-RbKFpY

My friends from speccy.pl made more tests:

BBC Master        - 0'25 - here is little bit optimised but I suppose it safe maximum 2 sec.
Amiga Basic   - 0'30
BBC Micro       - 0'47
BBC Electron    - 1'04
Sam Coupe         - 1'14
CPC 6128 (80)    - 1'19  - little bit faster ;)
CPC 464 (40)    - 1'22  -
C128 (80)    - 1'23  - 80 column mode made switch to 2MHz
C64           - 2'15
C+4           - 2'16
C128 (40)       - 2'48
C128 CP/M      - 3'28  - Microsoft Basic
Atari XL/XE    - 3'50 - faster processor than C64 but slower interpreter
MSX1           - 3'53
ZX 48           - 4'08 - terrible slowly :(
ZX 128         - 4'50
TI99/4A       - 5'58 
ZX81         - 13'12


I haven't tried it, though the BASIC Prime Number on this early ACU page takes 90 seconds (BASIC 1.0), the Hisoft Pascal counterpart takes 2.5 seconds.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

TMR

Quote from: ZbyniuR on 21:06, 09 January 16CPC 6128 (80)    - 1'19  - little bit faster ;)
CPC 464 (40)    - 1'22

i'm assuming that at least some of this difference is down to the PRINT command being faster when it's dealing with one bit per pixel...?

Quote from: ZbyniuR on 21:06, 09 January 16
C64           - 2'15
C+4           - 2'16
C128 (40)       - 2'48

Those numbers really are a surprise; the C128 without fast mode is clocked at the same speed as the C64 give or take (the speed with it enabled should be a bit faster than the 80 column mode because of the bottleneck, but the screen is off) and the 264 series are faster overall, so the meatier versions of Commodore BASIC must be a drag on resources!

Quote from: ZbyniuR on 21:06, 09 January 16ZX81         - 13'12

Ouch...! Have you perchance got a link to the original forum post where these numbers come from ZbyniuR?

andycadley

Quote from: TMR on 12:19, 10 January 16
Ouch...! Have you perchance got a link to the original forum post where these numbers come from ZbyniuR?

I'd bet that's in SLOW mode, where the Z80 is spending most of it's time doing the display output. In FAST mode (with the screen off) it'd probably be closer to the Spectrum as the ROM routines are very similar.

ZbyniuR

#24
I took this numbers from Polish forum about compare many platforms.
Speccy.pl - compare Basic's
After I put there the same link, some colectors made test on others computers. :)

AMSDOS@ - Aim of this program is to compare speed of BASIC in those computers. So have to be the same on each platform.
But method of the ACU is realy much faster.
Program from film after optimizing is need less than 53 sec to find prime numbers from 2 to 997, and method of ACU after a small amendments does it in 15.6 sec.
In STARS, TREK is better than WARS.

Powered by SMFPacks Menu Editor Mod