Author Topic: a mathematical demo  (Read 15260 times)

0 Members and 1 Guest are viewing this topic.

Offline litwr

  • CPC664
  • ***
  • Posts: 149
  • Country: ru
    • lidovski's www page
  • Liked: 122
  • Likes Given: 126
a mathematical demo
« on: 20:31, 24 December 15 »
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!  ;)
« Last Edit: 20:33, 24 December 15 by litwr »

Offline litwr

  • CPC664
  • ***
  • Posts: 149
  • Country: ru
    • lidovski's www page
  • Liked: 122
  • Likes Given: 126
Re: a mathematical demo
« Reply #1 on: 21:31, 05 January 16 »
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.

Offline Executioner

  • Supporter
  • 6128 Plus
  • *
  • Posts: 783
  • Country: au
  • WinAPE Developer
    • WinAPE
  • Liked: 391
  • Likes Given: 60
Re: a mathematical demo
« Reply #2 on: 00:39, 06 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.

Offline MacDeath

  • Chaotic post writer and mock-up specialist
  • Supporter
  • 6128 Plus
  • *
  • Posts: 4.056
  • Country: fr
  • Liked: 1146
  • Likes Given: 641
Re: a mathematical demo
« Reply #3 on: 23:19, 06 January 16 »
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 ?


[youtube]https://www.youtube.com/watch?v=Zo7jnQXvtNo[/youtube]
incredible, the BBC computer wins the benchmark on BBC channel.
 ;D

« Last Edit: 08:01, 07 January 16 by MacDeath »

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 3.579
  • Country: fr
    • ?area=showdonations;u=4
  • Liked: 2705
  • Likes Given: 1606
Re: a mathematical demo
« Reply #4 on: 23: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.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 870
  • Liked: 410
  • Likes Given: 72
Re: a mathematical demo
« Reply #5 on: 00:06, 07 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.

Offline HAL 6128

  • 464 Plus
  • *****
  • Posts: 493
  • Country: de
    • index.php?action=treasury
  • Liked: 244
  • Likes Given: 1228
Re: a mathematical demo
« Reply #6 on: 00:34, 07 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

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 3.579
  • Country: fr
    • ?area=showdonations;u=4
  • Liked: 2705
  • Likes Given: 1606
Re: a mathematical demo
« Reply #7 on: 08: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.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline alex76gr

  • CPC664
  • ***
  • Posts: 143
  • Country: gr
  • Liked: 92
  • Likes Given: 40
Re: a mathematical demo
« Reply #8 on: 09:56, 07 January 16 »
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.
« Last Edit: 10:06, 07 January 16 by alex76gr »
I still believe that i got my myopia from the green GT-65 monitor, but i can't prove it! :)

Offline HAL 6128

  • 464 Plus
  • *****
  • Posts: 493
  • Country: de
    • index.php?action=treasury
  • Liked: 244
  • Likes Given: 1228
Re: a mathematical demo
« Reply #9 on: 11:59, 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

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1976
  • Likes Given: 4650
Re: a mathematical demo
« Reply #10 on: 18:34, 07 January 16 »
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

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 3.579
  • Country: fr
    • ?area=showdonations;u=4
  • Liked: 2705
  • Likes Given: 1606
Re: a mathematical demo
« Reply #11 on: 18:44, 07 January 16 »
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)

Online Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 11.263
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
  • Liked: 3955
  • Likes Given: 417
Re: a mathematical demo
« Reply #12 on: 22: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.

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1976
  • Likes Given: 4650
Re: a mathematical demo
« Reply #13 on: 22:23, 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

Online Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 11.263
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
  • Liked: 3955
  • Likes Given: 417
Re: a mathematical demo
« Reply #14 on: 22:52, 07 January 16 »

Yes for 1541 support!  ;D

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

Bryce.

Offline litwr

  • CPC664
  • ***
  • Posts: 149
  • Country: ru
    • lidovski's www page
  • Liked: 122
  • Likes Given: 126
Re: a mathematical demo
« Reply #15 on: 08:15, 08 January 16 »
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).
« Last Edit: 08:18, 08 January 16 by litwr »

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1976
  • Likes Given: 4650
Re: a mathematical demo
« Reply #16 on: 19:44, 08 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

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1976
  • Likes Given: 4650
Re: a mathematical demo
« Reply #17 on: 19:49, 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

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 3.579
  • Country: fr
    • ?area=showdonations;u=4
  • Liked: 2705
  • Likes Given: 1606
Re: a mathematical demo
« Reply #18 on: 20:48, 08 January 16 »
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)

Offline litwr

  • CPC664
  • ***
  • Posts: 149
  • Country: ru
    • lidovski's www page
  • Liked: 122
  • Likes Given: 126
Re: a mathematical demo
« Reply #19 on: 21:00, 09 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?


Offline ZbyniuR

  • 464 Plus
  • *****
  • Posts: 319
  • Country: pl
  • 6128 A1230 PSX Win7
    • Jedyne polskie forum o CPC. :)
  • Liked: 343
  • Likes Given: 146
Re: a mathematical demo
« Reply #20 on: 22: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
In STARS, TREK is better than WARS.

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.764
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1011
  • Likes Given: 1723
Re: a mathematical demo
« Reply #21 on: 01:54, 10 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

Offline TMR

  • CPC6128
  • ****
  • Posts: 195
  • Country: gb
  • Beeping the horn on the data bus
    • JasonKelk.me.uk
  • Liked: 127
  • Likes Given: 40
Re: a mathematical demo
« Reply #22 on: 13:19, 10 January 16 »
CPC 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...?

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!

ZX81         - 13'12

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

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 870
  • Liked: 410
  • Likes Given: 72
Re: a mathematical demo
« Reply #23 on: 16:35, 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.

Offline ZbyniuR

  • 464 Plus
  • *****
  • Posts: 319
  • Country: pl
  • 6128 A1230 PSX Win7
    • Jedyne polskie forum o CPC. :)
  • Liked: 343
  • Likes Given: 146
Re: a mathematical demo
« Reply #24 on: 23:02, 10 January 16 »
I took this numbers from Polish forum about compare many platforms.
Speccy.pl - compare Basic's
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.
« Last Edit: 23:21, 10 January 16 by ZbyniuR »
In STARS, TREK is better than WARS.