MSc Defence by Mikkel Storgaard Knudsen
FShark: Futhark programming in FSharp
Futhark is a purely functional programming language, designed to be compiled to efficient GPU code. The GPU code has both C and Python interfaces, but does not interoperate with other mainstream languages such as C#, F# or Java.
We first describe and implement a C# code generator that allows GPU kernels written in Futhark to be compiled and used as external libraries in C# and F# programs. We then describe and implement the language FShark, which lets developers write and prototype their own GPU code entirely as declarative F# code. The language comes with a compiler of its own, which compiles FShark programs to Futhark code.
We argue that the FShark-to-Futhark translations are correct by comparing the results of F#-evaluated FShark code with their Futhark-evaluated counterparts, and by running a comprehensive suite of 128 unit tests. We show that Futhark can be compiled to C# GPU code by comparing running times across over 20 Futhark benchmark programs ported from other array programming languages. We report performance comparable with the C OpenCL backend (0 − 3% for complex benchmarks).
Finally, we show that complex GPU benchmarks can be easily written in FShark in a way that preserves the idiomatic F# style. The GPU benchmarks are compiled to GPU code and executed in an F# context, where they are shown to perform comparably with benchmarks handwritten in Futhark.
Cosmin E. Oancea
Michael Reichhardt Hansen