Futhark by Example

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

Some example programs use instructions to plot or render 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 slightly different approach to describing loop processing. We have tried to maintain the original naming scheme and programming style.

Most of the written Futhark code is probably still Futhark’s own test and benchmark suites. However, there are some programs that are written in Futhark because it was a good tool for the job, not just for testing the compiler. Possibly incomplete list:

diving beat is one falling sand
Game, which is a kind of simple particle simulator toy. Its main objective is to create a beautiful effect. There is a blog post with details and a video.

Soccer is a game of avoiding hitting balls. The rendering engine is a ray tracer written in Futhark.

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

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

Futswirl is a fractal generator based on iterated function systems.

Neptune is an implementation of the Poseidon hash function tuned for Filecoin, where the GPU parts are implemented in Futhark.

The Palathark lattice is a Futhark implementation of the Boltzmann method.

Ray Tracing in One Weekend in Futhark and Ray Tracing in Futhark: The Next Week are implementations based on the book series by Peter Shirley. These are by no means real-time ray tracers, but support advanced effects and use acceleration structures like BVH trees.

Paris is a compiler implemented in Futhark and C++.



<a href

Leave a Comment