Skip to content
Mandelbrot fractal on NVidia GPUs using CUDA dynamic parallelism and Mariani-Silver algorithm
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Mandelbrot fractal with CUDA dynamic parallelism (sample)


This is a set of two samples that both create an image of the Mandelbrot fractal
on NVidia GPUs with and without dynamic parallelism. Each sample has its own

mandelbrot/                 - without dynamic parallelism
mandelbrot-dyn/             - with dynamic parallelism

The sample without dynamic parallelism uses escape time algorithm
( to
compute the dwell on the GPU. The dynamic parallelism sample uses the
hierarchical Mariani-Silver algorithm (see, e.g., In both cases, final
coloring is done on the CPU, just to make the code clearer. Depending on the
image size and maximum dwell, the dynamic parallelism version is 1.3-6x faster
than the version where each pixel is evaluated.

This code has been developed by Andrew V. Adinetz, who is employed as researcher
in Juelich Supercomputing Centre, Forschungszentrum Juelich. This code is
property of Forschungszentrum Juelich. Users can modify and/or distribute code
free of charge, provided that this notice is retained. 

These samples have been primarily developed for educational purposes. They have
been used, e.g., in a lecture on CUDA dynamic parallelism in Advanced GPU
Programming course in Forschungszentrum Juelich
( Other
users can freely use this code for teaching, illustrative or copy-paste
purposes, if the link to the original source is provided.


For both: 

- Unix-like OS (tested on Linux)
- libpng (to save the generated image)

For Mandelbrot without dynamic parallelism:

- CUDA 4.0 or higher 
- NVidia GPU with Compute Capability 2.0 or higher (= Fermi or higher)

For Mandelbrot with dynamic parallelism:

- CUDA 5.0 or higher
- NVidia GPU with Compute Capability 3.5 or higher (= Kepler K20 or higher)


The following commands should be executed in the directory of the corresponding

To compile a sample, execute the following command:


To compile and run a sample, execute the following command:

	 make run

Upon running successfully, the sample will create the PNG image of Mandelbrot
fractal (mandelbrot.png). The resolution of the image and the maximum dwell used
to generate it are set in the source code of the sample using W, H and MAX_DWELL
constants, respectively. 
You can’t perform that action at this time.