Christian Mayer's Weblog

Mandelbrot Again

2008 I created a Perl script that generates pictures with the Mandelbrot set. But Perl is not very fast executing high floating point operations. So I decided to convert this Perl script to C. So I can generate faster pictures from the Mandelbrot set.
You can find the source code here: https://github.com/TheFox/mandelbrot-c

This is what it looks like unzoomed.

If you zoom deeper you get something like this:

The red line(s) are the 0,0 coordinates. The green one is always the center of the image.

This took about 13 seconds to generate on my iMac (3,4 GHz Intel Core i7). But I’m pretty sure that this program can be optimized. If you click on the image you get an image with a higher resolution. The hi-res picture took about 23 minutes to generate. With OpenMP support and 8 threads the same image even took only 6 minutes.

Of course you can use programs like XaoS to generate very fast pictures from the Mandelbrot set. But the challenge for me on this project is to optimize the C code for speed. This is perfect for learning how to optimize C code because the functions execute billions of iteration loops to calculate the set. One little change in the code can either extremely speed up or slow down the execution time.

Posted on .
Categories: Project. Tags: Mandelbrot, Set, Perl, C, C++, OpenMP, Thread.

Imprint | Usage | Archive | Categories | Feed
Copyright © 2006 by