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 the examples directory in the Futhark repository, or at our implemented benchmarks. We also maintain a list of projects using Futhark.
- Basic usage with the factorial function
- Primitive values
- Basic parallelism
- Tuples and records
- Scans and reductions
- Parametric polymorphism
- Gather and scatter
- Sum types and pattern matching
- Size parameters
- Matrix multiplication
- Computing histograms
- Radix sort
- Testing for associativity
- Reducing or scanning without a neutral element
- Gaussian blur (with Python integration)
- Faking nominal types
- Binary search
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:
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.
Palathark is a Futhark implementation of the lattice Boltzmann method.
Ray Tracing in One Weekend in Futhark and Ray Tracing: the Next Weekend in Futhark are implementations based on Peter Shirley’s book series. These are by no means real-time ray tracers, but support advanced effects and make use of acceleration structures like BVH trees.