[comp.sys.amiga.tech] Speeding up fractals in assembly

berenfie@tortoise.cis.ohio-state.edu (gregory neil berenfield) (12/20/90)

I am currently trying to teach myself assembly language on the amiga and
as a project, I thought I'd write a mandlebrot program in assembly that I
originally wrote in C. I can open libraries, screens, windows etc. well
and can generate a nice looking mandlebrot but what I'm after is SPEED!

Firstly, my system is an A3000 68030/68882 25Mhz. I have a shareware copy
of MandFXP by Cybersoft I believe, and that sucker can really splat
mandelbrots in under 2 seconds! Mine is not nearly as fast. My technique is
straightforward. For actual drawing, I open a custom screen & window and
use a pointer to the rastport for drawing in. I use the _WritePixel &
_SetAPen library calls to do the actual drawing. For testing a point to see
if it is in the mandelbrot set, I use the 68882 fmove,fmul,fdiv calls to 
calculate in single floating point accuracy, the coordinate on the complex
plane and use z->z^2+c calculations accordingly. The mandelbrot is drawn
fairly quickly but not nearly as fast as MandFXP and I want to squeeze 
maximum speed out of this sucker. Does anyone know of a way of storing
floating points as ints and doing some sort of bit shifting stuff to do 
fp arithmatic operations? Any help in optimizing this thing would be
of great help. Thanks.
                  Greg


-------------------------------------------------------------------------------

anonymous: Who am I?      |  O.S.U.  CIS
                          |  Columbus Ohio
-------------------------------------------------------------------------------

hugo@gem.stack.urc.tue.nl (Hugo Lyppens) (12/20/90)

berenfie@tortoise.cis.ohio-state.edu (gregory neil berenfield) writes:


>I am currently trying to teach myself assembly language on the amiga and
>as a project, I thought I'd write a mandlebrot program in assembly that I
>originally wrote in C. I can open libraries, screens, windows etc. well
>and can generate a nice looking mandlebrot but what I'm after is SPEED!

I'd suggest you read my article and program listing "Fast Fractals" in
the November 1989 issue of Amazing Amiga. It covers a fractal program
that is based on integer arithmetic. It works fast on the 68000
and it should be a real screamer on your configuration !

I hope this is a source of ideas.

Hugo Lyppens
hugo@gem.stack.urc.tue.nl

dac@prolix.ccadfa.oz.au (Andrew Clayton) (12/21/90)

In article <86849@tut.cis.ohio-state.edu>, gregory neil berenfield writes:

> and can generate a nice looking mandlebrot but what I'm after is SPEED!

Elusive as it may be! Even with my GVP 3001, at 30Mhz, things
aren't quick enough for me.

> Firstly, my system is an A3000 68030/68882 25Mhz. I have a shareware copy
> of MandFXP by Cybersoft I believe, and that sucker can really splat
> mandelbrots in under 2 seconds! 

CygnusSoft. The guys who wrote Cygnus Ed Professional, Release 2,
which I'm using right NOW, and it's G_R_E_A_T (Marketted by ASDG
Inc.) After using a public access UNIX machine to _attempt_ to
get onto USEnet, and having to use Vi, I cannot adequately explain
the enjoyment value that I get out of using CED compared to being
relegated to Vi!

(Go on, Usenetters, call me a heathen! :-)

I used MandelFXP to generate an 'AmigaMovie' of a Mandelbrot - on
a REALLY SMALL 1" square of the screen, down to 1/128,000,000th
of the screen (I was using 5 words of precision at that time!).
It looked sorta neat, but at more than 4 frames a second, it was
just visual noise, if you get my drift.

I wrote to ASDG, asking for more information (like, will they
ever get around to MandelMovie) but got zippo response.
Cygnussoft aren't contactable by phone. :-(

> Mine is not nearly as fast. 

Check out a program called MandelBz, by Nico Francois, the guy
who wrote PowerPacker. It's pretty quick, and uses a SECAM way
(Something Essentially Contrary to the American Method :^) of
doing Mandelbrots, by doing the edges first, and then area fills.
Pretty quick, and produces some VERY nice pictures. Best of all,
it uses PAL, whereas MandelFXP uses Never Twice Same Colour, and
the ugly 200 line screen.

Good luck with your project: I think Mandelbrot generators have
been done to death though.

> anonymous: Who am I?      |  O.S.U.  CIS

