Example: Fractal Julia set in Mojo and Mojo GPU

As a way to learn how to run Mojo on a GPU, I wrote a Julia fractal image generator in Mojo for the CPU and then for my NVIDIA A2000 GPU. I hope this is a good starting point for other people, especially Python programmers, who haven’t written GPU side code before and think it might be too hard for them. With Mojo, no it isn’t. Mojo really is “CUDA for Python programmers”.

Plus I wrote the same program in Python and C++ for comparison. Yes, benchmarks are always tricky, but the difference between C++ and Mojo is … surprising!

8 Likes

Very cool! A really fun combination might be to try integrating the calculation with the experimental work @lukas is doing with rendering from Mojo into OpenGL textures here: GitHub - lsh/shimmer: An experiment in cross-platform rendering to OpenGL textures using Mojo as a shading language. for a live iteration or zoom into the Julia set.

2 Likes