Login
Back to forumReply to this topicGo to last reply

Posted By

MIRKOSOFT
on 2016-08-17
12:20:16
 Mandelbrot and Commodore computers

Hi!

Robert Willie (aka Hydrophilic) created Basic Mandelbrot program for VDC and Basic 7.80.
I modified it to use for VIC-IIe, VIC-II, TED, - so also Commodore VIC screen, Commodore 64, Commodore Plus/4 (and 16 or 116).
It was tested and compared. For C64 is used Basic 3.5.
I could test only Commodore 128 (both VDC and VIC-IIe) with or without SuperCPU, C64 mode and only emulator of Plus/4.
So, I created blog at http://cbmandelbrot.blogspot.sk/

If you want to help testing, look at and reply to comments.
Miro

Posted By

Csabo
on 2016-08-17
14:29:30
 Re: Mandelbrot and Commodore computers

"really VICE emulator only, YAPE tried but failed at drawing." o_O

Posted By

gerliczer
on 2016-08-18
01:18:47
 Re: Mandelbrot and Commodore computers

BS. Yesterday evening I tried and it worked fine. Although, I didn't have enough patience to wait until the end. I turned it off after 2/3rd of the screen was filled. It took considerable time even with running close to 900% speed.

Posted By

MMS
on 2016-08-22
15:03:31
 Re: Mandelbrot and Commodore computers

I made some tests, though due to other activities I could not wait the several hours long full results.
(ouch, on an Amiga a complex raytrace HAM image rendered in 10-12 hours).

Summary: Austrospeed Compliler can double the speed of the already well optimized program

Actually the fractals and Mandelbrot/Julia,etc are very close to my heart, as my thesis in 1996 was made from this topic and wrote one of the very first Mandelbrot generators on PC with SVGA 256 color with fully mouse controllable GUI (can select new area with mouse, plus different color palettes for iterations, palette animation,+JMJ MOD music in the background, selectable fractals. happy )

But due to the fact that Plussy had no such processing power, I made no trials to convert my Pascal PRG, though sprite (mouse) emulation and SID music playback is not a miracle any more happy

So, back to the topic:
I made a short test, how we may speed up the mandelbrot generator on Plus/4.
As we have no SuperCPU, I tested other speed up methods we discussed in the past, and the impact of BASIC Compilers.

As I have limited time, I just measured the very first 5 lines to be drawn.
I know very well, than the later areas are much more calcuation intensive, but hey, I have some life too grin

Results to calculate and draw the first 5 lines:

original Mandelbrot V3.5 PRG 00:04:45 (4 minutes 45 seconds)

optimized Mandelbrot 00:04:44 (almost no impact)
(integers (%) used in FOR loops, variables used for comparisons io fix values)
(I made a mistake too: Renumbered it with 10, so the GOTO uses higher numbers in my version, make it slower a little)

AustroSpeed compiled orig.V3.5 00:02:20 (double speed, well visible improvement)

Austrospeed compiled optimized 00:02:16 (integers in FORs seems have some, but small impact)

AustroCONV tool from SVS: unfortunately it generated a PRG with incorrect SYS value, compiled and cracked PRG could not start, the value in the SYS command was just too high. Looks like: 1 SYS13056*256+39 AUSTROSPEED 1G GR

Plus-Comp compiler: Failed: PRG compiled and started but draw nothing on screen.

So, still only AustroSpeed could generate a useful output.
As far as I know, the other compilers do not support Plus/4 specific commands, just a 1-to-1 conversion from C64, supports only V2.0 commands.
So the Mandelbrot V3.5 cannot be compiled with other compilers.

Posted By

SVS
on 2016-08-24
07:11:20
 Re: Mandelbrot and Commodore computers

@MMS: the reason because AustroConv fails is that it can correctly work only for compiled files shorter than $7F00. If your C/prg is longer than the codes of the wedge prepared at $0303 are wrong (sorry).

All this can be bypassed if you use the MikeZ version of AustroSpeed, named Austrosimple.

Posted By

MIRKOSOFT
on 2016-08-24
19:38:14
 Re: Mandelbrot and Commodore computers

New two tests: C128 VIC @ 2MHz and Mega 65 in C64 mode @1MHz
http://cbmandelbrot.blogspot.sk/

Miro

Posted By

MMS
on 2016-08-24
21:36:03
 Re: Mandelbrot and Commodore computers