Fair enough.

Dac
   _l _  _  Andrew Clayton.      I post .       ccadfa.cc.adfa.oz.au!Uprolix!dac
  (_](_l(_  Canberra. Australia.       . . I am.

Note: I cannot send or recieve MAIL to sites outside of Australia. Sorry.

muenx@heike.informatik.uni-dortmund.de (Holger Muenx) (12/22/90)

In article <86849@tut.cis.ohio-state.edu>, berenfie@tortoise.cis.ohio-state.edu (gregory neil berenfield) writes:
|> Firstly, my system is an A3000 68030/68882 25Mhz. I have a shareware copy
|> of MandFXP by Cybersoft I believe, and that sucker can really splat
|> mandelbrots in under 2 seconds! Mine is not nearly as fast. My technique is
|> straightforward. For actual drawing, I open a custom screen & window and
[...]

Hi!

This is not concerning the technical details of treating floating point values
in Assembler but rather about two techniques to optimize Mandelbrot set
calculations you might want to use.

The first is very simple. Instead of calculating each point (including the
"black" areas too) you first look only at the frame of your picture. The
Mandelbrot set is connected; so if all the points on the frame are of the
same colour you need not to calculate the interior anymore, it is of the
colour of the frame. If the frame is not of one colour you can divide
your picture into four sub-pictures. On each picture the same procedure
as above is applied so that you result in a recursive process to calculate
the mandelbrot set. I wrote some time ago a program which uses this method
and can submit it if you are interested. (Unfortunately, it is written in
C and not in Assembler.)

Another faster method was posted some months ago in alt.fractals. I do not
remember the exact name and the algorithm but I can look for it at home. The
idea of this was that you follow the border of a colour without calculating
the interior. It can easily be filled with this colour.

I would be interested in MandFXP von Cybersoft (if it is really shareware,
I think it is commercial, but I can be mistaken). Where did you get it?
Is it available via ftp somewhere?

                                                       -Holger

===========================================================================
|| Holger Muenx, IRB, Universitaet Dortmund, 4600 Dortmund, West-Germany ||
||          Internet: muenx@heike.informatik.uni-dortmund.de             ||
===========================================================================

lphillips@lpami.wimsey.bc.ca (Larry Phillips) (12/22/90)

In <2888@laura.UUCP>, muenx@heike.informatik.uni-dortmund.de (Holger Muenx) writes:
>
>I would be interested in MandFXP von Cybersoft (if it is really shareware,
>I think it is commercial, but I can be mistaken). Where did you get it?
>Is it available via ftp somewhere?

MandFXP is from Cygnus Software, and was shareware.  Source was released about
a year or so ago, and I believe the shareware fee was waived at that time.

-larry

--
The best way to accelerate an MsDos machine is at 32 ft/sec/sec.
+-----------------------------------------------------------------------+ 
|   //   Larry Phillips                                                 |
| \X/    lphillips@lpami.wimsey.bc.ca -or- uunet!van-bc!lpami!lphillips |
|        COMPUSERVE: 76703,4322  -or-  76703.4322@compuserve.com        |
+-----------------------------------------------------------------------+

a447@mindlink.UUCP (Colin Fox) (12/22/90)

I know a bit about MandFXP (been told by one of the authors, Bruce Dawson).
First off, they draw into a separate buffer and then use DrawImage() to blit
the image to the screen. Much faster than using WritePixel(). Next, they spent
WEEKS on tiny loops to squeeze every cycle out of it. This is where they became
68000 experts. :)

And it's also fixed point, not floating point. I don't know if a floating point
processor (at roughly equivalent speeds) can duplicate that of a CPU doing
fixed point.

Also, apparently they do their math to 300 bits. (not decimal places). So it
sounds fairly accurate.

All in all, you've got your hands full with that speed demon. :)

   --- Colin ---

toucan@phoenix.pub.uu.oz.au (Matt Alderson) (12/23/90)

With regard to speeding up the mandlebrot thingies..
 
I have been in the same boat as you.

I found a HUUUGE increase when I decided to jump awaay from using libraries and do all the tedious work my self.. (eg. Using the Copper to open my screen , etc/... The biggest increase was acheived by instead of using Draw(x,y) library commands but rather access the actually bplane pointer and filling from there..

I'll try to dig up my source (it's been at least 2 years now.) and see if I can help more...