Researchers at the University of Copenhagen's Department of Computer Science recently unveiled Futhark, an open source functional programming language designed for creating code that runs on GPUs, for use in machine learning and other high-performance applications.
Futhark is meant to be more convenient to use than standard C/C++ frameworks for programming GPUs. It can automatically generate both C and Python code to be integrated with existing apps.
Most GPU programming involves using frameworks like OpenCL or CUDA, both of which use variations of C or C++ to generate code that runs on the GPU. Futhark can generate C code, but is its own language, more similar to Haskell or Standard ML than C. (Futhark is itself written in Haskell.)
Futhark's creators claim that the expressiveness of the language makes it easier to describe complex operations that use parallelism. This includes the ability to support nested parallelizations (parallel operations inside other parallel operations). Futhark can do this "despite the complexities of efficiently mapping to the flat parallelism supported by hardware, as a great many programs depend on this feature," say the language's creators.
Preliminary benchmarks pitting Futhark GPU programs against other GPU libraries showed mixed but promising results. For a maximum segment sum test, Futhark was nearly twice as fast as a competing open source project. In other cases, it matched or was only slightly slower than the competition. Futhark's developers attributed this to the newness of the language and its unrefined approach to allocating and reusing memory.
The current Futhark toolchain can generate code capable of running on either the CPU or GPU, with a variety of targets. For the former, it generates C code compiled by the GCC; for the latter, it generates C code that uses the OpenCL platform. Thus, the same code run on whatever hardware is available to support it, in much the same manner GPU-accelerated apps like the MapD database can fall back to using the CPU if needed.
Python users who want a speed boost can generate code with Futhark wrapped automatically in a Python module. The GPU code runs via PyOpenCL, which is a library for interfacing with GPUs. There are examples of this, such as a Futhark-driven GPU implementation of Conway's Game of Life.
Because Futhark is still fundamentally a research project, it is not yet as polished or complete as other languages. The documentation is incomplete, but both docs and language are open source on GitHub.