This repository contains code written for my thesis project at the University of Virginia, for which I am developing a library for plotting fractals and functions of a complex variable using NVIDIA graphics cards. The code is divided across five files, each of which accomplish some "idea":
color.cudefines a struct for holding RGB values and some utility functions related to this representation.image.cudefines a struct for images files, along with functions for reading from and writing to the.ppmformat. This format stores the raw pixel values (meaning large file sizes), but is simple enough to make a reader/writer from scratch.kernels.cudefines the kernels for each type of plot. This is where most of the heavy math is done.stills.cudefines functions for rendering to.ppmimage files.window.cudefines functions for rendering in a game window.
We will now discuss each type of plot supported by the library.
Suppose we want to visualize a function
A solution is that we can use color in our plots. The first technique we describe is known as domain coloring, wherein we draw some subset of
In particular, given a complex number
defines a color in the hsl_to_rgb defined in color.cu, inspired by the procedure detailed by
Saravanan, Yamuna, and Nandhini.
Heuristically, what this accomplishes is that the phase (or angle) of
Pictorially, we can see its roots, the third roots of unity, because in our color map, a magnitude of zero corresponds to black.
Phase portraiture is a variation on domain coloring, except that the magnitude of
TODO Mercat
TODO
TODO
One major area for work is improving efficiency. This includes running experiments to measure the impact of:
- Vectorize stores by using
uchar3. - Use fused multiply-adds (FMA) wherever possible, such as in lerp, the kernels (indices to complex), and
hsl_to_rgb(chroma, x, m).
Another area for work is code quality. This includes:
- Unify the (three) plot-specific CUDA kernels into a single generalized kernel.
- Make this documentation more thorough.
Finally, there are additional features we would like to support, such as:
- Add Toggleable axes in the window.
- Add phase portraits as another plot type.
- Develop a CPU version that does not rely upon CUDA.
Many examples and techniques were drawn from these excellent resources. I highly recommend them if you are looking to learn more.
