The Futhark documentation is divided into several parts. The in-progress book Parallel Programming in Futhark can be read freely online, and is the starting point for learning Futhark. The Futhark User's Guide contains detailed instructions on how to use the compilers, as well as the language reference and instructions on how to install the Futhark compiler.
If there is something you believe should be documented, but is not, you are very welcome to report the omission as a bug on our bug tracker. See the page Get Involved for more information.
We also have some Haddock-generated documentation of the compiler internals which is automatically updated every night.
- futhark-pycffi is a convenient way to access code generated by
futhark opencl, and
futhark cudafrom Python. For some programs, this can be a good bit faster than using
- Futhark support for Sublime Text 3.
- futhark-mode for Emacs.
- Syntax highlighting for Vim.
- Futhark language definition for Gedit. Simply place the linked file in
We have published a number of papers on Futhark, and hopefully more will follow in the future. They are presented below in reverse chronological order.
This paper presents a library for implementing neural networks in Futhark. The library functions are generically typed and the composition structure allows for networks to be trained (using back-propagation) and for trained networks to be used for predicting new results (using forward-propagation). Individual layers in a network can take different forms ranging over dense sigmoid layers to convolutional layers. We demonstrate that Futhark’s elimination of higher-order functions and modules leads to efficient generated code, with comparison to to TensorFlow.
One of Futhark’s main difficulties is its restriction to regular parallelism. This paper presents a programming technique for expressing certain kinds of irregular data-parallel problems in a regular manner.
This paper expands on the compilation scheme presented in our PLDI 2017 paper, to employ a multi-versioned approach, in which the parallelism in the program is mapped to multiple independent (but semantically equivalent) code versions, and the best one picked at run-time based on the concrete input data observed. The title is an homage to the paper Data-Only Flattening for Nested Data Parallelism, which also seeks to improve on the inefficiency of full flattening. See also the blog post on the paper.
Futhark initially did not support higher-order functions, because the usual compilation strategy creates a great degree of indirection, which can inhibit optimisation and efficient compilation. In this paper, we present a de functionalisation transformation that relies on type-based restrictions on the use of expressions of functional type, such that we can completely eliminate higher-order functions in all cases, without introducing any branching. We prove the correctness of the transformation and discuss its implementation in Futhark, a data-parallel functional language that generates GPU code. The use of these restricted higher-order functions has no impact on run-time performance, and we argue that we gain many of the benefits of general higher-order functions, without in most practical cases being hindered by the restrictions. An extended treatment can be found in Anders Kiel Hovgaard’s master’s thesis, available here.
This paper discusses the higher-order ML-style module system available in Futhark. Most of the discussion is a theoretical treatment, including a formally-verified implementation in Coq. The implementation in the Futhark compiler does not use this verified implementation for a variety of reasons, but it does almost exactly follow the semantic object definitions given in the paper.
This case study examines the data-parallel functional implementation of three algorithms: generation of quasi-random Sobol numbers, breadth-first search, and calibration of Heston market parameters via a least-squares procedure. We show that while all these problems permit elegant functional implementations, good performance depends on subtle issues that must be confronted in both the implementations of the algorithms themselves, as well as the compiler that is responsible for ultimately generating high-performance code. In particular, we demonstrate a modular technique for generating quasi-random Sobol numbers in an efficient manner, study the efficient implementation of an irregular graph algorithm without sacrificing parallelism, and argue for the utility of nested regular data parallelism in the context of nonlinear parameter calibration.
This PhD thesis describes the overall background and motivation behind the development of Futhark, as well as a collection of some of the core implementation techniques (size-dependent typing, fusion, moderate flattening, tiling). The treatment is high level, and the technicalities of the concrete compiler implementation is not discussed in great detail. The first part of the thesis describes the overall philosophy behind the design and implementation of Futhark, and is fairly readable. The latter part of the thesis, which discusses concrete program transformations, is a more difficult read, and probably only of interest to academics. The empirical evaluation chapter is a good description of what Futhark does well, and what it does not so well (at least as of the time the thesis was written).
A description of an implementation technique for regular segmented reductions on GPU. The technique is based on having three different strategies for dealing with different problem classes. This is the technique currently used by the Futhark compiler, but it is presented in a general setting, and could be used by other libraries and languages that make use of regular segmented reductions.
A general and self-contained description of the main points of the design and implementation of Futhark, including pieces of fusion, a formalisation of the uniqueness typing rules, and our mechanism for kernel extraction. The latter is the main novelty, as it allows the Futhark compiler to exploit regular nested parallelism in a more efficient (albeit also more restricted) manner than full flattening, while still being more powerful than approaches that support only flat parallelism. The accompanying benchmark suite is freely accessible.
A paper describing an APL compiler (apltail) that operates by translating APL into a typed array intermediate language (TAIL), and from there into Futhark. While the Futhark details are light, the paper demonstrates a simple use of Futhark as a target language for a compiler. We succeed in achieving decent speedup on several (small) APL programs. The accompanying benchmark suite may be worth a look.
A detailed presentation of one of Futhark’s internal language constructs -
redomap - which is used to represent various forms of
reduce-fusion. We present some microbenchmarks implemented in both Thrust and Futhark and discuss their relative performance.
Futhark supports automatic size inference of arrays, and this paper describes our approach, which is based on slicing. The descriptions are still up-to-date, although the Futhark source language has since grown support for user-defined size annotations, which can sometimes enable the compiler to make better assumptions about the shapes of arrays.
We implemented a novel form of bounds checking by extracting predicate functions from programs with array indexing. These predicates functioned as sufficient conditions for all bounds checks in the original program: if the extracted predicates evaluated to true, then every array index was guaranteed to be in bounds. The idea is that this produces an efficient alternative to precise bounds checking even for very complicated accesses (such as indirect indexing). The idea works, but was hard to implement and maintain and thus distracted us from our core work, so it is no longer used in the Futhark compiler. Instead, we provide an
unsafe keyword that one can use to remove bounds checks that would otherwise hinder parallelisation. In the future, we might return to this work.
A presentation of the core of the producer-consumer fusion algorithm in the Futhark compiler (although the language was called L0 at the time). The description of the fundamental algorithm is still correct, although it does not cover some of the newer language additions, nor does it describe horisontal fusion.
- Robert Schenck: Sum types in Futhark. MSc thesis. Computer Science, University of Copenhagen. December 2019. (pdf)
- Henrik Urms, Anna Sofie Kiehn: Refinement types in Futhark. MSc thesis. Computer Science, University of Copenhagen. September 2019. (pdf)
- Steffen Holst Larsen: Multi-GPU Futhark Using Parallel Streams. MSc thesis. Department of Computer Science, University of Copenhagen. September 2019. (pdf)
- Svend Lund Breddam: Futhark Autotuners for Incremental Flattening. MSc thesis. Department of Computer Science, University of Copenhagen. September 2019. (pdf)
- Steffen Holst Larsen: Futhark Vulkan Backend. MSc project. Department of Computer Science, University of Copenhagen. January 2019. (pdf)
- Jakob Stokholm Bertelsen: Implementing a CUDA Backend for Futhark. BSc thesis. Department of Computer Science, University of Copenhagen. January 2019. (pdf)
- Sune Hellfritzsch: Efficient Histogram Computation on GPGPUs. MSc thesis. Department of Computer Science, University of Copenhagen. October 2018. (pdf)
- Duc Minh Tran: Implementation of a deep learning library in Futhark. BSc Thesis. Department of Computer Science, University of Copenhagen. August 2018. (pdf)
- Mikkel Storgaard Knudsen: FShark: Futhark programming in FSharp. MSc thesis. Department of Computer Science, University of Copenhagen. August 2018. (pdf)
- Marek Hlava and Martin Metaksov: Accelerated Interest Rate Option Pricing using Trinomial Trees. MSc thesis. Department of Computer Science, University of Copenhagen. August 2018. (pdf)
- Kasper Abildtrup Hansen: FFT Generator in Futhark: A prototype Futhark library using FFTW technniques. MSc project. Department of Computer Science, University of Copenhagen. June 2018. (pdf)
- Frederik Thorøe: Auto-tuning of threshold-parameters in Futhark. BSc thesis. Department of Computer Science, University of Copenhagen. June 2018. (pdf)
- Mette Marie Kowalski: Designing and Accelerating a Generic FFT Library in Futhark. BSc thesis. Department of Computer Science, University of Copenhagen. June 2018. (pdf)
- Anders Kiel Hovgaard: Higher-order functions for a high-performance programming language for GPUs. MSc project. Department of Computer Science, University of Copenhagen. May 2018. (pdf)
- Niels G. W. Serup: Memory Block Merging in Futhark. MSc thesis. Department of Computer Science, University of Copenhagen. November 2017. (pdf)
- Rasmus Wriedt Larsen: Generating Efficient Code for Futhark’s Segmented Redomap. MSc thesis. Department of Computer Science, University of Copenhagen. March 2017. (pdf)
- Niels G. W. Serup: Extending Futhark with a write construct. MSc project. Department of Computer Science, University of Copenhagen. June 2016. (pdf).