Skip to content
Tech News
← Back to articles

Futhark by Example

read original get Futhark Programming Book → more articles
Why This Matters

Futhark's examples demonstrate its versatility in high-performance parallel programming, from graphics rendering to cryptography, highlighting its potential for innovative applications in the tech industry. Its ability to efficiently leverage GPU resources makes it valuable for developers seeking to optimize computational tasks across diverse domains.

Key Takeaways

The following is a hands-on introduction to Futhark through a collection of commented programs, listed in roughly increasing order of complexity. You can load the programs into the interpreter to experiment with them. For a conventional introduction to the language, Parallel Programming in Futhark may be a better choice. For more examples, you can check our implemented benchmarks. We also maintain a list of projects using Futhark.

Some of the example programs use directives for plotting or rendering graphics.

Literate Futhark allows direct use of gnuplot. These examples show simple and common cases.

The following examples are ported from Dex, a dependently typed functional array language that uses a somewhat different approach to describing loop processing. We've tried to keep the original naming scheme and programming style.

OCaml-GPU wordcount example by calling Futhark.

The majority of written Futhark code is probably still Futhark’s own test and benchmark suites. However, there are some programs that have been written in Futhark because it was a good tool for the job, and not just to test the compiler. A possibly incomplete list:

Diving Beet is a falling sand game, which is a kind of simple particle simulator toy. Its main purpose is to produce pretty effects. There is a blog post with details and a video.

Futball is a game about avoiding getting hit by balls. The rendering engine is a ray tracer written in Futhark.

Futcam is an application that applies stacks of interactively configurable filters to a webcam stream. Futhark is used to implement the filters.

Futracer is a fairly slow brute-force ray tracer written in Futhark.

... continue reading