Basic Mandelbrot render optimization

  • 20 Replies

0 Members and 1 Guest are viewing this topic.

Online hobold

  • *
  • Fractal Furball
  • ***
  • Posts: 287
« Reply #15 on: June 21, 2018, 11:01:43 AM »
If 128 bits of precision is sufficient, you might have better luck with a "double double" approach, where pairs of double precision floating point numbers are combined to obtain a larger mantissa (more generally, this idea is also called "normalized floating point"). Modern 'x86 processors can do fused multiply-add, therefore you can expect to lose less than a factor of ten performance as compared to native double precision.

Pros: can be inlined, relatively fast

Cons: no larger exponent range, only useful for mildly large precisions (128 - 256 bits)

Random reference:

Online claude

  • *
  • 3f
  • ******
  • Posts: 1455
« Reply #16 on: June 21, 2018, 12:15:02 PM »
Oh yes, I forgot about that approach!  it's also called "compensated arithmetic" in some circles. I wrote some Haskell bindings to libqd's C API once upon a time, but I think the 'compensated' package in pure Haskell is much better if you want to use that language.  IIRC libqd requires some setup/restore for floating point environment at program (thread?) startup/finish, at least on x86 (32bit).

Offline knighty

  • *
  • Fractal Feline
  • **
  • Posts: 195
« Reply #17 on: June 21, 2018, 04:14:04 PM »
Have anyone tried ISPC ?

Offline zenzero-2001

  • *
  • Fractal Freshman
  • *
  • Posts: 9
« Reply #18 on: July 04, 2018, 04:39:29 PM »
Lots of really interesting and good advice in this thread.

I use MPIR, MPFR, and MPREAL (an MPFR C++ wrapper,, as mentioned earlier in the thread) in my fractal explorer, Fractalscope, . MPIR is the Windows compatible version of GMP. In my experience, MPFR is slower than MPIR - probably because of its correct rounding etc.

Fractalscope uses MPREAL for calculating the required precision and precision mode (double or arbitrary) for a particular magnification level, but performs the actual Mandelbrot calculation using MPIR. The C++ operator overloading of MPREAL adds overhead to the calculation compared to the raw C calls of MPFR and MPIR and is therefore slower. Compiling MPIR specifically for your computer should help a bit with the arbitrary precision speed, but yeah using MPIR is like hitting a wall of jelly compared to double precision :-) The new perturbation technique is a huge leap in speed over conventional arbitrary precision, but the mathematics are beyond me!

Fractalscope uses SSE2 intrinsics for the Mandelbrot calculation at double precision (I never did get round to writing the SSE code for the other fractals). This enables four pixels to be calculated simultaneously without orbit detection and two pixels simultaneously with orbit detection. Things have moved on since I wrote that part of the code, new processors have more registers, AVX, etc, which I am not familiar with, so it may be possible to calculate more pixels simultaneously). Bruce Dawson's Fractal eXtreme has very fast arbitrary precision, but I believe that uses very clever and low level optimizations (and is closed source).

Orbit detection can give a very large speed up for areas that feature the inside of the set at high iteration counts, and is well worth including. Solid guessing can also help to speed up calculating  areas which feature the inside of the set. It is not very effective at speeding up the calculation outside of the set at high magnifications because the iteration bands become much narrower (or non-existent).

In addition to the instruction level optimizations of SSE, AVX, thread level optimization is also something to look at. Multi-threading gives a sizeable speed increase. The fact that processors nowadays  are increasing in cores rather than Mhz, means that mult-threading is a no-brainer - especially with something like calculating the Mandelbrot set which lends itself well to parallel computing.

Offline Adam Majewski

  • *
  • Fractal Furball
  • ***
  • Posts: 288
« Reply #19 on: July 04, 2018, 06:13:47 PM »
If 128 bits of precision is sufficient, you might have better luck with a "double double" approach,


Offline 3DickUlus

  • *
  • 3f
  • ******
  • Posts: 1656
    • Digilantism

The basic rules of the Mandelbrot-Set

Started by Fraktalist on Fractal Mathematics And New Theories

5 Replies
Last post October 12, 2017, 10:04:09 PM
by v
The Candy Vault - Using an Orbit Trap to render the Mandelbrot.

Started by saka on Fractal movie gallery

3 Replies
Last post March 22, 2018, 12:02:53 AM
by Spaciane
a basic Sym4 juliabulb

Started by mclarekin on Fragmentarium

2 Replies
Last post November 19, 2018, 11:11:32 AM
by Sabine62
basic algebra problem

Started by woodymnt on Noob's Corner

2 Replies
Last post March 30, 2020, 08:58:53 PM
by Adam Majewski
Knighty Menger Sponge basic setup for FragM

Started by mclarekin on Fragmentarium

2 Replies
Last post November 18, 2018, 11:27:00 AM
by timemit