SVS! thanks for the info. But the code is pretty short. Maybe the database it creates too big?

Posted By

MIRKOSOFT
on 2016-08-25
05:16:50
 Re: Mandelbrot and Commodore computers

Mega 65 in C64 mode at 48MHz was tested: http://cbmandelbrot.blogspot.sk/
Miro

Posted By

Litwr
on 2016-09-12
07:17:19
 Re: Mandelbrot and Commodore computers

A bit off topic information.
I have the reference to another graphical benchmark in Basic, it draws a Fibonacci sunflower. It draws it very slowly.
http://www.lemon64.com/forum/viewtopic.php?t=61877&start=0&postdays=0&postorder=asc

Posted By

Csabo
on 2016-09-12
09:58:30
 Re: Mandelbrot and Commodore computers

Pretty cool! Added to database: Fibonacci Sunflower.

I played around with it a bit, cause I thought drawing the circles from line segments is a bit inefficient. If you replace the inside of the "I" loop with this (delete 1070-1085):

X=(320+R*COS(DE))/4:Y=(200+R*SIN(DE))/2:CIRCLE3,X,Y,CI/4,,,,,45:PAINT2,X,Y,1

It runs about 20 times faster, and draws a very similar end result.

Posted By

Litwr
on 2016-09-12
12:09:19
 Re: Mandelbrot and Commodore computers

Thanks! I should inform Amstrad guys about your faster method. wink

Posted By

Csabo
on 2016-09-12
18:06:35
 Re: Mandelbrot and Commodore computers

I saw on the original forum that the reason they choose to draw the circle from line segments because that IS the faster method (on their machine anyway). For us, using CIRCLE is way easier and faster, especially thanks to the 9th parameter.

Posted By

Litwr
on 2016-10-05
02:02:30
 Re: Mandelbrot and Commodore computers

Amstrad Basic is fast but misses some useful commands like CIRCLE. I'd missed this fact and didn't use CIRCLE. Thanks to Csabo C+4 showed its power again! happy
EDIT. I've just made a conversion for Amstrad CPC. It makes the picture for 5:27:13... The details are at this thread. Note the link to one line program - here.

Posted By

MIRKOSOFT
on 2016-10-21
07:31:39
 Re: Mandelbrot and Commodore computers

New tests and used your linked program... look at:
http://cbmandelbrot.blogspot.sk/

Miro

Posted By

Litwr
on 2016-10-30
04:57:24
 Re: Mandelbrot and Commodore computers

I have converted the program to BBC Basic. The results are at http://www.stardot.org.uk/forums/viewtopic.php?f=2&t=12028#p152834
BTW I could run the program with plus4emu at 700% speed at the background and got the true result. It is above 10 hours.

Posted By

MMS
on 2016-10-30
16:49:33
 Re: Mandelbrot and Commodore computers

Hi! Thanks for converting and sharing the results.

There was a lot of dispute about the Plus/4 "theoretical" speed, PI calculation was a nice example, but I was asked on the Ha'wangadra festival viewers, how much it represents the full machine's capabilities.

Certainly, if next to the CPU the GFX is tested, there are more factors, than the CPU itself.
So here in the Mandelbrot (despite it is depends heavily on CPU power), it uses the GFX abilities of the machine.
as I see, in case of Commodre, it is attribute mode,

I see, that BBC Micro B and CPC6128 are both SIGNIFICANTLY faster than Plus/4. At least 2x
Why?
Does the Plus/4 GFX or TED is so much more complicated (slow)?
Or the BASIC3.5 DRAW command is so much slower than the PLOT? (because on C+4 it can draw lines and points too, to th routine is more complicerd and slow).

What if a fast point drawing routine would be used? As your one, was able to draw 5250 pixel/second? would be the same results? Or Plus/4 would become the fastest again? So maybe a slow BASIC DRAW routine+ ATTRIBUTE kills our machines's dominance? grin

Posted By

Litwr
on 2016-11-01
15:07:15
 Re: Mandelbrot and Commodore computers

