Skip to main content

parallelbrot

Mandelbrot set renderer with CPU, OpenCL and CUDA backends — a Python package for generating fractal images, and an interactive real-time viewer.

Mandelbrot Renderer Demo


Install

pip install parallelbrot
# or
uv add parallelbrot

Wheels are abi3, so one wheel per platform covers CPython 3.9 and up.


Python API

import parallelbrot as pb

image = pb.render(1920, 1080)                 # (1080, 1920, 4) float32 RGBA

Zoom in on the seahorse valley, and save it:

from PIL import Image

image = pb.render(
    1920, 1080,
    center=(-0.743644, 0.131826),
    zoom=4000,
    max_iterations=1000,
    color_scheme="fire",
)
Image.fromarray((image * 255).astype("uint8")).save("seahorse.png")

render()

Argument Default Meaning
width, height Output size in pixels
center (-0.5, 0.0) Point on the complex plane at the image centre
zoom 1.0 Magnification; the view spans 4 / zoom
max_iterations 128 Escape limit — raise it as you zoom in
color_scheme "fire" ultra_fractal, fire, ocean or psychedelic
backend "auto" auto, cpu, opencl or cuda
origin "upper" upper puts row 0 at the top, as images expect

Returns an (height, width, 4) float32 array with values in [0, 1].

Choosing a backend

pb.available_backends()   # ('cpu',) — compiled in and a device is present
pb.compiled_backends()    # ('cpu', 'opencl') — compiled in, device or not
pb.device_name("opencl")  # 'NVIDIA GeForce RTX 4070' or None
pb.has_openmp()           # is the CPU backend multi-threaded?

backend="auto" picks the fastest backend that has a working device, falling back to the CPU.

Rendering releases the GIL, so calls from separate threads run in parallel:

from concurrent.futures import ThreadPoolExecutor

with ThreadPoolExecutor() as pool:                       # renders a zoom
    frames = list(pool.map(                              # sequence in parallel
        lambda z: pb.render(640, 480, zoom=z), [2**i for i in range(12)]
    ))

Which backends do you get?

CPU (OpenMP) OpenCL CUDA
pip install / uv add
conda-forge
built from source if headers found if nvcc found

PyPI wheels are CPU-only on purpose. Linking OpenCL makes the extension require an ICD loader at import time, which would break the package on machines without a GPU driver — including for people who only wanted the CPU backend. conda can declare that loader as a dependency, so the GPU builds live there.

The CPU backend is not a toy: OpenMP parallelises across rows with dynamic scheduling, since interior points cost far more than exterior ones. A 1920×1080 frame at 1000 iterations takes 37 ms on 16 cores, against 506 ms single-threaded.


Interactive viewer

A real-time pan-and-zoom window, built separately from the Python package.

make install-deps-ubuntu     # or -fedora, -arch, -macos
make opencl && bin/mandelbrot_opencl   # any GPU — recommended
make cuda   && bin/mandelbrot_cuda     # NVIDIA only, fastest
make cpu    && bin/mandelbrot_cpu      # always works
Input Action
Mouse drag Pan
Mouse wheel Zoom, centred on the cursor
Arrow keys Pan
+ / - Increase / decrease iterations
C Cycle colour schemes
R Reset view
Esc Quit

make help lists every target; make check-opencl and make check-cuda report what your machine can do.

Viewer dependencies

Component Linux macOS Windows (MSYS2)
Compiler g++ (GCC ≥ 9) Apple Clang MinGW-w64 g++
Build make, pkg-config make, pkg-config GNU make, pkg-config
OpenGL libgl1-mesa-dev, libglew-dev built-in mingw-w64-x86_64-glew
GLFW 3 libglfw3-dev brew install glfw mingw-w64-x86_64-glfw
OpenCL ocl-icd-opencl-dev + driver built-in framework mingw-w64-x86_64-opencl-icd
CUDA (optional) nvidia-cuda-toolkit + driver 470+ not supported CUDA Toolkit

GPU drivers: NVIDIA needs the proprietary driver or nvidia-opencl-dev; AMD needs rocm-opencl-runtime or mesa-opencl-icd; Intel needs intel-opencl-icd. macOS provides OpenCL itself.


Building from source

git clone https://github.com/prathamhole/parallelbrot
cd parallelbrot

uv sync                      # venv + dev dependencies, package built editable
uv run pytest                # 16 tests
uv run python -c "import parallelbrot as p; print(p.compiled_backends())"

Without uv:

pip install -e .             # rebuilds the C++ on import when sources change
pytest

Build options are Meson features, so absent tooling degrades the build rather than failing it:

uv sync -C setup-args=-Dopencl=enabled    # fail if OpenCL is missing
uv sync -C setup-args=-Dopenmp=disabled   # single-threaded CPU backend
python -m build --wheel                   # a cp3XX-abi3 wheel

macOS needs brew install libomp for a multi-threaded CPU backend — Apple Clang ships without OpenMP. pb.has_openmp() tells you which you got.

Layout

include/parallelbrot/core.hpp   Shared View struct + backend entry points
src/core/                       Compute cores — no windowing, no Python
src/cpu|opencl|cuda/            Interactive frontends + device kernels
src/python/                     CPython extension (limited API)
src/parallelbrot/               Python package
meson.build, pyproject.toml     Wheel build
Makefile                        Interactive viewer binaries

The compute cores carry no GLFW, OpenGL or Python headers, so the same code serves the viewer, the Python package and the tests.

See docs/RELEASING.md for the release process.


License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parallelbrot-0.1.0.tar.gz (2.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

parallelbrot-0.1.0-cp39-abi3-win_amd64.whl (257.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

parallelbrot-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (127.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

parallelbrot-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (123.4 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

parallelbrot-0.1.0-cp39-abi3-macosx_15_0_arm64.whl (255.3 kB view details)

Uploaded CPython 3.9+macOS 15.0+ ARM64

parallelbrot-0.1.0-cp39-abi3-macosx_14_0_x86_64.whl (287.0 kB view details)

Uploaded CPython 3.9+macOS 14.0+ x86-64

File details

Details for the file parallelbrot-0.1.0.tar.gz.

File metadata

  • Download URL: parallelbrot-0.1.0.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for parallelbrot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 421baa309b85d1b2255855b258eb9b3bd8e0f39607fc92edb9bc7bca7b6bd1c1
MD5 03db859595c6d98b7f4c9b621ce577b5
BLAKE2b-256 7ec3a81b8088dd8330240d94b92b4f789ad67b85290c05b736b447812e7d9a28

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallelbrot-0.1.0.tar.gz:

Publisher: wheels.yml on prathamhole14/parallelbrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parallelbrot-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: parallelbrot-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 257.3 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for parallelbrot-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 38fccdf2b75e802e4e13f15a82f8ee18e271a61148564a86fe53b35cdec2ede6
MD5 5ed2a9add5c7f7fed2170b99fc574fb5
BLAKE2b-256 4c00188dd38ef6a71dcf1010f57749b9a3d756dd5e5944e939c8517dc82e5658

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallelbrot-0.1.0-cp39-abi3-win_amd64.whl:

Publisher: wheels.yml on prathamhole14/parallelbrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parallelbrot-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for parallelbrot-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8546c0b228c8401d5b29048fdd69a2aa0701855200bfa2eb9959642988ac7250
MD5 762761e2db935f45a9cf67798ec7c5a5
BLAKE2b-256 35212eb2a32f18bb5900343fe6b68d1b0dd2df1f3a0d3df2ab57a31c09629230

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallelbrot-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on prathamhole14/parallelbrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parallelbrot-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for parallelbrot-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5f9ed085991d3ebf3cc0e69c1a6dfe7118ddf245554fea97a2d015345d3fecc7
MD5 a2e824bc3e769603a9389bf59f373a06
BLAKE2b-256 e6a9f26d227ad1fa766eecf821bf16aae7e68e637d1cc50226cd79a9a515305b

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallelbrot-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on prathamhole14/parallelbrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parallelbrot-0.1.0-cp39-abi3-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for parallelbrot-0.1.0-cp39-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 82065c81d44f51b158c417050d248c1f71c546bbf21a98b9a99ed120ed8df80d
MD5 868133463777279e0d357cca3b1dcf79
BLAKE2b-256 1b6c72ee7dba72f2c6063acd53d68d80cbe4457384232959debefe53f3be8cba

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallelbrot-0.1.0-cp39-abi3-macosx_15_0_arm64.whl:

Publisher: wheels.yml on prathamhole14/parallelbrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file parallelbrot-0.1.0-cp39-abi3-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for parallelbrot-0.1.0-cp39-abi3-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 b2b92064d70c8dd3a57bdab03d235624d29252c32f832d61ec0d5864f15787b2
MD5 6583bbad3e165b18c8e0c4605c6e748e
BLAKE2b-256 d47d0cec8a69fa046e338448941f3574bda3a171d09857057fbe73f01877971c

See more details on using hashes here.

Provenance

The following attestation bundles were made for parallelbrot-0.1.0-cp39-abi3-macosx_14_0_x86_64.whl:

Publisher: wheels.yml on prathamhole14/parallelbrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.1

6 files

0.1.1

6 files

This release

0.1.0 This release

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page