{"id":17650878,"url":"https://github.com/yalue/cudabrot","last_synced_at":"2025-05-07T07:06:38.861Z","repository":{"id":69008024,"uuid":"98926595","full_name":"yalue/cudabrot","owner":"yalue","description":"A CUDA renderer for the Buddhabrot fractal","archived":false,"fork":false,"pushed_at":"2023-09-14T00:37:47.000Z","size":1541,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T07:06:25.094Z","etag":null,"topics":["amd","buddhabrot","buddhabrot-fractal","cuda","gpu","hip","mandelbrot","mandelbrot-fractal","rocm"],"latest_commit_sha":null,"homepage":"","language":"Cuda","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yalue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-31T20:22:59.000Z","updated_at":"2024-11-26T09:23:17.000Z","dependencies_parsed_at":"2025-03-10T21:31:06.590Z","dependency_job_id":"1d8fcde6-56b7-4359-8d3f-f4a6318c578c","html_url":"https://github.com/yalue/cudabrot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yalue%2Fcudabrot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yalue%2Fcudabrot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yalue%2Fcudabrot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yalue%2Fcudabrot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yalue","download_url":"https://codeload.github.com/yalue/cudabrot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252831255,"owners_count":21810783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amd","buddhabrot","buddhabrot-fractal","cuda","gpu","hip","mandelbrot","mandelbrot-fractal","rocm"],"created_at":"2024-10-23T11:39:42.404Z","updated_at":"2025-05-07T07:06:38.853Z","avatar_url":"https://github.com/yalue.png","language":"Cuda","funding_links":[],"categories":[],"sub_categories":[],"readme":"CUDAbrot: A \"Buddhabrot\" Renderer using CUDA or HIP\n===================================================\n\nAbout\n-----\n\nThis project contains a small CUDA program for rendering the Buddhabrot fractal\nusing a CUDA-capable GPU.\n\nI'm aware that there are at least two other github projects named \"cudabrot\",\nbut both of them render the Mandelbrot set rather than the Buddhabrot. The\nBuddhabrot set is a variant of the Mandelbrot set similar to an\n[attractor](https://en.wikipedia.org/wiki/Attractor), and is generally more\nprocessor-intensive to render. Therefore, rendering high-resolution Buddhabrot\nimages is an excellent application of GPU computing.\n\nFor more information on how the Buddhabrot set is rendered, see the\n[Wikipedia article](https://en.wikipedia.org/wiki/Buddhabrot) for information\nabout the algorithm and the relationship to the Mandelbrot set.\n\nUsage\n-----\n\nTo compile and run this program, you need to be using a Linux system with CUDA\ninstalled (the more recent the version, the better), and a CUDA-capable GPU.\nSee below for instructions on AMD, using HIP.\n\nCompile the program simply by running `make`. Run it by running `./cudabrot`.\nA summary of command-line arguments can be obtained by running\n`./cudabrot --help`. Running the program will produce a single grayscale image.\nTypically, a colored Buddhabrot image is created by rendering several single-\nchannel images with different parameters, then combining the results by\nassigning each single-channel image to a color in the output image.\n\nCompilation on AMD, using ROCm\n------------------------------\n\nThis program has also been built and tested using ROCm 3.7 (but older versions\nprobably work) on AMD GPUs. To use this, you'll need to have\n[installed ROCm](https://github.com/RadeonOpenCompute/ROCm), including `hip`,\n`rocRAND`, and `hipRAND` (these should be installed by default if you just\nfollow the main ROCm installation instructions). Additionally, you'll need to\nensure that `hipcc` and `hipify-perl` are on your `PATH`. The makefile also\nexpects to be able to find `rocRAND` and `hipRAND` under `/opt/rocm/rocrand`\nand `/opt/rocm/hiprand`, respectively.\n\nIf you satisfy all of the above requirements, then you should be able to\ncompile the program by running `make hip`. This will produce a `cudabrot`\nbinary that behaves the same way as the CUDA version. (Don't be intimidated by\nthese instructions--check the makefile, it's actually very simple!)\n\n\nExamples and detailed description of options\n--------------------------------------------\n\nAll examples below were rendered using an NVIDIA GTX 970 with 4GB of GPU RAM.\n\n - `-d \u003cdevice number\u003e`: Example: `./cudabrot -d 0`. If you have more than one\n   GPU, providing the `-d` flag along with a device number allows you to run\n   computations on a GPU of your choosing. If the `-d` flag isn't specified,\n   the program defaults to using GPU 0.\n\n - `-o \u003coutput file name\u003e`: Example: `./cudabrot -o image.pgm`. This program is\n   capable only of saving `.pgm`-format images, which are a simple grayscale\n   bitmap format. Output images always use 16-bit grayscale. If left\n   unspecified, the program will save the image to a file named `output.pgm` by\n   default.\n\n - `-w \u003cimage width\u003e`: Example: `./cudabrot -w 500 -h 500`. This flag controls\n   the horizontal resolution of the output image, in pixels. Note that neither\n   this nor `-h` (for controlling vertical resolution) affects resolution at\n   which the complex plane is actually sampled. Image resolution doesn't\n   directly affect computation speed, but it *will* have an impact on GPU and\n   CPU memory required. For example, rendering a 20000x20000 image\n   (`-w 20000 -h 20000`) takes at least 3 GB of GPU memory, so higher\n   resolutions may only be possible on more-capable GPUs.\n\n - `-h \u003cimage height\u003e`: Example: `./cudabrot -w 500 -h 500`. This is like `-w`,\n   except it controls vertical resolution rather than horizontal resolution.\n\n - `-s \u003csave/load file\u003e`: If provided, this must be the name of a file into\n   which the rendering buffer will be saved, for future continuation. If the\n   file already exists when the program starts, it will be loaded (and then\n   updated again before the program exits). This can be helpful if you need to\n   \"pause\" long-running renders and resume them later. If already present, the\n   file's size must match the expected internal size of the image buffer, but\n   otherwise the file has no specified format.\n\n - `--min-real \u003cminimum real value\u003e`: Example: `./cudabrot -w 200 -h 100 --min-real 0.0 --max-real 1.0 --min-imag 0.0 --max-imag 0.5`.\n   This, along with `--max-real`, `--min-imag`, and `--max-imag` control the\n   borders of the output-image \"canvas\" on the complex plane. The rectangle\n   specified must be well-formed (e.g. `--min-real` must be less than\n   `--max-real`, etc.). If you want to set the canvas to something that isn't a\n   square, then you'll also need manually adjust the output width and height to\n   match the aspect ratio. For example, the above \"example\" command produces\n   this image: ![cropped example image](examples/cropped.png). Note that\n   \"zooming in\" will *not* necessarily speed up rendering, since points must\n   still be sampled from across the entire Mandelbrot-set domain (from -2.0 to\n   2.0, and -2.0i to 2.0i).  However, these settings can still be used for\n   saving memory if you want to zoom in on finer details without rendering an\n   ultra-high-resolution image. `--min-real` defaults to -2.0.\n\n - `--max-real \u003cmaximum real value\u003e`. See the note about `--min-real`.\n   `--max-real` defaults to 2.0.\n\n - `--min-imag \u003cminimum imaginary value\u003e`. See the note about `--min-real`.\n   `--min-imag` defaults to -2.0.\n\n - `--max-imag \u003cmaximum imaginary value\u003e`. See the note about `--min-real`.\n   `--max-imag` defaults to 2.0.\n\n - `-t \u003ctime to run (in seconds)\u003e`: Example: `./cudabrot -t 60`. This option\n   specifies the amount of time, in seconds, to run the rendering on the GPU.\n   The longer the time, the sharper the image will appear (especially at high\n   resolutions or number of iterations). Passing a special value of -1 to `-t`\n   will cause the program to run until it is interrupted by the user (using\n   `kill` or CTRL+C on Linux, for example). Example: `./cudabrot -t -1`. If the\n   program is run with `-t -1` and killed by the user, it will save the\n   currently-rendered output image. This is the recommended way to run the\n   program, if, for example, you want to render an image overnight. This option\n   defaults to 10 seconds.\n\n - `-g \u003cgamma correction\u003e`: Example: `./cudabrot -g 2.0`. This option specifies\n   the amount of gamma correction to be applied post-rendering. Gamma\n   correction brightens darker areas of the image, which enhances the\n   visibility of some details. In most cases, it may be easier to apply gamma\n   correction post-rendering using a separate image editor (where changes can\n   be previewed), but this option is available for convenience and scripting.\n   This option defaults to 1.0 (no gamma correction).\n   Example images:\n\n    | `./cudabrot -w 200 -h 200 -m 10000 -c 8000 -t 30 -g 1.0` | `./cudabrot -w 200 -h 200 -m 10000 -c 8000 -t 30 -g 1.5` | `./cudabrot -w 200 -h 200 -m 10000 -c 8000 -t 30 -g 2.2` |\n    | :---: | :---: | :---: |\n    | ![No gamma correction](examples/gamma_1_0.png) | ![1.5 gamma](examples/gamma_1_5.png) | ![2.2 gamma](examples/gamma_2_2.png) |\n\n - `-m \u003cmax escape iterations\u003e`: Example: `./cudabrot -m 10000`. This option\n   specifies the maximum iterations to follow each particle before determining\n   whether it remains in the Mandelbrot set (meaning that its path is included\n   in the Buddhabrot set). In short, increasing this value will include more\n   fine details in the resulting image. This value defaults to 100, which is a\n   fairly low value. See these examples:\n\n    | `./cudabrot -w 200 -h 200 -t 10 -c 20 -m 100` | `./cudabrot -w 200 -h 200 -t 10 -c 20 -m 1000` | `./cudabrot -w 200 -h 200 -t 10 -c 20 -m 20000` |\n    | :---: | :---: | :---: |\n    | ![Low max iterations](examples/max_100.png) | ![Mid max iterations](examples/max_1000.png) | ![High max iterations](examples/max_20000.png) |\n\n - `-c \u003cmin escape iterations\u003e`: Example: `./cudabrot -m 5000 -c 4000`. This\n   option specifies the minimum cutoff for the number of iterations for which\n   points must *remain* in the Mandelbrot set if they are to be included in\n   the Buddhabrot. Increasing the minimum cutoff iterations will therefore\n   reduce the \"cloudiness\" of the generated image, enhancing the visibility of\n   the details produced using higher `-m` values. This value defaults to 20,\n   which will produce a cloudy, nebulous image. See these examples:\n\n    | `./cudabrot -w 200 -h 200 -t 30 -g 1.8 -m 20000 -c 20` | `./cudabrot -w 200 -h 200 -t 30 -g 1.8 -m 20000 -c 2000` | `./cudabrot -w 200 -h 200 -t 30 -g 1.8 -m 20000 -c 10000` |\n    | :---: | :---: | :---: |\n    | ![Low cutoff](examples/cutoff_20.png) | ![Mid cutoff](examples/cutoff_2000.png) | ![High cutoff](examples/cutoff_10000.png) |\n\n\nColoring the Buddhabrot\n-----------------------\n\nThe Buddhabrot rendering maps most easily to grayscale images, so coloring is\nleft to post-processing. The \"traditional\" way to color a Buddhabrot is to\ngenerate several grayscale images using different minimum and maximum iteration\nvalues (the `-m` and `-c` options in this program). The grayscale images can\nthen be combined into a single output image, with each grayscale image\ncontributing to a different color channel in the output.\n\nA free program that can be used to combine grayscale images into a single color\nimage exists [in a separate repository](https://github.com/yalue/image_combiner).\n\nHere's an example of how to create a color image, using the `image_combiner`\ntool linked above:\n\n```bash\n./cudabrot -g 2.0 -w 1000 -h 1000 -m 100 -c 20 -t 20 -o low_iterations.pgm\n./cudabrot -g 2.0 -w 1000 -h 1000 -m 2000 -c 600 -t 20 -o mid_iterations.pgm\n./cudabrot -g 2.5 -w 1000 -h 1000 -m 10000 -c 9000 -t 40 -o high_iterations.pgm\n./image_combiner \\\n    low_iterations.pgm blue \\\n    mid_iterations.pgm lime \\\n    high_iterations.pgm red \\\n    color_output.jpg\n```\n\nAlternatively, I've found that mapping grayscale images to H, S, and L\ncomponents of an HSL-color image results in a wide range of colors. I've\nincluded a script, `generate_hires_color_image.sh`, that uses this program to\ngenerate a nice looking, high-resolution (20k x 15x pixels) result. See the\ncomments in the script for notes about additional requirements and operation.\nThe following image is a cropped portion of the full-resolution output:\n\n![Cropped HSL-script output](examples/hsl_render.jpg)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyalue%2Fcudabrot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyalue%2Fcudabrot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyalue%2Fcudabrot/lists"}