From 3efffb9ca98303487cf091447c7ba3fba3c71df8 Mon Sep 17 00:00:00 2001 From: JP Appel Date: Tue, 30 Apr 2024 06:46:31 -0400 Subject: finishing changes to presentation --- .gitignore | 1 + README.md | 34 +++- examples/burning_ship.png | Bin 0 -> 5830856 bytes examples/julia.png | Bin 0 -> 5672122 bytes examples/mandelbrot.png | Bin 0 -> 1554396 bytes examples/multibrot.png | Bin 0 -> 2304127 bytes examples/multicorn.gif | Bin 0 -> 155443 bytes examples/multicorn_framelist | 4 + examples/tricorn.png | Bin 0 -> 1448374 bytes makefile | 20 +- presentation/presentation.html | 411 +++++++++++++++++++++++++++++++++++++++++ presentation/presentation.md | 15 +- src/fractal_render.c | 3 +- src/renderers.c | 5 +- 14 files changed, 480 insertions(+), 13 deletions(-) create mode 100644 examples/burning_ship.png create mode 100644 examples/julia.png create mode 100644 examples/mandelbrot.png create mode 100644 examples/multibrot.png create mode 100644 examples/multicorn.gif create mode 100644 examples/multicorn_framelist create mode 100644 examples/tricorn.png create mode 100644 presentation/presentation.html diff --git a/.gitignore b/.gitignore index c93d064..270e560 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ analysis/data/* build/* *.html !analysis/analysis.html +!presentation/presentation.html # IDE stuff .vscode diff --git a/README.md b/README.md index 17c312e..a962c12 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Each version of the complex fractal generator has its own dependencies. The serial version should compile on all systems that support complex arithmetic. The shared version requires a compiler with [OpenMP](https://www.openmp.org/) support. -The CUDA version requires the `nvcc` compiler and `thrust libraries`. +The CUDA version requires the `nvcc` compiler and `thrust` libraries. For better performance on your machine, change the flag `-arch=sm_86` in `NVCFLAGS` in the makefile to your gpu's compute capability. ### Building @@ -68,6 +68,38 @@ Generates a 500x500 julia fractal grid which has a maximum of 30 iterations for ## Visualizations +The program `fractal-render` renders `.grid` files into txt, png's, and animated gifs. + +``` +Usage: fractal-render -i input.grid [-r renderer] [-o output.ext] +Options: + -i, --input the grid to be rendered, if the file name is '-' reads from stdin + -r, --renderer the renderer to use, defaults to the text renderer + renderers: txt, png, gif (TODO, with additional features) + -d, --delay the delay between animation frames in 1/100 s + -o, --output the file to output the result of rendering, if not given defaults to fractal.out. + -v, --verbose verbose output + -h, --help prints this help and exits +``` + +### Building + +To build simply run + +```bash +make +``` + +### Examples + +Some example visualizations are provided in `examples`, they can be regenerated with + +```bash +make examples/julia.png +make examples/multicorn.gif +``` + + ## Presentation Building the presentation requires a [pandoc](https://pandoc.org/) installation. diff --git a/examples/burning_ship.png b/examples/burning_ship.png new file mode 100644 index 0000000..98ce9f1 Binary files /dev/null and b/examples/burning_ship.png differ diff --git a/examples/julia.png b/examples/julia.png new file mode 100644 index 0000000..1b8440c Binary files /dev/null and b/examples/julia.png differ diff --git a/examples/mandelbrot.png b/examples/mandelbrot.png new file mode 100644 index 0000000..4fbfb8a Binary files /dev/null and b/examples/mandelbrot.png differ diff --git a/examples/multibrot.png b/examples/multibrot.png new file mode 100644 index 0000000..6aae55d Binary files /dev/null and b/examples/multibrot.png differ diff --git a/examples/multicorn.gif b/examples/multicorn.gif new file mode 100644 index 0000000..115eb9b Binary files /dev/null and b/examples/multicorn.gif differ diff --git a/examples/multicorn_framelist b/examples/multicorn_framelist new file mode 100644 index 0000000..243dfd2 --- /dev/null +++ b/examples/multicorn_framelist @@ -0,0 +1,4 @@ +examples/multicorn_2.grid +examples/multicorn_3.grid +examples/multicorn_4.grid +examples/multicorn_5.grid diff --git a/examples/tricorn.png b/examples/tricorn.png new file mode 100644 index 0000000..8d02e24 Binary files /dev/null and b/examples/tricorn.png differ diff --git a/makefile b/makefile index 8fc8abd..8a73420 100644 --- a/makefile +++ b/makefile @@ -48,19 +48,31 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR) $(OBJ_DIR): mkdir -p $@ -########### -# Tests # -########### +#################### +# Tests/Examples # +################### examples/julia.png: examples/julia.grid $(BUILD_DIR)/fractal-render $(BUILD_DIR)/fractal-render -i $< -r png -o $@ +examples/multicorn.gif: examples/multicorn_framelist + $(BUILD_DIR)/fractal-render -i $< -d 80 -r gif -o $@ + +examples/multicorn_framelist: examples/multicorn_2.grid examples/multicorn_3.grid examples/multicorn_4.grid examples/multicorn_5.grid + @echo $< > $@ + @echo $(word 2, $^) >> $@ + @echo $(word 3, $^) >> $@ + @echo $(word 4, $^) >> $@ + examples/julia.grid: $(BUILD_DIR)/shared-fractals - $< -c 0.285+0.01i -i 255 -r 2 -x 8192 -y 8192 -o $@ -f julia + $< -c 0.285+0.01i -i 155 -r 2 -x 8192 -y 8192 -o $@ -f julia examples/mandelbrot_%.grid: $(BUILD_DIR)/%-fractals $< -x 100 -y 100 -o $@ +examples/multicorn_%.grid: $(BUILD_DIR)/shared-fractals + $< -x1000 -y1000 -i50 -d $* -o $@ -f multicorn + tests/mandelbrot: examples/mandelbrot_serial.grid examples/mandelbrot_shared.grid examples/mandelbrot_cuda.grid cmp -l $< $(word 2, $^) > $@ cmp -l $(word 2, $^) $(word 3, $^) >> $@ diff --git a/presentation/presentation.html b/presentation/presentation.html new file mode 100644 index 0000000..31c1443 --- /dev/null +++ b/presentation/presentation.html @@ -0,0 +1,411 @@ + + + + + + + + HPC Complex Fractal Generation + + + + + + + + + +
+
+ +
+

HPC Complex Fractal Generation

+

JP Appel

+

David Marrero

+
+ +
+
+

Prerequisite Knowledge

+ +
+
+

Complex Numbers

+

i2 =  − 1 z = x + iy

+ +
+

Addition

+

z1 + z2 = (x1+x2) + i(y1+y2)

+ +

Multiplication

+

z1z2 = (x1x2y1y2) + i(x1y2+x2y1)

+
+
+
+

What is the Mandelbrot Set

+
+

zn = zn − 12 + z0

+ +
+
+
+

Fractals

+
+
+
    +
  • infinite self-similar geometric shape
  • +
  • have “fractional dimension”
  • +
+
+
+Sripenski Triangle + +
+
+
+
+

The Mandelbrot set is a fractal in the complex plane

+ +
+
+
+

Fractal in Nature

+
+Romanesco Cauliflower + +
+ +
+
+

Escape Time Algorithm

+
+
    +
  • Inputs +
      +
    • Maximum Number of iterations
    • +
    • Upper bound
    • +
  • +
+
    +
  1. Create a grid of points to sample
  2. +
  3. For each point in the sample space +
      +
    1. Compute the next term in the sequence
    2. +
    3. if greater than the upper bound return the number +of iterations
    4. +
    5. else repeat until the maximum number of iterations +and return
    6. +
  4. +
+
+ +
+
+
+

Implementation

+ +
+
+

Program Structure

+

+ +
+
+

Mandelbrot

+

Image

+ +
+
+

Tricorn

+

Image

+
+
+

Burning Ship

+

Image

+
+
+

Multibrot

+

Image

+
+
+

Multicorn

+

GIF

+
+
+

Julia

+

Image

+
+
+
+

Analysis

+ +
+
+

+

Interactive Plots

+
+
+
+ + + + + + + + + + + diff --git a/presentation/presentation.md b/presentation/presentation.md index b3297c3..a4a1f4f 100644 --- a/presentation/presentation.md +++ b/presentation/presentation.md @@ -139,6 +139,8 @@ The Mandelbrot set is a fractal in the complex plane ## Mandelbrot +[Image](../examples/mandelbrot.png) + ::: notes * when mandelbrot initially tried to have this printed, the printers kept removing the "dust" thinking it was an error in their printing process @@ -147,19 +149,24 @@ The Mandelbrot set is a fractal in the complex plane ## Tricorn +[Image](../examples/tricorn.png) + ## Burning Ship +[Image](../examples/burning_ship.png) + ## Multibrot +[Image](../examples/multibrot.png) + ## Multicorn -## Julia +[GIF](../examples/multicorn.gif) -## Serial Animation -## Shared Animation +## Julia -## CUDA Animation +[Image](../examples/julia.png) # Analysis diff --git a/src/fractal_render.c b/src/fractal_render.c index 721d3f2..fe25f12 100644 --- a/src/fractal_render.c +++ b/src/fractal_render.c @@ -21,8 +21,7 @@ void print_help(){ " -r, --renderer the renderer to use, defaults to the text renderer\n" " renderers: txt, png, gif (TODO, with additional features)\n" " -d, --delay the delay between animation frames in 1/100 s\n" - " -o, --output the file to output the result of rendering, if not given defaults to output.\n" - " where is the renderer used\n" + " -o, --output the file to output the result of rendering, if not given defaults to fractal.out\n" " -v, --verbose verbose output\n" " -h, --help prints this help and exits\n" ); diff --git a/src/renderers.c b/src/renderers.c index 2955fb2..372d7a2 100644 --- a/src/renderers.c +++ b/src/renderers.c @@ -51,10 +51,11 @@ gdImagePtr converter(const grid_t* grid){ gdImagePtr img = gdImageCreate(width, height); int colors[256]; for(size_t i = 0; i < 255; i++){ - colors[i] = gdImageColorAllocate(img, 0, i, i/2); + colors[i] = gdImageColorAllocate(img, 0, 255-i, (255-i)/2); } colors[255] = gdImageColorAllocate(img, 0, 0, 0); + for(size_t y = 0; y < height; y++){ for(size_t x = 0; x < width; x++){ byte iteration = data[y * width + x]; @@ -82,7 +83,7 @@ void render_gif(FILE* output, const renderer_params* params){ gdImagePtr imgs[size]; imgs[0] = converter(grids[0]); - gdImageGifAnimBegin(imgs[0], output, 1, -1); + gdImageGifAnimBegin(imgs[0], output, 1, 0); gdImageGifAnimAdd(imgs[0], output, 0, 0, 0, delay, 1, NULL); for(size_t i = 1; i < size; i++){ -- cgit v1.2.3