I wanted to get the true sport results. BBC Micro and Amstrad CPC have no screen off speedup. So C+4 works with screen on at 1.1 MHz. Commodore Basic 3.5/7 has good commands but it is much slower (50-100%) than Amstrad CPC or BBC Micro Basics. This makes the results. If we run Plus4 with screen off then it makes it about 60% faster. If we add "secret" NTSC boost then we get about 90% less time. However with slow Commodore Basic even this boost doesn't allow to catch up Amstrad CPC. Plus4 is the fastest with disabled screen only. BTW a BBC Micro enthusiast has just made a ML interactive Mandelbrot builder. It draws a screen in about 2 minutes. The next screens (zoom in) are drawn slower.

Posted By

MMS
on 2016-11-01
17:50:35
 Re: Mandelbrot and Commodore computers

OK, I get the point, also the continuous RAM/ROM switching does not help too much for +4 (C128 too?)

2minutes for a Mandelbrot screen is not a bad result at all from an 8bit computer!
But time greatly depends on the number of iterations (depth) set.

Could be interesting to see the # of iterations it uses to reach it.

Posted By

Litwr
on 2016-11-10
00:41:54
 Re: Mandelbrot and Commodore computers

There are commented sources at stardot.org.uk
BBC Micro users have a new life for their old machines by the new accelerators, they can use 6502 at up to 225 MHz! IMHO it is faster than first Pentiums.
EDIT. I've just made a video. :)

Posted By

Mad
on 2016-11-10
18:46:41
 Re: Mandelbrot and Commodore computers

Cool! Must look into the sources, this edgetracing approach for fractals is somehow awesome! (Some Mandelbrot zoomers in PC Demos where most probably coded with it).

The main point seems to be this:
; This method scans the 8 neighbouring pixels around the one at (x,y).
; If any are found with a different colour to this one, they are added to the stack to be processed later.

So you get only the outlines. Most probably you just need to go from top to bottom through every column and fill the holes with the right colors.
Perhaps this is just do able in basic, too. Dunno..

Ah and the floodfill:

; Flood fill remaining areas.
; Because we know that filled regions are bounded completely by their colour,
; we can just scan downwards, duplicating the byte above into the byte below, masking out
; any bits which are already written in the byte below.

Didn't understood every detail. But it seems that the trick is just testing the 8 neighbors for a different color to determine the next pixels to process.

Or did the basic programs already do this stuff?

Posted By

MMS
on 2016-12-13
17:04:09
 Re: Mandelbrot and Commodore computers

Surely no.
It goes line by line, pixel by pixel, and calculation that specific pixel's color (depth) as my ancient code from the 90s.
Probably that code may increase the speed by 40-60%, but will not be seconds, or minutes, still. grin

UPDATE: It seems I did not read the other comments before my post. So with edge-tracing it is possible, with oldschool code not possible to reach that speed.

Posted By

RichTW
on 2016-11-23
14:12:04
 Re: Mandelbrot and Commodore computers

Hi!

I'm the author of the BBC Micro Mandelbrot. Thanks for the kind remarks! Yeah, the speed comes from a couple of things:

- boundary tracing: it maintains a queue of pixels to evaluate, and starts by adding all the pixels on the screen edge. Then for every item in the queue, it evaluates it and its eight neighbours, and if any neighbour is a different colour, it gets added to the queue itself so its neighbours can also be processed. Obviously the screen itself acts as a cache to save evaluating a pixel which has already been drawn. This saves evaluating the insides of big areas, most notably areas "inside" the Mandelbrot set which would take the most iterations to evaluate.

- fast multiply using the difference of two squares method (and the additional optimization of holding a (n-255)^2/4 table). This reduces the multiplication to a simple 16 bit subtract. The values are actually 32 bit, using 29 bit fixed point - the result comes by summing combinations of partial products and performing a final shift to reposition the fixed decimal point. This leads to a further optimization when squaring a value, since some of the partial products are shared. From a rough estimate, I reckoned the 32bit*32bit multiply completes in around 800 cycles, as opposed to the "naive" multiply which would take between 2200 and 3200 cycles, depending on the number of set bits in the multiplicand.

The code currently performs 32 iterations, but this isn't enough when the zoom gets higher - it should really increase the iteration count the higher you zoom. It should also ideally use more fixed fractional bits to allow for greater precision at high zoom. Currently it refuses to let you zoom beyond five steps as the image starts to go wonky.

Posted By

Litwr
on 2016-12-13
10:38:31
 Re: Mandelbrot and Commodore computers

Mandelbrot in 30 seconds - http://www.octoate.de/wp/?s=mavdelbrot



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024